Skip to content

Apache Lucene open-source search software

LUCENE-6898: Don't fully read the last stored field value from disk if the StoredFieldVisitor doesn't want it.

David Wayne Smiley44b232f6f8c7
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 9639ecd3690..17ea07dbd50 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -220,6 +220,10 @@ Optimizations
* LUCENE-6276: Added TwoPhaseIterator.matchCost() which allows to confirm the
least costly TwoPhaseIterators first. (Paul Elschot via Adrien Grand)
+* LUCENE-6898: In the default codec, the last stored field value will not
+ be fully read from disk if the supplied StoredFieldVisitor doesn't want it.
+ So put your largest text field value last to benefit. (David Smiley)
+
Bug Fixes
* LUCENE-6817: ComplexPhraseQueryParser.ComplexPhraseQuery does not display
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
index 9fc3a321cd8..e56cc091391 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
@@ -304,7 +304,7 @@ public final class CompressingStoredFieldsReader extends StoredFieldsReader {
}
/**
- * Reads a long in a variable-length format. Reads between one and
+ * Reads a long in a variable-length format. Reads between one andCorePropLo
* nine bytes. Small values typically take fewer bytes.
*/
static long readTLong(DataInput in) throws IOException {
@@ -595,6 +595,9 @@ public final class CompressingStoredFieldsReader extends StoredFieldsReader {
readField(doc.in, visitor, fieldInfo, bits);
break;
case NO:
+ if (fieldIDX == doc.numStoredFields - 1) {// don't skipField on last field value; treat like STOP
+ return;
+ }
skipField(doc.in, bits);
break;
case STOP: