dungba88 commented on code in PR #12980: URL: https://github.com/apache/lucene/pull/12980#discussion_r1436295737
########## lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java: ########## @@ -187,33 +200,38 @@ public void write(Fields fields, NormsProducer norms) throws IOException { @Override public void close() throws IOException { - if (out != null) { + if (metaOut != null) { + assert dataOut != null; boolean success = false; try { // write field summary - final long dirStart = out.getFilePointer(); + final long dirStart = metaOut.getFilePointer(); - out.writeVInt(fields.size()); + metaOut.writeVInt(fields.size()); for (FieldMetaData field : fields) { - out.writeVInt(field.fieldInfo.number); - out.writeVLong(field.numTerms); + metaOut.writeVInt(field.fieldInfo.number); + metaOut.writeVLong(field.numTerms); if (field.fieldInfo.getIndexOptions() != IndexOptions.DOCS) { - out.writeVLong(field.sumTotalTermFreq); + metaOut.writeVLong(field.sumTotalTermFreq); } - out.writeVLong(field.sumDocFreq); - out.writeVInt(field.docCount); - field.dict.save(out, out); + metaOut.writeVLong(field.sumDocFreq); + metaOut.writeVInt(field.docCount); + // write the starting file pointer + metaOut.writeVLong(dataOut.getFilePointer()); Review Comment: Oh I think I found the bug, and why using an on-heap DataOutput works. This `close()` method is called after the FST for all fields have been saved (streamed), and thus `dataOut.getFilePointer()` always points to the same pointer (EOF). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org