mirror of https://github.com/apache/lucene.git
LUCENE-6688: Use the Query API instead of QueryWrapperFilter to handle deleted documents.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1692830 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f33b81fe1e
commit
5d16b97396
|
@ -27,10 +27,10 @@ import java.util.Locale;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.apache.lucene.search.DocIdSet;
|
|
||||||
import org.apache.lucene.search.DocIdSetIterator;
|
import org.apache.lucene.search.DocIdSetIterator;
|
||||||
|
import org.apache.lucene.search.IndexSearcher;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.apache.lucene.search.QueryWrapperFilter;
|
import org.apache.lucene.search.Weight;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.util.Accountable;
|
import org.apache.lucene.util.Accountable;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
|
@ -687,15 +687,20 @@ class BufferedUpdatesStream implements Accountable {
|
||||||
for (QueryAndLimit ent : queriesIter) {
|
for (QueryAndLimit ent : queriesIter) {
|
||||||
Query query = ent.query;
|
Query query = ent.query;
|
||||||
int limit = ent.limit;
|
int limit = ent.limit;
|
||||||
final DocIdSet docs = new QueryWrapperFilter(query).getDocIdSet(readerContext, segState.reader.getLiveDocs());
|
final IndexSearcher searcher = new IndexSearcher(readerContext.reader());
|
||||||
if (docs != null) {
|
searcher.setQueryCache(null);
|
||||||
final DocIdSetIterator it = docs.iterator();
|
final Weight weight = searcher.createNormalizedWeight(query, false);
|
||||||
|
final DocIdSetIterator it = weight.scorer(readerContext);
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
|
final Bits liveDocs = readerContext.reader().getLiveDocs();
|
||||||
while (true) {
|
while (true) {
|
||||||
int doc = it.nextDoc();
|
int doc = it.nextDoc();
|
||||||
if (doc >= limit) {
|
if (doc >= limit) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (liveDocs != null && liveDocs.get(doc) == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!segState.any) {
|
if (!segState.any) {
|
||||||
segState.rld.initWritableLiveDocs();
|
segState.rld.initWritableLiveDocs();
|
||||||
|
@ -707,7 +712,6 @@ class BufferedUpdatesStream implements Accountable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return delCount;
|
return delCount;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue