Skip to content

Apache Lucene open-source search software

LUCENE-2884: fix StandardPostingsReader's enums to not try to load skip data when there wasn't any

Michael McCandless25f5488fd2ce
diff --git a/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java b/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java
index 1ea93a04495..d4a6ac1bce7 100644
--- a/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java
+++ b/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java
@@ -514,7 +514,7 @@ public class BlockTermsReader extends FieldsProducer {
metadata, ie docFreq, totalTermFreq or pulls a D/&PEnum, we then (lazily)
decode all metadata up to the current term. */
private BytesRef _next() throws IOException {
- //System.out.println("BTR._next this=" + this + " termCount=" + state.termCount + " (vs " + state.blockTermCount + ")");
+ //System.out.println("BTR._next seg=" + segment + " this=" + this + " termCount=" + state.termCount + " (vs " + state.blockTermCount + ")");
if (state.termCount == state.blockTermCount) {
if (!nextBlock()) {
//System.out.println(" eof");
diff --git a/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReader.java b/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReader.java
index 61851070c87..707bb43dec1 100644
--- a/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReader.java
+++ b/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReader.java
@@ -172,11 +172,14 @@ public class StandardPostingsReader extends PostingsReaderBase {
} else {
termState.freqOffset += termState.bytesReader.readVLong();
}
+ //System.out.println(" dF=" + termState.docFreq);
//System.out.println(" freqFP=" + termState.freqOffset);
+ assert termState.freqOffset < freqIn.length();
if (termState.docFreq >= skipInterval) {
termState.skipOffset = termState.bytesReader.readVInt();
- //System.out.println(" skipOffset=" + termState.skipOffset);
+ //System.out.println(" skipOffset=" + termState.skipOffset + " vs freqIn.length=" + freqIn.length());
+ assert termState.freqOffset + termState.skipOffset < freqIn.length();
} else {
// undefined
}
@@ -375,7 +378,7 @@ public class StandardPostingsReader extends PostingsReaderBase {
// TODO: jump right to next() if target is < X away
// from where we are now?
- if (skipOffset > 0) {
+ if (limit >= skipInterval) {
// There are enough docs in the posting to have
// skip data
@@ -528,7 +531,7 @@ public class StandardPostingsReader extends PostingsReaderBase {
// TODO: jump right to next() if target is < X away
// from where we are now?
- if (skipOffset > 0) {
+ if (limit >= skipInterval) {
// There are enough docs in the posting to have
// skip data
@@ -670,7 +673,7 @@ public class StandardPostingsReader extends PostingsReaderBase {
freqOffset = termState.freqOffset;
proxOffset = termState.proxOffset;
skipOffset = termState.skipOffset;
- //System.out.println("StandardR.D&PE reset seg=" + segment + " limit=" + limit + " freqFP=" + freqOffset + " proxFP=" + proxOffset);
+ //System.out.println("StandardR.D&PE reset seg=" + segment + " limit=" + limit + " freqFP=" + freqOffset + " proxFP=" + proxOffset + " this=" + this);
return this;
}
@@ -720,10 +723,11 @@ public class StandardPostingsReader extends PostingsReaderBase {
@Override
public int advance(int target) throws IOException {
+ //System.out.println("StandardR.D&PE advance seg=" + segment + " target=" + target + " this=" + this);
// TODO: jump right to next() if target is < X away
// from where we are now?
- if (skipOffset > 0) {
+ if (limit >= skipInterval) {
// There are enough docs in the posting to have
// skip data
@@ -738,7 +742,7 @@ public class StandardPostingsReader extends PostingsReaderBase {
// This is the first time this posting has
// skipped, since reset() was called, so now we
// load the skip data for this posting
-
+ //System.out.println(" init skipper freqOffset=" + freqOffset + " skipOffset=" + skipOffset + " vs len=" + freqIn.length());
skipper.init(freqOffset+skipOffset,
freqOffset, proxOffset,
limit, true);