mirror of https://github.com/apache/lucene.git
LUCENE-3580: fix postingsreaders to obey DISI contract
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1203190 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
87ac7de453
commit
4597d97e68
|
@ -994,6 +994,7 @@ public class Lucene3xFields extends FieldsProducer {
|
||||||
public PreDocsEnum reset(SegmentTermEnum termEnum, Bits liveDocs) throws IOException {
|
public PreDocsEnum reset(SegmentTermEnum termEnum, Bits liveDocs) throws IOException {
|
||||||
docs.setLiveDocs(liveDocs);
|
docs.setLiveDocs(liveDocs);
|
||||||
docs.seek(termEnum);
|
docs.seek(termEnum);
|
||||||
|
docID = -1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1050,6 +1051,7 @@ public class Lucene3xFields extends FieldsProducer {
|
||||||
public DocsAndPositionsEnum reset(SegmentTermEnum termEnum, Bits liveDocs) throws IOException {
|
public DocsAndPositionsEnum reset(SegmentTermEnum termEnum, Bits liveDocs) throws IOException {
|
||||||
pos.setLiveDocs(liveDocs);
|
pos.setLiveDocs(liveDocs);
|
||||||
pos.seek(termEnum);
|
pos.seek(termEnum);
|
||||||
|
docID = -1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
int limit; // number of docs in this posting
|
int limit; // number of docs in this posting
|
||||||
int ord; // how many docs we've read
|
int ord; // how many docs we've read
|
||||||
int doc; // doc we last read
|
int doc = -1; // doc we last read
|
||||||
|
int accum; // accumulator for doc deltas
|
||||||
int freq; // freq we last read
|
int freq; // freq we last read
|
||||||
|
|
||||||
Bits liveDocs;
|
Bits liveDocs;
|
||||||
|
@ -306,7 +307,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
limit = termState.docFreq;
|
limit = termState.docFreq;
|
||||||
assert limit > 0;
|
assert limit > 0;
|
||||||
ord = 0;
|
ord = 0;
|
||||||
doc = 0;
|
doc = -1;
|
||||||
|
accum = 0;
|
||||||
// if (DEBUG) System.out.println(" sde limit=" + limit + " freqFP=" + freqOffset);
|
// if (DEBUG) System.out.println(" sde limit=" + limit + " freqFP=" + freqOffset);
|
||||||
|
|
||||||
skipped = false;
|
skipped = false;
|
||||||
|
@ -329,9 +331,9 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
final int code = freqIn.readVInt();
|
final int code = freqIn.readVInt();
|
||||||
// if (DEBUG) System.out.println(" code=" + code);
|
// if (DEBUG) System.out.println(" code=" + code);
|
||||||
if (omitTF) {
|
if (omitTF) {
|
||||||
doc += code;
|
accum += code;
|
||||||
} else {
|
} else {
|
||||||
doc += code >>> 1; // shift off low bit
|
accum += code >>> 1; // shift off low bit
|
||||||
if ((code & 1) != 0) { // if low bit is set
|
if ((code & 1) != 0) { // if low bit is set
|
||||||
freq = 1; // freq is one
|
freq = 1; // freq is one
|
||||||
} else {
|
} else {
|
||||||
|
@ -339,13 +341,13 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(doc)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (DEBUG) System.out.println(" stpr.nextDoc return doc=" + doc);
|
//if (DEBUG) System.out.println(" stpr.nextDoc return doc=" + doc);
|
||||||
return doc;
|
return (doc = accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -360,9 +362,9 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
// manually inlined call to next() for speed
|
// manually inlined call to next() for speed
|
||||||
final int code = freqIn.readVInt();
|
final int code = freqIn.readVInt();
|
||||||
if (omitTF) {
|
if (omitTF) {
|
||||||
doc += code;
|
accum += code;
|
||||||
} else {
|
} else {
|
||||||
doc += code >>> 1; // shift off low bit
|
accum += code >>> 1; // shift off low bit
|
||||||
if ((code & 1) != 0) { // if low bit is set
|
if ((code & 1) != 0) { // if low bit is set
|
||||||
freq = 1; // freq is one
|
freq = 1; // freq is one
|
||||||
} else {
|
} else {
|
||||||
|
@ -370,8 +372,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(doc)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
docs[i] = doc;
|
docs[i] = doc = accum;
|
||||||
freqs[i] = freq;
|
freqs[i] = freq;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -422,7 +424,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
// Skipper moved
|
// Skipper moved
|
||||||
|
|
||||||
ord = newOrd;
|
ord = newOrd;
|
||||||
doc = skipper.getDoc();
|
doc = accum = skipper.getDoc();
|
||||||
freqIn.seek(skipper.getFreqPointer());
|
freqIn.seek(skipper.getFreqPointer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,7 +446,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
int limit; // number of docs in this posting
|
int limit; // number of docs in this posting
|
||||||
int ord; // how many docs we've read
|
int ord; // how many docs we've read
|
||||||
int doc; // doc we last read
|
int doc = -1; // doc we last read
|
||||||
|
int accum; // accumulator for doc deltas
|
||||||
int freq; // freq we last read
|
int freq; // freq we last read
|
||||||
int position;
|
int position;
|
||||||
|
|
||||||
|
@ -482,7 +485,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
assert limit > 0;
|
assert limit > 0;
|
||||||
|
|
||||||
ord = 0;
|
ord = 0;
|
||||||
doc = 0;
|
doc = -1;
|
||||||
|
accum = 0;
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
||||||
skipped = false;
|
skipped = false;
|
||||||
|
@ -510,7 +514,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
// Decode next doc/freq pair
|
// Decode next doc/freq pair
|
||||||
final int code = freqIn.readVInt();
|
final int code = freqIn.readVInt();
|
||||||
|
|
||||||
doc += code >>> 1; // shift off low bit
|
accum += code >>> 1; // shift off low bit
|
||||||
if ((code & 1) != 0) { // if low bit is set
|
if ((code & 1) != 0) { // if low bit is set
|
||||||
freq = 1; // freq is one
|
freq = 1; // freq is one
|
||||||
} else {
|
} else {
|
||||||
|
@ -518,7 +522,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
posPendingCount += freq;
|
posPendingCount += freq;
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(doc)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,7 +530,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
||||||
// if (DEBUG) System.out.println(" return doc=" + doc);
|
// if (DEBUG) System.out.println(" return doc=" + doc);
|
||||||
return doc;
|
return (doc = accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -572,7 +576,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
if (newOrd > ord) {
|
if (newOrd > ord) {
|
||||||
// Skipper moved
|
// Skipper moved
|
||||||
ord = newOrd;
|
ord = newOrd;
|
||||||
doc = skipper.getDoc();
|
doc = accum = skipper.getDoc();
|
||||||
freqIn.seek(skipper.getFreqPointer());
|
freqIn.seek(skipper.getFreqPointer());
|
||||||
lazyProxPointer = skipper.getProxPointer();
|
lazyProxPointer = skipper.getProxPointer();
|
||||||
posPendingCount = 0;
|
posPendingCount = 0;
|
||||||
|
@ -636,7 +640,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
int limit; // number of docs in this posting
|
int limit; // number of docs in this posting
|
||||||
int ord; // how many docs we've read
|
int ord; // how many docs we've read
|
||||||
int doc; // doc we last read
|
int doc = -1; // doc we last read
|
||||||
|
int accum; // accumulator for doc deltas
|
||||||
int freq; // freq we last read
|
int freq; // freq we last read
|
||||||
int position;
|
int position;
|
||||||
|
|
||||||
|
@ -679,7 +684,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
limit = termState.docFreq;
|
limit = termState.docFreq;
|
||||||
ord = 0;
|
ord = 0;
|
||||||
doc = 0;
|
doc = -1;
|
||||||
|
accum = 0;
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
||||||
skipped = false;
|
skipped = false;
|
||||||
|
@ -707,7 +713,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
// Decode next doc/freq pair
|
// Decode next doc/freq pair
|
||||||
final int code = freqIn.readVInt();
|
final int code = freqIn.readVInt();
|
||||||
|
|
||||||
doc += code >>> 1; // shift off low bit
|
accum += code >>> 1; // shift off low bit
|
||||||
if ((code & 1) != 0) { // if low bit is set
|
if ((code & 1) != 0) { // if low bit is set
|
||||||
freq = 1; // freq is one
|
freq = 1; // freq is one
|
||||||
} else {
|
} else {
|
||||||
|
@ -715,7 +721,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
posPendingCount += freq;
|
posPendingCount += freq;
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(doc)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -723,7 +729,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
||||||
//System.out.println("StandardR.D&PE nextDoc seg=" + segment + " return doc=" + doc);
|
//System.out.println("StandardR.D&PE nextDoc seg=" + segment + " return doc=" + doc);
|
||||||
return doc;
|
return (doc = accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -769,7 +775,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
|
||||||
if (newOrd > ord) {
|
if (newOrd > ord) {
|
||||||
// Skipper moved
|
// Skipper moved
|
||||||
ord = newOrd;
|
ord = newOrd;
|
||||||
doc = skipper.getDoc();
|
doc = accum = skipper.getDoc();
|
||||||
freqIn.seek(skipper.getFreqPointer());
|
freqIn.seek(skipper.getFreqPointer());
|
||||||
lazyProxPointer = skipper.getProxPointer();
|
lazyProxPointer = skipper.getProxPointer();
|
||||||
posPendingCount = 0;
|
posPendingCount = 0;
|
||||||
|
|
|
@ -273,7 +273,8 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
|
|
||||||
private Bits liveDocs;
|
private Bits liveDocs;
|
||||||
private int docUpto;
|
private int docUpto;
|
||||||
private int docID;
|
private int docID = -1;
|
||||||
|
private int accum;
|
||||||
private int freq;
|
private int freq;
|
||||||
private int payloadLen;
|
private int payloadLen;
|
||||||
private int numDocs;
|
private int numDocs;
|
||||||
|
@ -295,7 +296,8 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
in.reset(buffer, 0, bufferIn.length - bufferIn.offset);
|
in.reset(buffer, 0, bufferIn.length - bufferIn.offset);
|
||||||
System.arraycopy(bufferIn.bytes, bufferIn.offset, buffer, 0, bufferIn.length - bufferIn.offset);
|
System.arraycopy(bufferIn.bytes, bufferIn.offset, buffer, 0, bufferIn.length - bufferIn.offset);
|
||||||
this.liveDocs = liveDocs;
|
this.liveDocs = liveDocs;
|
||||||
docID = 0;
|
docID = -1;
|
||||||
|
accum = 0;
|
||||||
docUpto = 0;
|
docUpto = 0;
|
||||||
payloadLen = 0;
|
payloadLen = 0;
|
||||||
this.numDocs = numDocs;
|
this.numDocs = numDocs;
|
||||||
|
@ -314,12 +316,12 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
}
|
}
|
||||||
docUpto++;
|
docUpto++;
|
||||||
if (indexOptions == IndexOptions.DOCS_ONLY) {
|
if (indexOptions == IndexOptions.DOCS_ONLY) {
|
||||||
docID += in.readVInt();
|
accum += in.readVInt();
|
||||||
freq = 1;
|
freq = 1;
|
||||||
} else {
|
} else {
|
||||||
final int code = in.readVInt();
|
final int code = in.readVInt();
|
||||||
docID += code >>> 1;
|
accum += code >>> 1;
|
||||||
if (VERBOSE) System.out.println(" docID=" + docID + " code=" + code);
|
if (VERBOSE) System.out.println(" docID=" + accum + " code=" + code);
|
||||||
if ((code & 1) != 0) {
|
if ((code & 1) != 0) {
|
||||||
freq = 1;
|
freq = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -343,9 +345,9 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(docID)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
if (VERBOSE) System.out.println(" return docID=" + docID + " freq=" + freq);
|
if (VERBOSE) System.out.println(" return docID=" + accum + " freq=" + freq);
|
||||||
return docID;
|
return (docID = accum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,7 +382,8 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
|
|
||||||
private Bits liveDocs;
|
private Bits liveDocs;
|
||||||
private int docUpto;
|
private int docUpto;
|
||||||
private int docID;
|
private int docID = -1;
|
||||||
|
private int accum;
|
||||||
private int freq;
|
private int freq;
|
||||||
private int numDocs;
|
private int numDocs;
|
||||||
private int posPending;
|
private int posPending;
|
||||||
|
@ -412,7 +415,8 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
in.reset(buffer, 0, bufferIn.length - bufferIn.offset);
|
in.reset(buffer, 0, bufferIn.length - bufferIn.offset);
|
||||||
System.arraycopy(bufferIn.bytes, bufferIn.offset, buffer, 0, bufferIn.length - bufferIn.offset);
|
System.arraycopy(bufferIn.bytes, bufferIn.offset, buffer, 0, bufferIn.length - bufferIn.offset);
|
||||||
this.liveDocs = liveDocs;
|
this.liveDocs = liveDocs;
|
||||||
docID = 0;
|
docID = -1;
|
||||||
|
accum = 0;
|
||||||
docUpto = 0;
|
docUpto = 0;
|
||||||
payload.bytes = buffer;
|
payload.bytes = buffer;
|
||||||
payloadLength = 0;
|
payloadLength = 0;
|
||||||
|
@ -436,7 +440,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
docUpto++;
|
docUpto++;
|
||||||
|
|
||||||
final int code = in.readVInt();
|
final int code = in.readVInt();
|
||||||
docID += code >>> 1;
|
accum += code >>> 1;
|
||||||
if ((code & 1) != 0) {
|
if ((code & 1) != 0) {
|
||||||
freq = 1;
|
freq = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -444,11 +448,11 @@ public class MemoryPostingsFormat extends PostingsFormat {
|
||||||
assert freq > 0;
|
assert freq > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(docID)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
pos = 0;
|
pos = 0;
|
||||||
posPending = freq;
|
posPending = freq;
|
||||||
if (VERBOSE) System.out.println(" return docID=" + docID + " freq=" + freq);
|
if (VERBOSE) System.out.println(" return docID=" + accum + " freq=" + freq);
|
||||||
return docID;
|
return (docID = accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip positions
|
// Skip positions
|
||||||
|
|
|
@ -257,7 +257,8 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
private final IndexOptions indexOptions;
|
private final IndexOptions indexOptions;
|
||||||
private final boolean storePayloads;
|
private final boolean storePayloads;
|
||||||
private Bits liveDocs;
|
private Bits liveDocs;
|
||||||
private int docID;
|
private int docID = -1;
|
||||||
|
private int accum;
|
||||||
private int freq;
|
private int freq;
|
||||||
private int payloadLength;
|
private int payloadLength;
|
||||||
|
|
||||||
|
@ -279,7 +280,8 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
System.arraycopy(termState.postings, 0, postingsBytes, 0, termState.postingsSize);
|
System.arraycopy(termState.postings, 0, postingsBytes, 0, termState.postingsSize);
|
||||||
postings.reset(postingsBytes, 0, termState.postingsSize);
|
postings.reset(postingsBytes, 0, termState.postingsSize);
|
||||||
docID = 0;
|
docID = -1;
|
||||||
|
accum = 0;
|
||||||
payloadLength = 0;
|
payloadLength = 0;
|
||||||
freq = 1;
|
freq = 1;
|
||||||
this.liveDocs = liveDocs;
|
this.liveDocs = liveDocs;
|
||||||
|
@ -302,9 +304,9 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
final int code = postings.readVInt();
|
final int code = postings.readVInt();
|
||||||
//System.out.println(" read code=" + code);
|
//System.out.println(" read code=" + code);
|
||||||
if (indexOptions == IndexOptions.DOCS_ONLY) {
|
if (indexOptions == IndexOptions.DOCS_ONLY) {
|
||||||
docID += code;
|
accum += code;
|
||||||
} else {
|
} else {
|
||||||
docID += code >>> 1; // shift off low bit
|
accum += code >>> 1; // shift off low bit
|
||||||
if ((code & 1) != 0) { // if low bit is set
|
if ((code & 1) != 0) { // if low bit is set
|
||||||
freq = 1; // freq is one
|
freq = 1; // freq is one
|
||||||
} else {
|
} else {
|
||||||
|
@ -332,8 +334,8 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(docID)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
return docID;
|
return (docID = accum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,7 +367,8 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
private final boolean storePayloads;
|
private final boolean storePayloads;
|
||||||
|
|
||||||
private Bits liveDocs;
|
private Bits liveDocs;
|
||||||
private int docID;
|
private int docID = -1;
|
||||||
|
private int accum;
|
||||||
private int freq;
|
private int freq;
|
||||||
private int posPending;
|
private int posPending;
|
||||||
private int position;
|
private int position;
|
||||||
|
@ -394,7 +397,8 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
this.liveDocs = liveDocs;
|
this.liveDocs = liveDocs;
|
||||||
payloadLength = 0;
|
payloadLength = 0;
|
||||||
posPending = 0;
|
posPending = 0;
|
||||||
docID = 0;
|
docID = -1;
|
||||||
|
accum = 0;
|
||||||
//System.out.println("PR d&p reset storesPayloads=" + storePayloads + " bytes=" + bytes.length + " this=" + this);
|
//System.out.println("PR d&p reset storesPayloads=" + storePayloads + " bytes=" + bytes.length + " this=" + this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +418,7 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int code = postings.readVInt();
|
final int code = postings.readVInt();
|
||||||
docID += code >>> 1; // shift off low bit
|
accum += code >>> 1; // shift off low bit
|
||||||
if ((code & 1) != 0) { // if low bit is set
|
if ((code & 1) != 0) { // if low bit is set
|
||||||
freq = 1; // freq is one
|
freq = 1; // freq is one
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,10 +426,10 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
posPending = freq;
|
posPending = freq;
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(docID)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
//System.out.println(" return docID=" + docID + " freq=" + freq);
|
//System.out.println(" return docID=" + docID + " freq=" + freq);
|
||||||
position = 0;
|
position = 0;
|
||||||
return docID;
|
return (docID = accum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,7 +312,8 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
class SepDocsEnum extends DocsEnum {
|
class SepDocsEnum extends DocsEnum {
|
||||||
int docFreq;
|
int docFreq;
|
||||||
int doc;
|
int doc = -1;
|
||||||
|
int accum;
|
||||||
int count;
|
int count;
|
||||||
int freq;
|
int freq;
|
||||||
long freqStart;
|
long freqStart;
|
||||||
|
@ -376,7 +377,8 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
// NOTE: unused if docFreq < skipMinimum:
|
// NOTE: unused if docFreq < skipMinimum:
|
||||||
skipFP = termState.skipFP;
|
skipFP = termState.skipFP;
|
||||||
count = 0;
|
count = 0;
|
||||||
doc = 0;
|
doc = -1;
|
||||||
|
accum = 0;
|
||||||
skipped = false;
|
skipped = false;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -394,18 +396,18 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
// Decode next doc
|
// Decode next doc
|
||||||
//System.out.println("decode docDelta:");
|
//System.out.println("decode docDelta:");
|
||||||
doc += docReader.next();
|
accum += docReader.next();
|
||||||
|
|
||||||
if (!omitTF) {
|
if (!omitTF) {
|
||||||
//System.out.println("decode freq:");
|
//System.out.println("decode freq:");
|
||||||
freq = freqReader.next();
|
freq = freqReader.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(doc)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return doc;
|
return (doc = accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -420,14 +422,14 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
count++;
|
count++;
|
||||||
// manually inlined call to next() for speed
|
// manually inlined call to next() for speed
|
||||||
//System.out.println("decode doc");
|
//System.out.println("decode doc");
|
||||||
doc += docReader.next();
|
accum += docReader.next();
|
||||||
if (!omitTF) {
|
if (!omitTF) {
|
||||||
//System.out.println("decode freq");
|
//System.out.println("decode freq");
|
||||||
freq = freqReader.next();
|
freq = freqReader.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(doc)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
docs[i] = doc;
|
docs[i] = doc = accum;
|
||||||
freqs[i] = freq;
|
freqs[i] = freq;
|
||||||
//System.out.println(" docs[" + i + "]=" + doc + " count=" + count + " dF=" + docFreq);
|
//System.out.println(" docs[" + i + "]=" + doc + " count=" + count + " dF=" + docFreq);
|
||||||
i++;
|
i++;
|
||||||
|
@ -488,7 +490,7 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
}
|
}
|
||||||
skipper.getDocIndex().seek(docReader);
|
skipper.getDocIndex().seek(docReader);
|
||||||
count = newCount;
|
count = newCount;
|
||||||
doc = skipper.getDoc();
|
doc = accum = skipper.getDoc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +507,8 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
class SepDocsAndPositionsEnum extends DocsAndPositionsEnum {
|
class SepDocsAndPositionsEnum extends DocsAndPositionsEnum {
|
||||||
int docFreq;
|
int docFreq;
|
||||||
int doc;
|
int doc = -1;
|
||||||
|
int accum;
|
||||||
int count;
|
int count;
|
||||||
int freq;
|
int freq;
|
||||||
long freqStart;
|
long freqStart;
|
||||||
|
@ -572,7 +575,8 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
docFreq = termState.docFreq;
|
docFreq = termState.docFreq;
|
||||||
count = 0;
|
count = 0;
|
||||||
doc = 0;
|
doc = -1;
|
||||||
|
accum = 0;
|
||||||
pendingPosCount = 0;
|
pendingPosCount = 0;
|
||||||
pendingPayloadBytes = 0;
|
pendingPayloadBytes = 0;
|
||||||
skipped = false;
|
skipped = false;
|
||||||
|
@ -595,20 +599,20 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
|
|
||||||
// Decode next doc
|
// Decode next doc
|
||||||
//System.out.println(" sep d&p read doc");
|
//System.out.println(" sep d&p read doc");
|
||||||
doc += docReader.next();
|
accum += docReader.next();
|
||||||
|
|
||||||
//System.out.println(" sep d&p read freq");
|
//System.out.println(" sep d&p read freq");
|
||||||
freq = freqReader.next();
|
freq = freqReader.next();
|
||||||
|
|
||||||
pendingPosCount += freq;
|
pendingPosCount += freq;
|
||||||
|
|
||||||
if (liveDocs == null || liveDocs.get(doc)) {
|
if (liveDocs == null || liveDocs.get(accum)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
position = 0;
|
position = 0;
|
||||||
return doc;
|
return (doc = accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -668,7 +672,7 @@ public class SepPostingsReader extends PostingsReaderBase {
|
||||||
posIndex.set(skipper.getPosIndex());
|
posIndex.set(skipper.getPosIndex());
|
||||||
posSeekPending = true;
|
posSeekPending = true;
|
||||||
count = newCount;
|
count = newCount;
|
||||||
doc = skipper.getDoc();
|
doc = accum = skipper.getDoc();
|
||||||
//System.out.println(" moved to doc=" + doc);
|
//System.out.println(" moved to doc=" + doc);
|
||||||
//payloadIn.seek(skipper.getPayloadPointer());
|
//payloadIn.seek(skipper.getPayloadPointer());
|
||||||
payloadFP = skipper.getPayloadPointer();
|
payloadFP = skipper.getPayloadPointer();
|
||||||
|
|
|
@ -314,7 +314,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
|
||||||
private class SimpleTextDocsAndPositionsEnum extends DocsAndPositionsEnum {
|
private class SimpleTextDocsAndPositionsEnum extends DocsAndPositionsEnum {
|
||||||
private final IndexInput inStart;
|
private final IndexInput inStart;
|
||||||
private final IndexInput in;
|
private final IndexInput in;
|
||||||
private int docID;
|
private int docID = -1;
|
||||||
private int tf;
|
private int tf;
|
||||||
private Bits liveDocs;
|
private Bits liveDocs;
|
||||||
private final BytesRef scratch = new BytesRef(10);
|
private final BytesRef scratch = new BytesRef(10);
|
||||||
|
@ -336,6 +336,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
|
||||||
public SimpleTextDocsAndPositionsEnum reset(long fp, Bits liveDocs) {
|
public SimpleTextDocsAndPositionsEnum reset(long fp, Bits liveDocs) {
|
||||||
this.liveDocs = liveDocs;
|
this.liveDocs = liveDocs;
|
||||||
nextDocStart = fp;
|
nextDocStart = fp;
|
||||||
|
docID = -1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,13 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.document.FieldType;
|
import org.apache.lucene.document.FieldType;
|
||||||
|
import org.apache.lucene.document.StringField;
|
||||||
import org.apache.lucene.document.TextField;
|
import org.apache.lucene.document.TextField;
|
||||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||||
import org.apache.lucene.index.IndexReader.ReaderContext;
|
import org.apache.lucene.index.IndexReader.ReaderContext;
|
||||||
|
import org.apache.lucene.search.DocIdSetIterator;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
|
@ -331,5 +334,50 @@ public class TestDocsAndPositions extends LuceneTestCase {
|
||||||
reader.close();
|
reader.close();
|
||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDocsEnumStart() throws Exception {
|
||||||
|
Directory dir = newDirectory();
|
||||||
|
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
|
||||||
|
Document doc = new Document();
|
||||||
|
doc.add(newField("foo", "bar", StringField.TYPE_UNSTORED));
|
||||||
|
writer.addDocument(doc);
|
||||||
|
IndexReader reader = writer.getReader();
|
||||||
|
IndexReader r = getOnlySegmentReader(reader);
|
||||||
|
DocsEnum disi = r.termDocsEnum(null, "foo", new BytesRef("bar"));
|
||||||
|
int docid = disi.docID();
|
||||||
|
assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
|
||||||
|
// now reuse and check again
|
||||||
|
disi = r.terms("foo").docs(null, new BytesRef("bar"), disi);
|
||||||
|
docid = disi.docID();
|
||||||
|
assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
writer.close();
|
||||||
|
r.close();
|
||||||
|
dir.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDocsAndPositionsEnumStart() throws Exception {
|
||||||
|
Directory dir = newDirectory();
|
||||||
|
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
|
||||||
|
Document doc = new Document();
|
||||||
|
doc.add(newField("foo", "bar", TextField.TYPE_UNSTORED));
|
||||||
|
writer.addDocument(doc);
|
||||||
|
IndexReader reader = writer.getReader();
|
||||||
|
IndexReader r = getOnlySegmentReader(reader);
|
||||||
|
DocsAndPositionsEnum disi = r.termPositionsEnum(null, "foo", new BytesRef("bar"));
|
||||||
|
int docid = disi.docID();
|
||||||
|
assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
|
||||||
|
// now reuse and check again
|
||||||
|
disi = r.terms("foo").docsAndPositions(null, new BytesRef("bar"), disi);
|
||||||
|
docid = disi.docID();
|
||||||
|
assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
|
||||||
|
writer.close();
|
||||||
|
r.close();
|
||||||
|
dir.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue