rmuir commented on code in PR #892: URL: https://github.com/apache/lucene/pull/892#discussion_r877982698
########## lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsWriter.java: ########## @@ -553,14 +554,20 @@ private void copyChunks( final long toPointer = toDocID == sub.maxDoc ? reader.getMaxPointer() : index.getStartPointer(toDocID); if (fromPointer < toPointer) { - if (numBufferedDocs > 0) { - flush(true); - } final IndexInput rawDocs = reader.getFieldsStream(); rawDocs.seek(fromPointer); do { final int base = rawDocs.readVInt(); final int code = rawDocs.readVInt(); + final boolean dirtyChunk = (code & 2) != 0; + if (copyDirtyChunks) { + if (numBufferedDocs > 0) { + flush(true); + } + } else if (dirtyChunk || numBufferedDocs > 0) { + // Don't copy a dirty chunk or force a flush, which would create a dirty chunk + break; + } Review Comment: I find the way this is organized confusing, especially compared to the previous `if buffered > 0 flush()`. Is there some other way the code could be re-arranged? the if-then-else structure is just especially complicated and hard on the eyes. Maybe, we should avoid the use of `copyDirtyChunks` boolean. This boolean is making the logic especially difficult for me. If instead of `if (copyDirtyChunks)`, it were to read `if (mergeStrategy == DIRTY_BULK)`, then its on its way to getting better. (separately, i also hate DIRTY_BULK and CLEAN_BULK names, i will think about it). -- 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