You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2015/06/25 15:59:21 UTC
svn commit: r1687524 [2/7] - in /lucene/dev/trunk: lucene/
lucene/analysis/common/src/test/org/apache/lucene/analysis/core/
lucene/analysis/common/src/test/org/apache/lucene/analysis/sinks/
lucene/analysis/common/src/test/org/apache/lucene/analysis/sta...
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50DocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50DocValuesProducer.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50DocValuesProducer.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50DocValuesProducer.java Thu Jun 25 13:59:19 2015
@@ -1122,7 +1122,7 @@ class Lucene50DocValuesProducer extends
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
throw new UnsupportedOperationException();
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java Thu Jun 25 13:59:19 2015
@@ -32,7 +32,6 @@ import org.apache.lucene.index.SegmentRe
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.RamUsageEstimator;
@@ -192,7 +191,7 @@ public final class Lucene50PostingsReade
}
@Override
- public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+ public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, PostingsEnum reuse, int flags) throws IOException {
boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
@@ -208,7 +207,7 @@ public final class Lucene50PostingsReade
} else {
docsEnum = new BlockDocsEnum(fieldInfo);
}
- return docsEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
+ return docsEnum.reset((IntBlockTermState) termState, flags);
} else if ((indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) &&
(indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) {
BlockPostingsEnum docsAndPositionsEnum;
@@ -220,7 +219,7 @@ public final class Lucene50PostingsReade
} else {
docsAndPositionsEnum = new BlockPostingsEnum(fieldInfo);
}
- return docsAndPositionsEnum.reset(liveDocs, (IntBlockTermState) termState);
+ return docsAndPositionsEnum.reset((IntBlockTermState) termState);
} else {
EverythingEnum everythingEnum;
if (reuse instanceof EverythingEnum) {
@@ -231,7 +230,7 @@ public final class Lucene50PostingsReade
} else {
everythingEnum = new EverythingEnum(fieldInfo);
}
- return everythingEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
+ return everythingEnum.reset((IntBlockTermState) termState, flags);
}
}
@@ -272,8 +271,6 @@ public final class Lucene50PostingsReade
// docID for next skip point, we won't use skipper if
// target docID is not larger than this
private int nextSkipDoc;
-
- private Bits liveDocs;
private boolean needsFreq; // true if the caller actually needs frequencies
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
@@ -295,9 +292,7 @@ public final class Lucene50PostingsReade
indexHasPayloads == fieldInfo.hasPayloads();
}
- public PostingsEnum reset(Bits liveDocs, IntBlockTermState termState, int flags) throws IOException {
- this.liveDocs = liveDocs;
-
+ public PostingsEnum reset(IntBlockTermState termState, int flags) throws IOException {
docFreq = termState.docFreq;
totalTermFreq = indexHasFreq ? termState.totalTermFreq : docFreq;
docTermStartFP = termState.docStartFP;
@@ -380,26 +375,20 @@ public final class Lucene50PostingsReade
@Override
public int nextDoc() throws IOException {
- while (true) {
-
- if (docUpto == docFreq) {
- return doc = NO_MORE_DOCS;
- }
- if (docBufferUpto == BLOCK_SIZE) {
- refillDocs();
- }
+ if (docUpto == docFreq) {
+ return doc = NO_MORE_DOCS;
+ }
+ if (docBufferUpto == BLOCK_SIZE) {
+ refillDocs();
+ }
- accum += docDeltaBuffer[docBufferUpto];
- docUpto++;
+ accum += docDeltaBuffer[docBufferUpto];
+ docUpto++;
- if (liveDocs == null || liveDocs.get(accum)) {
- doc = accum;
- freq = freqBuffer[docBufferUpto];
- docBufferUpto++;
- return doc;
- }
- docBufferUpto++;
- }
+ doc = accum;
+ freq = freqBuffer[docBufferUpto];
+ docBufferUpto++;
+ return doc;
}
@Override
@@ -467,14 +456,9 @@ public final class Lucene50PostingsReade
}
}
- if (liveDocs == null || liveDocs.get(accum)) {
- freq = freqBuffer[docBufferUpto];
- docBufferUpto++;
- return doc = accum;
- } else {
- docBufferUpto++;
- return nextDoc();
- }
+ freq = freqBuffer[docBufferUpto];
+ docBufferUpto++;
+ return doc = accum;
}
@Override
@@ -544,7 +528,6 @@ public final class Lucene50PostingsReade
private int nextSkipDoc;
- private Bits liveDocs;
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
public BlockPostingsEnum(FieldInfo fieldInfo) throws IOException {
@@ -562,9 +545,7 @@ public final class Lucene50PostingsReade
indexHasPayloads == fieldInfo.hasPayloads();
}
- public PostingsEnum reset(Bits liveDocs, IntBlockTermState termState) throws IOException {
- this.liveDocs = liveDocs;
-
+ public PostingsEnum reset(IntBlockTermState termState) throws IOException {
docFreq = termState.docFreq;
docTermStartFP = termState.docStartFP;
posTermStartFP = termState.posStartFP;
@@ -660,26 +641,22 @@ public final class Lucene50PostingsReade
@Override
public int nextDoc() throws IOException {
- while (true) {
- if (docUpto == docFreq) {
- return doc = NO_MORE_DOCS;
- }
- if (docBufferUpto == BLOCK_SIZE) {
- refillDocs();
- }
+ if (docUpto == docFreq) {
+ return doc = NO_MORE_DOCS;
+ }
+ if (docBufferUpto == BLOCK_SIZE) {
+ refillDocs();
+ }
- accum += docDeltaBuffer[docBufferUpto];
- freq = freqBuffer[docBufferUpto];
- posPendingCount += freq;
- docBufferUpto++;
- docUpto++;
+ accum += docDeltaBuffer[docBufferUpto];
+ freq = freqBuffer[docBufferUpto];
+ posPendingCount += freq;
+ docBufferUpto++;
+ docUpto++;
- if (liveDocs == null || liveDocs.get(accum)) {
- doc = accum;
- position = 0;
- return doc;
- }
- }
+ doc = accum;
+ position = 0;
+ return doc;
}
@Override
@@ -745,12 +722,8 @@ public final class Lucene50PostingsReade
}
}
- if (liveDocs == null || liveDocs.get(accum)) {
- position = 0;
- return doc = accum;
- } else {
- return nextDoc();
- }
+ position = 0;
+ return doc = accum;
}
// TODO: in theory we could avoid loading frq block
@@ -904,8 +877,6 @@ public final class Lucene50PostingsReade
private long skipOffset;
private int nextSkipDoc;
-
- private Bits liveDocs;
private boolean needsOffsets; // true if we actually need offsets
private boolean needsPayloads; // true if we actually need payloads
@@ -946,9 +917,7 @@ public final class Lucene50PostingsReade
indexHasPayloads == fieldInfo.hasPayloads();
}
- public EverythingEnum reset(Bits liveDocs, IntBlockTermState termState, int flags) throws IOException {
- this.liveDocs = liveDocs;
-
+ public EverythingEnum reset(IntBlockTermState termState, int flags) throws IOException {
docFreq = termState.docFreq;
docTermStartFP = termState.docStartFP;
posTermStartFP = termState.posStartFP;
@@ -1087,27 +1056,23 @@ public final class Lucene50PostingsReade
@Override
public int nextDoc() throws IOException {
- while (true) {
- if (docUpto == docFreq) {
- return doc = NO_MORE_DOCS;
- }
- if (docBufferUpto == BLOCK_SIZE) {
- refillDocs();
- }
+ if (docUpto == docFreq) {
+ return doc = NO_MORE_DOCS;
+ }
+ if (docBufferUpto == BLOCK_SIZE) {
+ refillDocs();
+ }
- accum += docDeltaBuffer[docBufferUpto];
- freq = freqBuffer[docBufferUpto];
- posPendingCount += freq;
- docBufferUpto++;
- docUpto++;
+ accum += docDeltaBuffer[docBufferUpto];
+ freq = freqBuffer[docBufferUpto];
+ posPendingCount += freq;
+ docBufferUpto++;
+ docUpto++;
- if (liveDocs == null || liveDocs.get(accum)) {
- doc = accum;
- position = 0;
- lastStartOffset = 0;
- return doc;
- }
- }
+ doc = accum;
+ position = 0;
+ lastStartOffset = 0;
+ return doc;
}
@Override
@@ -1174,13 +1139,9 @@ public final class Lucene50PostingsReade
}
}
- if (liveDocs == null || liveDocs.get(accum)) {
- position = 0;
- lastStartOffset = 0;
- return doc = accum;
- } else {
- return nextDoc();
- }
+ position = 0;
+ lastStartOffset = 0;
+ return doc = accum;
}
// TODO: in theory we could avoid loading frq block
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java Thu Jun 25 13:59:19 2015
@@ -31,9 +31,9 @@ import org.apache.lucene.search.DocIdSet
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryWrapperFilter;
-import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.InfoStream;
@@ -550,7 +550,8 @@ class BufferedUpdatesStream implements A
if (state.delGen < delGen) {
// we don't need term frequencies for this
- state.postingsEnum = state.termsEnum.postings(state.rld.getLiveDocs(), state.postingsEnum, PostingsEnum.NONE);
+ final Bits acceptDocs = state.rld.getLiveDocs();
+ state.postingsEnum = state.termsEnum.postings(state.postingsEnum, PostingsEnum.NONE);
assert state.postingsEnum != null;
@@ -559,6 +560,9 @@ class BufferedUpdatesStream implements A
if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
+ if (acceptDocs != null && acceptDocs.get(docID) == false) {
+ continue;
+ }
if (!state.any) {
state.rld.initWritableLiveDocs();
state.any = true;
@@ -646,7 +650,8 @@ class BufferedUpdatesStream implements A
if (termsEnum.seekExact(term.bytes())) {
// we don't need term frequencies for this
- postingsEnum = termsEnum.postings(segState.rld.getLiveDocs(), postingsEnum, PostingsEnum.NONE);
+ final Bits acceptDocs = segState.rld.getLiveDocs();
+ postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.NONE);
DocValuesFieldUpdates dvUpdates = dvUpdatesContainer.getUpdates(update.field, update.type);
if (dvUpdates == null) {
@@ -657,6 +662,9 @@ class BufferedUpdatesStream implements A
if (doc >= limit) {
break; // no more docs that can be updated for this term
}
+ if (acceptDocs != null && acceptDocs.get(doc) == false) {
+ continue;
+ }
dvUpdates.add(doc, update.value);
}
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java Thu Jun 25 13:59:19 2015
@@ -528,9 +528,8 @@ public class CheckIndex implements Close
result.cantOpenSegments = true;
return result;
}
- int format = 0;
try {
- format = input.readInt();
+ /*int format =*/ input.readInt();
} catch (Throwable t) {
if (failFast) {
IOUtils.reThrow(t);
@@ -959,7 +958,7 @@ public class CheckIndex implements Close
}
}
- postingsEnum = termsEnum.postings(null, postingsEnum, 0);
+ postingsEnum = termsEnum.postings(postingsEnum, 0);
int lastDoc = -1;
while (true) {
@@ -1203,7 +1202,6 @@ public class CheckIndex implements Close
long sumTotalTermFreq = 0;
long sumDocFreq = 0;
- long upto = 0;
FixedBitSet visitedDocs = new FixedBitSet(maxDoc);
while(true) {
@@ -1249,7 +1247,7 @@ public class CheckIndex implements Close
}
sumDocFreq += docFreq;
- postings = termsEnum.postings(liveDocs, postings, PostingsEnum.ALL);
+ postings = termsEnum.postings(postings, PostingsEnum.ALL);
if (hasFreqs == false) {
if (termsEnum.totalTermFreq() != -1) {
@@ -1275,13 +1273,13 @@ public class CheckIndex implements Close
int lastDoc = -1;
int docCount = 0;
+ boolean hasNonDeletedDocs = false;
long totalTermFreq = 0;
while(true) {
final int doc = postings.nextDoc();
if (doc == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
- status.totFreq++;
visitedDocs.set(doc);
int freq = -1;
if (hasFreqs) {
@@ -1289,7 +1287,6 @@ public class CheckIndex implements Close
if (freq <= 0) {
throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " is out of bounds");
}
- status.totPos += freq;
totalTermFreq += freq;
} else {
// When a field didn't index freq, it must
@@ -1299,6 +1296,13 @@ public class CheckIndex implements Close
throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " != 1 when Terms.hasFreqs() is false");
}
}
+ if (liveDocs == null || liveDocs.get(doc)) {
+ hasNonDeletedDocs = true;
+ status.totFreq++;
+ if (freq >= 0) {
+ status.totPos += freq;
+ }
+ }
docCount++;
if (doc <= lastDoc) {
@@ -1358,7 +1362,7 @@ public class CheckIndex implements Close
}
}
- if (docCount != 0) {
+ if (hasNonDeletedDocs) {
status.termCount++;
} else {
status.delTermCount++;
@@ -1367,28 +1371,6 @@ public class CheckIndex implements Close
final long totalTermFreq2 = termsEnum.totalTermFreq();
final boolean hasTotalTermFreq = hasFreqs && totalTermFreq2 != -1;
- // Re-count if there are deleted docs:
- if (liveDocs != null) {
- if (hasFreqs) {
- postings = termsEnum.postings(null, postings);
- docCount = 0;
- totalTermFreq = 0;
- while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
- visitedDocs.set(postings.docID());
- docCount++;
- totalTermFreq += postings.freq();
- }
- } else {
- postings = termsEnum.postings(null, postings, PostingsEnum.NONE);
- docCount = 0;
- totalTermFreq = -1;
- while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
- visitedDocs.set(postings.docID());
- docCount++;
- }
- }
- }
-
if (docCount != docFreq) {
throw new RuntimeException("term " + term + " docFreq=" + docFreq + " != tot docs w/o deletions " + docCount);
}
@@ -1406,7 +1388,7 @@ public class CheckIndex implements Close
if (hasPositions) {
for(int idx=0;idx<7;idx++) {
final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);
- postings = termsEnum.postings(liveDocs, postings, PostingsEnum.ALL);
+ postings = termsEnum.postings(postings, PostingsEnum.ALL);
final int docID = postings.advance(skipDocID);
if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
@@ -1470,7 +1452,7 @@ public class CheckIndex implements Close
} else {
for(int idx=0;idx<7;idx++) {
final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);
- postings = termsEnum.postings(liveDocs, postings, PostingsEnum.NONE);
+ postings = termsEnum.postings(postings, PostingsEnum.NONE);
final int docID = postings.advance(skipDocID);
if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
@@ -1552,7 +1534,7 @@ public class CheckIndex implements Close
}
int expectedDocFreq = termsEnum.docFreq();
- PostingsEnum d = termsEnum.postings(null, null, PostingsEnum.NONE);
+ PostingsEnum d = termsEnum.postings(null, PostingsEnum.NONE);
int docFreq = 0;
while (d.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
docFreq++;
@@ -1591,7 +1573,6 @@ public class CheckIndex implements Close
}
// Seek by term
- long totDocCount = 0;
for(int i=seekCount-1;i>=0;i--) {
if (termsEnum.seekCeil(seekTerms[i]) != TermsEnum.SeekStatus.FOUND) {
throw new RuntimeException("seek to existing term " + seekTerms[i] + " failed");
@@ -1600,40 +1581,10 @@ public class CheckIndex implements Close
throw new RuntimeException("seek to existing term " + seekTerms[i] + " returned FOUND but seeked to the wrong term " + termsEnum.term());
}
- postings = termsEnum.postings(liveDocs, postings, PostingsEnum.NONE);
- if (postings == null) {
- throw new RuntimeException("null DocsEnum from to existing term " + seekTerms[i]);
- }
-
- while (postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
- totDocCount++;
- }
- }
-
- long totDocCountNoDeletes = 0;
- long totDocFreq = 0;
- for(int i=0;i<seekCount;i++) {
- if (!termsEnum.seekExact(seekTerms[i])) {
- throw new RuntimeException("seek to existing term " + seekTerms[i] + " failed");
- }
-
- totDocFreq += termsEnum.docFreq();
- postings = termsEnum.postings(null, postings, PostingsEnum.NONE);
+ postings = termsEnum.postings(postings, PostingsEnum.NONE);
if (postings == null) {
throw new RuntimeException("null DocsEnum from to existing term " + seekTerms[i]);
}
-
- while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
- totDocCountNoDeletes++;
- }
- }
-
- if (totDocCount > totDocCountNoDeletes) {
- throw new RuntimeException("more postings with deletes=" + totDocCount + " than without=" + totDocCountNoDeletes);
- }
-
- if (totDocCountNoDeletes != totDocFreq) {
- throw new RuntimeException("docfreqs=" + totDocFreq + " != recomputed docfreqs=" + totDocCountNoDeletes);
}
}
}
@@ -1685,7 +1636,6 @@ public class CheckIndex implements Close
Status.TermIndexStatus status;
final int maxDoc = reader.maxDoc();
- final Bits liveDocs = reader.getLiveDocs();
try {
if (infoStream != null) {
@@ -1694,13 +1644,7 @@ public class CheckIndex implements Close
final Fields fields = reader.getPostingsReader().getMergeInstance();
final FieldInfos fieldInfos = reader.getFieldInfos();
- status = checkFields(fields, liveDocs, maxDoc, fieldInfos, true, false, infoStream, verbose);
- if (liveDocs != null) {
- if (infoStream != null) {
- infoStream.print(" test (ignoring deletes): terms, freq, prox...");
- }
- checkFields(fields, null, maxDoc, fieldInfos, true, false, infoStream, verbose);
- }
+ status = checkFields(fields, reader.getLiveDocs(), maxDoc, fieldInfos, true, false, infoStream, verbose);
} catch (Throwable e) {
if (failFast) {
IOUtils.reThrow(e);
@@ -2015,7 +1959,6 @@ public class CheckIndex implements Close
long startNS = System.nanoTime();
final Status.TermVectorStatus status = new Status.TermVectorStatus();
final FieldInfos fieldInfos = reader.getFieldInfos();
- final Bits onlyDocIsDeleted = new FixedBitSet(1);
try {
if (infoStream != null) {
@@ -2026,7 +1969,6 @@ public class CheckIndex implements Close
// Only used if crossCheckTermVectors is true:
PostingsEnum postingsDocs = null;
- PostingsEnum postingsDocs2 = null;
final Bits liveDocs = reader.getLiveDocs();
@@ -2055,12 +1997,6 @@ public class CheckIndex implements Close
// First run with no deletions:
checkFields(tfv, null, 1, fieldInfos, false, true, infoStream, verbose);
- if (j == 0) {
- // Also test with the 1 doc deleted; we only do this for first doc because this really is just looking for a [slightly] buggy
- // TermVectors impl that fails to respect the incoming live docs:
- checkFields(tfv, onlyDocIsDeleted, 1, fieldInfos, false, true, infoStream, verbose);
- }
-
// Only agg stats if the doc is live:
final boolean doStats = liveDocs == null || liveDocs.get(j);
@@ -2097,7 +2033,7 @@ public class CheckIndex implements Close
while ((term = termsEnum.next()) != null) {
// This is the term vectors:
- postings = termsEnum.postings(null, postings, PostingsEnum.ALL);
+ postings = termsEnum.postings(postings, PostingsEnum.ALL);
assert postings != null;
if (!postingsTermsEnum.seekExact(term)) {
@@ -2105,11 +2041,11 @@ public class CheckIndex implements Close
}
// This is the inverted index ("real" postings):
- postingsDocs2 = postingsTermsEnum.postings(null, postingsDocs2, PostingsEnum.ALL);
- assert postingsDocs2 != null;
+ postingsDocs = postingsTermsEnum.postings(postingsDocs, PostingsEnum.ALL);
+ assert postingsDocs != null;
- final int advanceDoc = postingsDocs2.advance(j);
+ final int advanceDoc = postingsDocs.advance(j);
if (advanceDoc != j) {
throw new RuntimeException("vector term=" + term + " field=" + field + ": doc=" + j + " was not found in postings (got: " + advanceDoc + ")");
}
@@ -2122,8 +2058,8 @@ public class CheckIndex implements Close
if (postingsHasFreq) {
final int tf = postings.freq();
- if (postingsHasFreq && postingsDocs2.freq() != tf) {
- throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": freq=" + tf + " differs from postings freq=" + postingsDocs2.freq());
+ if (postingsHasFreq && postingsDocs.freq() != tf) {
+ throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": freq=" + tf + " differs from postings freq=" + postingsDocs.freq());
}
// Term vectors has prox?
@@ -2131,7 +2067,7 @@ public class CheckIndex implements Close
for (int i = 0; i < tf; i++) {
int pos = postings.nextPosition();
if (postingsTerms.hasPositions()) {
- int postingsPos = postingsDocs2.nextPosition();
+ int postingsPos = postingsDocs.nextPosition();
if (terms.hasPositions() && pos != postingsPos) {
throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": pos=" + pos + " differs from postings pos=" + postingsPos);
}
@@ -2153,8 +2089,8 @@ public class CheckIndex implements Close
*/
if (startOffset != -1 && endOffset != -1 && postingsTerms.hasOffsets()) {
- int postingsStartOffset = postingsDocs2.startOffset();
- int postingsEndOffset = postingsDocs2.endOffset();
+ int postingsStartOffset = postingsDocs.startOffset();
+ int postingsEndOffset = postingsDocs.endOffset();
if (startOffset != postingsStartOffset) {
throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": startOffset=" + startOffset + " differs from postings startOffset=" + postingsStartOffset);
}
@@ -2174,16 +2110,16 @@ public class CheckIndex implements Close
if (payload == null) {
// we have payloads, but not at this position.
// postings has payloads too, it should not have one at this position
- if (postingsDocs2.getPayload() != null) {
- throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has no payload but postings does: " + postingsDocs2.getPayload());
+ if (postingsDocs.getPayload() != null) {
+ throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has no payload but postings does: " + postingsDocs.getPayload());
}
} else {
// we have payloads, and one at this position
// postings should also have one at this position, with the same bytes.
- if (postingsDocs2.getPayload() == null) {
+ if (postingsDocs.getPayload() == null) {
throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has payload=" + payload + " but postings does not.");
}
- BytesRef postingsPayload = postingsDocs2.getPayload();
+ BytesRef postingsPayload = postingsDocs.getPayload();
if (!payload.equals(postingsPayload)) {
throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has payload=" + payload + " but differs from postings payload=" + postingsPayload);
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java Thu Jun 25 13:59:19 2015
@@ -216,8 +216,8 @@ public class FilterLeafReader extends Le
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
- return in.postings(liveDocs, reuse, flags);
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
+ return in.postings(reuse, flags);
}
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java Thu Jun 25 13:59:19 2015
@@ -21,7 +21,6 @@ import java.io.IOException;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.AttributeSource;
-import org.apache.lucene.util.Bits;
/**
* Abstract class for enumerating a subset of all terms.
@@ -179,8 +178,8 @@ public abstract class FilteredTermsEnum
}
@Override
- public PostingsEnum postings(Bits bits, PostingsEnum reuse, int flags) throws IOException {
- return tenum.postings(bits, reuse, flags);
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
+ return tenum.postings(reuse, flags);
}
/** This enum does not support seeking!
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.java Thu Jun 25 13:59:19 2015
@@ -25,7 +25,6 @@ import java.util.Map;
import org.apache.lucene.index.FreqProxTermsWriterPerField.FreqProxPostingsArray;
import org.apache.lucene.util.AttributeSource;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
@@ -226,11 +225,7 @@ class FreqProxFields extends Fields {
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) {
- if (liveDocs != null) {
- throw new IllegalArgumentException("liveDocs must be null");
- }
-
+ public PostingsEnum postings(PostingsEnum reuse, int flags) {
if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
FreqProxPostingsEnum posEnum;
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java Thu Jun 25 13:59:19 2015
@@ -56,7 +56,7 @@ final class FreqProxTermsWriter extends
}
if (termsEnum != null && termsEnum.seekExact(deleteTerm.bytes())) {
- postingsEnum = termsEnum.postings(null, postingsEnum, 0);
+ postingsEnum = termsEnum.postings(postingsEnum, 0);
int delDocLimit = segDeletes.get(deleteTerm);
assert delDocLimit < PostingsEnum.NO_MORE_DOCS;
while (true) {
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/LeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/LeafReader.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/LeafReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/LeafReader.java Thu Jun 25 13:59:19 2015
@@ -210,7 +210,8 @@ public abstract class LeafReader extends
/** Returns {@link PostingsEnum} for the specified term.
* This will return null if either the field or
* term does not exist.
- * @see TermsEnum#postings(Bits, PostingsEnum) */
+ * <p><b>NOTE:</b> The returned {@link PostingsEnum} may contain deleted docs.
+ * @see TermsEnum#postings(PostingsEnum) */
public final PostingsEnum postings(Term term, int flags) throws IOException {
assert term.field() != null;
assert term.bytes() != null;
@@ -218,7 +219,7 @@ public abstract class LeafReader extends
if (terms != null) {
final TermsEnum termsEnum = terms.iterator();
if (termsEnum.seekExact(term.bytes())) {
- return termsEnum.postings(getLiveDocs(), null, flags);
+ return termsEnum.postings(null, flags);
}
}
return null;
@@ -231,6 +232,7 @@ public abstract class LeafReader extends
* and do not need any proximity data.
* This method is equivalent to
* {@link #postings(Term, int) postings(term, PostingsEnum.FREQS)}
+ * <p><b>NOTE:</b> The returned {@link PostingsEnum} may contain deleted docs.
* @see #postings(Term, int)
*/
public final PostingsEnum postings(Term term) throws IOException {
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MappedMultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MappedMultiFields.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MappedMultiFields.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MappedMultiFields.java Thu Jun 25 13:59:19 2015
@@ -19,8 +19,6 @@ package org.apache.lucene.index;
import java.io.IOException;
-import org.apache.lucene.util.Bits;
-
import static org.apache.lucene.index.FilterLeafReader.FilterFields;
import static org.apache.lucene.index.FilterLeafReader.FilterTerms;
import static org.apache.lucene.index.FilterLeafReader.FilterTermsEnum;
@@ -107,11 +105,7 @@ public class MappedMultiFields extends F
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
- if (liveDocs != null) {
- throw new IllegalArgumentException("liveDocs must be null");
- }
-
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
MappingMultiPostingsEnum mappingDocsAndPositionsEnum;
if (reuse instanceof MappingMultiPostingsEnum) {
MappingMultiPostingsEnum postings = (MappingMultiPostingsEnum) reuse;
@@ -124,7 +118,7 @@ public class MappedMultiFields extends F
mappingDocsAndPositionsEnum = new MappingMultiPostingsEnum(field, mergeState);
}
- MultiPostingsEnum docsAndPositionsEnum = (MultiPostingsEnum) in.postings(liveDocs, mappingDocsAndPositionsEnum.multiDocsAndPositionsEnum, flags);
+ MultiPostingsEnum docsAndPositionsEnum = (MultiPostingsEnum) in.postings(mappingDocsAndPositionsEnum.multiDocsAndPositionsEnum, flags);
mappingDocsAndPositionsEnum.reset(docsAndPositionsEnum);
return mappingDocsAndPositionsEnum;
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiFields.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiFields.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiFields.java Thu Jun 25 13:59:19 2015
@@ -123,8 +123,8 @@ public final class MultiFields extends F
/** Returns {@link PostingsEnum} for the specified field and
* term. This will return null if the field or term does
* not exist. */
- public static PostingsEnum getTermDocsEnum(IndexReader r, Bits liveDocs, String field, BytesRef term) throws IOException {
- return getTermDocsEnum(r, liveDocs, field, term, PostingsEnum.FREQS);
+ public static PostingsEnum getTermDocsEnum(IndexReader r, String field, BytesRef term) throws IOException {
+ return getTermDocsEnum(r, field, term, PostingsEnum.FREQS);
}
/** Returns {@link PostingsEnum} for the specified field and
@@ -132,15 +132,15 @@ public final class MultiFields extends F
* Some codecs may be able to optimize their
* implementation when freqs are not required. This will
* return null if the field or term does not exist. See {@link
- * TermsEnum#postings(Bits, PostingsEnum,int)}.*/
- public static PostingsEnum getTermDocsEnum(IndexReader r, Bits liveDocs, String field, BytesRef term, int flags) throws IOException {
+ * TermsEnum#postings(PostingsEnum,int)}.*/
+ public static PostingsEnum getTermDocsEnum(IndexReader r, String field, BytesRef term, int flags) throws IOException {
assert field != null;
assert term != null;
final Terms terms = getTerms(r, field);
if (terms != null) {
final TermsEnum termsEnum = terms.iterator();
if (termsEnum.seekExact(term)) {
- return termsEnum.postings(liveDocs, null, flags);
+ return termsEnum.postings(null, flags);
}
}
return null;
@@ -149,9 +149,9 @@ public final class MultiFields extends F
/** Returns {@link PostingsEnum} for the specified
* field and term. This will return null if the field or
* term does not exist or positions were not indexed.
- * @see #getTermPositionsEnum(IndexReader, Bits, String, BytesRef, int) */
- public static PostingsEnum getTermPositionsEnum(IndexReader r, Bits liveDocs, String field, BytesRef term) throws IOException {
- return getTermPositionsEnum(r, liveDocs, field, term, PostingsEnum.ALL);
+ * @see #getTermPositionsEnum(IndexReader, String, BytesRef, int) */
+ public static PostingsEnum getTermPositionsEnum(IndexReader r, String field, BytesRef term) throws IOException {
+ return getTermPositionsEnum(r, field, term, PostingsEnum.ALL);
}
/** Returns {@link PostingsEnum} for the specified
@@ -159,15 +159,15 @@ public final class MultiFields extends F
* required. Some codecs may be able to optimize
* their implementation when offsets and/or payloads are not
* required. This will return null if the field or term does not
- * exist. See {@link TermsEnum#postings(Bits, PostingsEnum,int)}. */
- public static PostingsEnum getTermPositionsEnum(IndexReader r, Bits liveDocs, String field, BytesRef term, int flags) throws IOException {
+ * exist. See {@link TermsEnum#postings(PostingsEnum,int)}. */
+ public static PostingsEnum getTermPositionsEnum(IndexReader r, String field, BytesRef term, int flags) throws IOException {
assert field != null;
assert term != null;
final Terms terms = getTerms(r, field);
if (terms != null) {
final TermsEnum termsEnum = terms.iterator();
if (termsEnum.seekExact(term)) {
- return termsEnum.postings(liveDocs, null, flags);
+ return termsEnum.postings(null, flags);
}
}
return null;
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java Thu Jun 25 13:59:19 2015
@@ -20,7 +20,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Arrays;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.PriorityQueue;
@@ -327,7 +326,7 @@ public final class MultiTermsEnum extend
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
MultiPostingsEnum docsEnum;
// Can only reuse if incoming enum is also a MultiDocsEnum
@@ -340,13 +339,6 @@ public final class MultiTermsEnum extend
} else {
docsEnum = new MultiPostingsEnum(this, subs.length);
}
-
- final MultiBits multiLiveDocs;
- if (liveDocs instanceof MultiBits) {
- multiLiveDocs = (MultiBits) liveDocs;
- } else {
- multiLiveDocs = null;
- }
int upto = 0;
@@ -354,31 +346,8 @@ public final class MultiTermsEnum extend
final TermsEnumWithSlice entry = top[i];
- final Bits b;
-
- if (multiLiveDocs != null) {
- // optimize for common case: requested skip docs is a
- // congruent sub-slice of MultiBits: in this case, we
- // just pull the liveDocs from the sub reader, rather
- // than making the inefficient
- // Slice(Multi(sub-readers)):
- final MultiBits.SubResult sub = multiLiveDocs.getMatchingSub(entry.subSlice);
- if (sub.matches) {
- b = sub.result;
- } else {
- // custom case: requested skip docs is foreign:
- // must slice it on every access
- b = new BitsSlice(liveDocs, entry.subSlice);
- }
- } else if (liveDocs != null) {
- b = new BitsSlice(liveDocs, entry.subSlice);
- } else {
- // no deletions
- b = null;
- }
-
assert entry.index < docsEnum.subPostingsEnums.length: entry.index + " vs " + docsEnum.subPostingsEnums.length + "; " + subs.length;
- final PostingsEnum subPostingsEnum = entry.terms.postings(b, docsEnum.subPostingsEnums[entry.index], flags);
+ final PostingsEnum subPostingsEnum = entry.terms.postings(docsEnum.subPostingsEnums[entry.index], flags);
assert subPostingsEnum != null;
docsEnum.subPostingsEnums[entry.index] = subPostingsEnum;
subDocs[upto].postingsEnum = subPostingsEnum;
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/PostingsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/PostingsEnum.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/PostingsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/PostingsEnum.java Thu Jun 25 13:59:19 2015
@@ -21,7 +21,6 @@ import java.io.IOException;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.AttributeSource;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
/** Iterates through the postings.
@@ -30,29 +29,29 @@ import org.apache.lucene.util.BytesRef;
public abstract class PostingsEnum extends DocIdSetIterator {
/**
- * Flag to pass to {@link TermsEnum#postings(Bits, PostingsEnum, int)} if you don't
+ * Flag to pass to {@link TermsEnum#postings(PostingsEnum, int)} if you don't
* require per-document postings in the returned enum.
*/
public static final short NONE = 0;
- /** Flag to pass to {@link TermsEnum#postings(Bits, PostingsEnum, int)}
+ /** Flag to pass to {@link TermsEnum#postings(PostingsEnum, int)}
* if you require term frequencies in the returned enum. */
public static final short FREQS = 1 << 3;
- /** Flag to pass to {@link TermsEnum#postings(Bits, PostingsEnum, int)}
+ /** Flag to pass to {@link TermsEnum#postings(PostingsEnum, int)}
* if you require term positions in the returned enum. */
public static final short POSITIONS = FREQS | 1 << 4;
- /** Flag to pass to {@link TermsEnum#postings(Bits, PostingsEnum, int)}
+ /** Flag to pass to {@link TermsEnum#postings(PostingsEnum, int)}
* if you require offsets in the returned enum. */
public static final short OFFSETS = POSITIONS | 1 << 5;
- /** Flag to pass to {@link TermsEnum#postings(Bits, PostingsEnum, int)}
+ /** Flag to pass to {@link TermsEnum#postings(PostingsEnum, int)}
* if you require payloads in the returned enum. */
public static final short PAYLOADS = POSITIONS | 1 << 6;
/**
- * Flag to pass to {@link TermsEnum#postings(Bits, PostingsEnum, int)}
+ * Flag to pass to {@link TermsEnum#postings(PostingsEnum, int)}
* to get positions, payloads and offsets in the returned enum
*/
public static final short ALL = OFFSETS | PAYLOADS;
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java Thu Jun 25 13:59:19 2015
@@ -19,7 +19,6 @@ package org.apache.lucene.index;
import java.io.IOException;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
@@ -106,7 +105,7 @@ class SortedDocValuesTermsEnum extends T
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
throw new UnsupportedOperationException();
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValuesTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValuesTermsEnum.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValuesTermsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValuesTermsEnum.java Thu Jun 25 13:59:19 2015
@@ -17,7 +17,6 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
@@ -106,7 +105,7 @@ class SortedSetDocValuesTermsEnum extend
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
throw new UnsupportedOperationException();
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java Thu Jun 25 13:59:19 2015
@@ -20,7 +20,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.util.AttributeSource;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefIterator;
@@ -142,18 +141,19 @@ public abstract class TermsEnum implemen
* call this when the enum is unpositioned. This method
* will not return null.
* <p>
+ * <b>NOTE</b>: the returned iterator may return deleted documents, so
+ * deleted documents have to be checked on top of the {@link PostingsEnum}.
+ * <p>
* Use this method if you only require documents and frequencies,
* and do not need any proximity data.
* This method is equivalent to
- * {@link #postings(Bits, PostingsEnum, int) postings(liveDocs, reuse, PostingsEnum.FREQS)}
- *
- * @param liveDocs unset bits are documents that should not
- * be returned
+ * {@link #postings(PostingsEnum, int) postings(reuse, PostingsEnum.FREQS)}
+ *
* @param reuse pass a prior PostingsEnum for possible reuse
- * @see #postings(Bits, PostingsEnum, int)
+ * @see #postings(PostingsEnum, int)
*/
- public final PostingsEnum postings(Bits liveDocs, PostingsEnum reuse) throws IOException {
- return postings(liveDocs, reuse, PostingsEnum.FREQS);
+ public final PostingsEnum postings(PostingsEnum reuse) throws IOException {
+ return postings(reuse, PostingsEnum.FREQS);
}
/** Get {@link PostingsEnum} for the current term, with
@@ -161,14 +161,15 @@ public abstract class TermsEnum implemen
* are required. Do not call this when the enum is
* unpositioned. This method may return null if the postings
* information required is not available from the index
- *
- * @param liveDocs unset bits are documents that should not
- * be returned
+ * <p>
+ * <b>NOTE</b>: the returned iterator may return deleted documents, so
+ * deleted documents have to be checked on top of the {@link PostingsEnum}.
+ *
* @param reuse pass a prior PostingsEnum for possible reuse
* @param flags specifies which optional per-document values
* you require; see {@link PostingsEnum#FREQS}
*/
- public abstract PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException;
+ public abstract PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException;
/**
* Expert: Returns the TermsEnums internal state to position the TermsEnum
@@ -225,7 +226,7 @@ public abstract class TermsEnum implemen
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) {
+ public PostingsEnum postings(PostingsEnum reuse, int flags) {
throw new IllegalStateException("this method should never be called");
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java Thu Jun 25 13:59:19 2015
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
-import org.apache.lucene.search.BooleanWeight;
+import org.apache.lucene.util.Bits;
import org.apache.lucene.util.PriorityQueue;
/**
@@ -41,7 +41,7 @@ final class BooleanScorer extends BulkSc
return new BulkScorer() {
@Override
- public int score(final LeafCollector collector, int min, int max) throws IOException {
+ public int score(final LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
final LeafCollector noScoreCollector = new LeafCollector() {
FakeScorer fake = new FakeScorer();
@@ -56,7 +56,7 @@ final class BooleanScorer extends BulkSc
collector.collect(doc);
}
};
- return scorer.score(noScoreCollector, min, max);
+ return scorer.score(noScoreCollector, acceptDocs, min, max);
}
@Override
@@ -83,11 +83,11 @@ final class BooleanScorer extends BulkSc
}
void advance(int min) throws IOException {
- score(min, min);
+ score(null, min, min);
}
- void score(int min, int max) throws IOException {
- next = scorer.score(orCollector, min, max);
+ void score(Bits acceptDocs, int min, int max) throws IOException {
+ next = scorer.score(orCollector, acceptDocs, min, max);
}
}
@@ -237,12 +237,12 @@ final class BooleanScorer extends BulkSc
}
}
- private void scoreWindow(LeafCollector collector, int base, int min, int max,
+ private void scoreWindow(LeafCollector collector, Bits acceptDocs, int base, int min, int max,
BulkScorerAndDoc[] scorers, int numScorers) throws IOException {
for (int i = 0; i < numScorers; ++i) {
final BulkScorerAndDoc scorer = scorers[i];
assert scorer.next < max;
- scorer.score(min, max);
+ scorer.score(acceptDocs, min, max);
}
scoreMatches(collector, base);
@@ -270,7 +270,7 @@ final class BooleanScorer extends BulkSc
return headTop;
}
- private void scoreWindow(LeafCollector collector, int windowBase, int windowMin, int windowMax) throws IOException {
+ private void scoreWindow(LeafCollector collector, Bits acceptDocs, int windowBase, int windowMin, int windowMax) throws IOException {
// Fill 'leads' with all scorers from 'head' that are in the right window
leads[0] = head.pop();
int maxFreq = 1;
@@ -296,7 +296,7 @@ final class BooleanScorer extends BulkSc
}
tail.clear();
- scoreWindow(collector, windowBase, windowMin, windowMax, leads, maxFreq);
+ scoreWindow(collector, acceptDocs, windowBase, windowMin, windowMax, leads, maxFreq);
}
// Push back scorers into head and tail
@@ -309,7 +309,7 @@ final class BooleanScorer extends BulkSc
}
@Override
- public int score(LeafCollector collector, int min, int max) throws IOException {
+ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
fakeScorer.doc = -1;
collector.setScorer(fakeScorer);
@@ -321,7 +321,7 @@ final class BooleanScorer extends BulkSc
final int windowMax = Math.min(max, windowBase + SIZE);
// general case
- scoreWindow(collector, windowBase, windowMin, windowMax);
+ scoreWindow(collector, acceptDocs, windowBase, windowMin, windowMax);
top = head.top();
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java Thu Jun 25 13:59:19 2015
@@ -28,7 +28,6 @@ import org.apache.lucene.index.LeafReade
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.Bits;
/**
* Expert: the Weight for BooleanQuery, used to
@@ -194,12 +193,12 @@ final class BooleanWeight extends Weight
/** Try to build a boolean scorer for this weight. Returns null if {@link BooleanScorer}
* cannot be used. */
// pkg-private for forcing use of BooleanScorer in tests
- BooleanScorer booleanScorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ BooleanScorer booleanScorer(LeafReaderContext context) throws IOException {
List<BulkScorer> optional = new ArrayList<BulkScorer>();
Iterator<BooleanClause> cIter = query.iterator();
for (Weight w : weights) {
BooleanClause c = cIter.next();
- BulkScorer subScorer = w.bulkScorer(context, acceptDocs);
+ BulkScorer subScorer = w.bulkScorer(context);
if (subScorer == null) {
if (c.isRequired()) {
@@ -230,8 +229,8 @@ final class BooleanWeight extends Weight
}
@Override
- public BulkScorer bulkScorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final BooleanScorer bulkScorer = booleanScorer(context, acceptDocs);
+ public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
+ final BooleanScorer bulkScorer = booleanScorer(context);
if (bulkScorer != null) { // BooleanScorer is applicable
// TODO: what is the right heuristic here?
final long costThreshold;
@@ -254,11 +253,11 @@ final class BooleanWeight extends Weight
return bulkScorer;
}
}
- return super.bulkScorer(context, acceptDocs);
+ return super.bulkScorer(context);
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
// initially the user provided value,
// but if minNrShouldMatch == optional.size(),
// we will optimize and move these to required, making this 0
@@ -272,7 +271,7 @@ final class BooleanWeight extends Weight
Iterator<BooleanClause> cIter = query.iterator();
for (Weight w : weights) {
BooleanClause c = cIter.next();
- Scorer subScorer = w.scorer(context, acceptDocs);
+ Scorer subScorer = w.scorer(context);
if (subScorer == null) {
if (c.isRequired()) {
return null;
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BulkScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BulkScorer.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BulkScorer.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/BulkScorer.java Thu Jun 25 13:59:19 2015
@@ -19,6 +19,8 @@ package org.apache.lucene.search;
import java.io.IOException;
+import org.apache.lucene.util.Bits;
+
/** This class is used to score a range of documents at
* once, and is returned by {@link Weight#bulkScorer}. Only
* queries that have a more optimized means of scoring
@@ -30,9 +32,11 @@ public abstract class BulkScorer {
/** Scores and collects all matching documents.
* @param collector The collector to which all matching documents are passed.
+ * @param acceptDocs {@link Bits} that represents the allowed documents to match, or
+ * {@code null} if they are all allowed to match.
*/
- public void score(LeafCollector collector) throws IOException {
- final int next = score(collector, 0, DocIdSetIterator.NO_MORE_DOCS);
+ public void score(LeafCollector collector, Bits acceptDocs) throws IOException {
+ final int next = score(collector, acceptDocs, 0, DocIdSetIterator.NO_MORE_DOCS);
assert next == DocIdSetIterator.NO_MORE_DOCS;
}
@@ -54,14 +58,16 @@ public abstract class BulkScorer {
* <pre class="prettyprint">
* private final Scorer scorer; // set via constructor
*
- * public int score(LeafCollector collector, int min, int max) throws IOException {
+ * public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
* collector.setScorer(scorer);
* int doc = scorer.docID();
* if (doc < min) {
* doc = scorer.advance(min);
* }
* while (doc < max) {
- * collector.collect(doc);
+ * if (acceptDocs == null || acceptDocs.get(doc)) {
+ * collector.collect(doc);
+ * }
* doc = scorer.nextDoc();
* }
* return doc;
@@ -69,11 +75,13 @@ public abstract class BulkScorer {
* </pre>
*
* @param collector The collector to which all matching documents are passed.
+ * @param acceptDocs {@link Bits} that represents the allowed documents to match, or
+ * {@code null} if they are all allowed to match.
* @param min Score starting at, including, this document
* @param max Score up to, but not including, this doc
* @return an under-estimation of the next matching doc after max
*/
- public abstract int score(LeafCollector collector, int min, int max) throws IOException;
+ public abstract int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException;
/**
* Same as {@link Scorer#cost()} for bulk scorers.
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/CachingWrapperQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/CachingWrapperQuery.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/CachingWrapperQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/CachingWrapperQuery.java Thu Jun 25 13:59:19 2015
@@ -33,7 +33,6 @@ import org.apache.lucene.index.LeafReade
import org.apache.lucene.index.Term;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.Accountables;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.RoaringDocIdSet;
/**
@@ -124,7 +123,7 @@ public class CachingWrapperQuery extends
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
final LeafReader reader = context.reader();
final Object key = reader.getCoreCacheKey();
@@ -133,7 +132,7 @@ public class CachingWrapperQuery extends
hitCount++;
} else if (policy.shouldCache(query, context)) {
missCount++;
- final Scorer scorer = weight.scorer(context, null);
+ final Scorer scorer = weight.scorer(context);
if (scorer == null) {
docIdSet = DocIdSet.EMPTY;
} else {
@@ -141,7 +140,7 @@ public class CachingWrapperQuery extends
}
cache.put(key, docIdSet);
} else {
- return weight.scorer(context, acceptDocs);
+ return weight.scorer(context);
}
assert docIdSet != null;
@@ -153,21 +152,7 @@ public class CachingWrapperQuery extends
return null;
}
- // We apply acceptDocs as an approximation
- if (acceptDocs == null) {
- return new ConstantScoreScorer(this, 0f, disi);
- } else {
- final TwoPhaseIterator twoPhaseView = new TwoPhaseIterator(disi) {
-
- @Override
- public boolean matches() throws IOException {
- final int doc = approximation.docID();
- return acceptDocs.get(doc);
- }
-
- };
- return new ConstantScoreScorer(this, 0f, twoPhaseView);
- }
+ return new ConstantScoreScorer(this, 0f, disi);
}
};
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java Thu Jun 25 13:59:19 2015
@@ -83,8 +83,8 @@ public class ConstantScoreQuery extends
}
@Override
- public int score(LeafCollector collector, int min, int max) throws IOException {
- return bulkScorer.score(wrapCollector(collector), min, max);
+ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
+ return bulkScorer.score(wrapCollector(collector), acceptDocs, min, max);
}
private LeafCollector wrapCollector(LeafCollector collector) {
@@ -119,8 +119,8 @@ public class ConstantScoreQuery extends
return new ConstantScoreWeight(this) {
@Override
- public BulkScorer bulkScorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final BulkScorer innerScorer = innerWeight.bulkScorer(context, acceptDocs);
+ public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
+ final BulkScorer innerScorer = innerWeight.bulkScorer(context);
if (innerScorer == null) {
return null;
}
@@ -128,8 +128,8 @@ public class ConstantScoreQuery extends
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final Scorer innerScorer = innerWeight.scorer(context, acceptDocs);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ final Scorer innerScorer = innerWeight.scorer(context);
if (innerScorer == null) {
return null;
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreWeight.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreWeight.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreWeight.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/ConstantScoreWeight.java Thu Jun 25 13:59:19 2015
@@ -66,7 +66,7 @@ public abstract class ConstantScoreWeigh
@Override
public final Explanation explain(LeafReaderContext context, int doc) throws IOException {
- final Scorer s = scorer(context, context.reader().getLiveDocs());
+ final Scorer s = scorer(context);
final boolean exists;
if (s == null) {
exists = false;
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java Thu Jun 25 13:59:19 2015
@@ -27,7 +27,6 @@ import java.util.Set;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
-import org.apache.lucene.util.Bits;
/**
* A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum
@@ -161,11 +160,11 @@ public class DisjunctionMaxQuery extends
/** Create the scorer used to score our associated DisjunctionMaxQuery */
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
List<Scorer> scorers = new ArrayList<>();
for (Weight w : weights) {
// we will advance() subscorers
- Scorer subScorer = w.scorer(context, acceptDocs);
+ Scorer subScorer = w.scorer(context);
if (subScorer != null) {
scorers.add(subScorer);
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Filter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Filter.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Filter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Filter.java Thu Jun 25 13:59:19 2015
@@ -96,7 +96,7 @@ public abstract class Filter extends Que
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- final Scorer scorer = scorer(context, context.reader().getLiveDocs());
+ final Scorer scorer = scorer(context);
final boolean match = (scorer != null && scorer.advance(doc) == doc);
if (match) {
assert scorer.score() == 0f;
@@ -107,8 +107,8 @@ public abstract class Filter extends Que
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final DocIdSet set = getDocIdSet(context, acceptDocs);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ final DocIdSet set = getDocIdSet(context, null);
if (set == null) {
return null;
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java Thu Jun 25 13:59:19 2015
@@ -31,7 +31,6 @@ import org.apache.lucene.index.TermsEnum
import org.apache.lucene.util.Attribute;
import org.apache.lucene.util.AttributeImpl;
import org.apache.lucene.util.AttributeSource;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.UnicodeUtil;
@@ -265,8 +264,8 @@ public class FuzzyTermsEnum extends Term
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
- return actualEnum.postings(liveDocs, reuse, flags);
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
+ return actualEnum.postings(reuse, flags);
}
@Override
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java Thu Jun 25 13:59:19 2015
@@ -46,6 +46,7 @@ import org.apache.lucene.index.Terms;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.store.NIOFSDirectory; // javadoc
+import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ThreadInterruptedException;
@@ -614,10 +615,10 @@ public class IndexSearcher {
// continue with the following leaf
continue;
}
- BulkScorer scorer = weight.bulkScorer(ctx, ctx.reader().getLiveDocs());
+ BulkScorer scorer = weight.bulkScorer(ctx);
if (scorer != null) {
try {
- scorer.score(leafCollector);
+ scorer.score(leafCollector, ctx.reader().getLiveDocs());
} catch (CollectionTerminatedException e) {
// collection was terminated prematurely
// continue with the following leaf
@@ -667,7 +668,10 @@ public class IndexSearcher {
int n = ReaderUtil.subIndex(doc, leafContexts);
final LeafReaderContext ctx = leafContexts.get(n);
int deBasedDoc = doc - ctx.docBase;
-
+ final Bits liveDocs = ctx.reader().getLiveDocs();
+ if (liveDocs != null && liveDocs.get(deBasedDoc) == false) {
+ return Explanation.noMatch("Document " + doc + " is deleted");
+ }
return weight.explain(ctx, deBasedDoc);
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java Thu Jun 25 13:59:19 2015
@@ -36,7 +36,6 @@ import org.apache.lucene.index.ReaderUti
import org.apache.lucene.index.Term;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.Accountables;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.RoaringDocIdSet;
@@ -566,7 +565,7 @@ public class LRUQueryCache implements Qu
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
if (context.ord == 0) {
policy.onUse(getQuery());
}
@@ -574,7 +573,7 @@ public class LRUQueryCache implements Qu
if (docIdSet == null) {
if (cacheEntryHasReasonableWorstCaseSize(ReaderUtil.getTopLevelContext(context).reader().maxDoc())
&& policy.shouldCache(in.getQuery(), context)) {
- final Scorer scorer = in.scorer(context, null);
+ final Scorer scorer = in.scorer(context);
if (scorer == null) {
docIdSet = DocIdSet.EMPTY;
} else {
@@ -582,7 +581,7 @@ public class LRUQueryCache implements Qu
}
putIfAbsent(in.getQuery(), context, docIdSet);
} else {
- return in.scorer(context, acceptDocs);
+ return in.scorer(context);
}
}
@@ -595,19 +594,7 @@ public class LRUQueryCache implements Qu
return null;
}
- // we apply acceptDocs as an approximation
- if (acceptDocs == null) {
- return new ConstantScoreScorer(this, 0f, disi);
- } else {
- final TwoPhaseIterator twoPhaseView = new TwoPhaseIterator(disi) {
- @Override
- public boolean matches() throws IOException {
- final int doc = approximation.docID();
- return acceptDocs.get(doc);
- }
- };
- return new ConstantScoreScorer(this, 0f, twoPhaseView);
- }
+ return new ConstantScoreScorer(this, 0f, disi);
}
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java Thu Jun 25 13:59:19 2015
@@ -33,7 +33,6 @@ import org.apache.lucene.index.TermsEnum
import org.apache.lucene.search.similarities.Similarity.SimScorer;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.PriorityQueue;
import org.apache.lucene.util.ToStringUtils;
@@ -173,10 +172,9 @@ public class MultiPhraseQuery extends Qu
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
assert !termArrays.isEmpty();
final LeafReader reader = context.reader();
- final Bits liveDocs = acceptDocs;
PhraseQuery.PostingsAndFreq[] postingsFreqs = new PhraseQuery.PostingsAndFreq[termArrays.size()];
@@ -201,7 +199,7 @@ public class MultiPhraseQuery extends Qu
TermState termState = termContexts.get(term).get(context.ord);
if (termState != null) {
termsEnum.seekExact(term.bytes(), termState);
- postings.add(termsEnum.postings(liveDocs, null, PostingsEnum.POSITIONS));
+ postings.add(termsEnum.postings(null, PostingsEnum.POSITIONS));
}
}
@@ -233,7 +231,7 @@ public class MultiPhraseQuery extends Qu
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- Scorer scorer = scorer(context, context.reader().getLiveDocs());
+ Scorer scorer = scorer(context);
if (scorer != null) {
int newDoc = scorer.advance(doc);
if (newDoc == doc) {
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreWrapper.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreWrapper.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreWrapper.java Thu Jun 25 13:59:19 2015
@@ -31,7 +31,6 @@ import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.util.BitDocIdSet;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
/**
@@ -136,7 +135,7 @@ final class MultiTermQueryConstantScoreW
* On the given leaf context, try to either rewrite to a disjunction if
* there are few terms, or build a bitset containing matching docs.
*/
- private WeightOrBitSet rewrite(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ private WeightOrBitSet rewrite(LeafReaderContext context) throws IOException {
final Terms terms = context.reader().terms(query.field);
if (terms == null) {
// field does not exist
@@ -168,14 +167,14 @@ final class MultiTermQueryConstantScoreW
TermsEnum termsEnum2 = terms.iterator();
for (TermAndState t : collectedTerms) {
termsEnum2.seekExact(t.term, t.state);
- docs = termsEnum2.postings(acceptDocs, docs, PostingsEnum.NONE);
+ docs = termsEnum2.postings(docs, PostingsEnum.NONE);
builder.or(docs);
}
}
// Then keep filling the bit set with remaining terms
do {
- docs = termsEnum.postings(acceptDocs, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
builder.or(docs);
} while (termsEnum.next() != null);
@@ -194,10 +193,10 @@ final class MultiTermQueryConstantScoreW
}
@Override
- public BulkScorer bulkScorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final WeightOrBitSet weightOrBitSet = rewrite(context, acceptDocs);
+ public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
+ final WeightOrBitSet weightOrBitSet = rewrite(context);
if (weightOrBitSet.weight != null) {
- return weightOrBitSet.weight.bulkScorer(context, acceptDocs);
+ return weightOrBitSet.weight.bulkScorer(context);
} else {
final Scorer scorer = scorer(weightOrBitSet.bitset);
if (scorer == null) {
@@ -208,10 +207,10 @@ final class MultiTermQueryConstantScoreW
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final WeightOrBitSet weightOrBitSet = rewrite(context, acceptDocs);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ final WeightOrBitSet weightOrBitSet = rewrite(context);
if (weightOrBitSet.weight != null) {
- return weightOrBitSet.weight.scorer(context, acceptDocs);
+ return weightOrBitSet.weight.scorer(context);
} else {
return scorer(weightOrBitSet.bitset);
}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java Thu Jun 25 13:59:19 2015
@@ -37,7 +37,6 @@ import org.apache.lucene.index.TermsEnum
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.search.similarities.Similarity.SimScorer;
import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ToStringUtils;
@@ -396,10 +395,9 @@ public class PhraseQuery extends Query {
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
assert terms.length > 0;
final LeafReader reader = context.reader();
- final Bits liveDocs = acceptDocs;
PostingsAndFreq[] postingsFreqs = new PostingsAndFreq[terms.length];
final Terms fieldTerms = reader.terms(field);
@@ -422,7 +420,7 @@ public class PhraseQuery extends Query {
return null;
}
te.seekExact(t.bytes(), state);
- PostingsEnum postingsEnum = te.postings(liveDocs, null, PostingsEnum.POSITIONS);
+ PostingsEnum postingsEnum = te.postings(null, PostingsEnum.POSITIONS);
postingsFreqs[i] = new PostingsAndFreq(postingsEnum, positions[i], t);
}
@@ -445,7 +443,7 @@ public class PhraseQuery extends Query {
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- Scorer scorer = scorer(context, context.reader().getLiveDocs());
+ Scorer scorer = scorer(context);
if (scorer != null) {
int newDoc = scorer.advance(doc);
if (newDoc == doc) {
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryRescorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryRescorer.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryRescorer.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryRescorer.java Thu Jun 25 13:59:19 2015
@@ -82,7 +82,7 @@ public abstract class QueryRescorer exte
if (readerContext != null) {
// We advanced to another segment:
docBase = readerContext.docBase;
- scorer = weight.scorer(readerContext, null);
+ scorer = weight.scorer(readerContext);
}
if(scorer != null) {
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java Thu Jun 25 13:59:19 2015
@@ -61,10 +61,11 @@ public class QueryWrapperFilter extends
// get a private context that is used to rewrite, createWeight and score eventually
final LeafReaderContext privateContext = context.reader().getContext();
final Weight weight = new IndexSearcher(privateContext).createNormalizedWeight(query, false);
- return new DocIdSet() {
+
+ DocIdSet set = new DocIdSet() {
@Override
public DocIdSetIterator iterator() throws IOException {
- return weight.scorer(privateContext, acceptDocs);
+ return weight.scorer(privateContext);
}
@Override
@@ -72,6 +73,7 @@ public class QueryWrapperFilter extends
return 0L;
}
};
+ return BitsFilteredDocIdSet.wrap(set, acceptDocs);
}
@Override
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/RandomAccessWeight.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/RandomAccessWeight.java?rev=1687524&r1=1687523&r2=1687524&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/RandomAccessWeight.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/RandomAccessWeight.java Thu Jun 25 13:59:19 2015
@@ -48,7 +48,7 @@ public abstract class RandomAccessWeight
protected abstract Bits getMatchingDocs(LeafReaderContext context) throws IOException;
@Override
- public final Scorer scorer(LeafReaderContext context, final Bits acceptDocs) throws IOException {
+ public final Scorer scorer(LeafReaderContext context) throws IOException {
final Bits matchingDocs = getMatchingDocs(context);
if (matchingDocs == null || matchingDocs instanceof MatchNoBits) {
return null;
@@ -60,10 +60,6 @@ public abstract class RandomAccessWeight
public boolean matches() throws IOException {
final int doc = approximation.docID();
- if (acceptDocs != null && acceptDocs.get(doc) == false) {
- return false;
- }
-
return matchingDocs.get(doc);
}
};