lucene 4: Upgraded AndFilter, FilteredCollector, LimitFilter, MatchAllDocsFilter and MatchNoDocsFilter.
This commit is contained in:
parent
e75c732bdd
commit
1a46179c4e
|
@ -20,9 +20,11 @@
|
|||
package org.elasticsearch.common.lucene.search;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.elasticsearch.common.lucene.docset.AndDocIdSet;
|
||||
import org.elasticsearch.common.lucene.docset.AndDocSet;
|
||||
import org.elasticsearch.common.lucene.docset.DocSet;
|
||||
|
@ -46,14 +48,14 @@ public class AndFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
||||
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
|
||||
if (filters.size() == 1) {
|
||||
return filters.get(0).getDocIdSet(reader);
|
||||
return filters.get(0).getDocIdSet(context, acceptDocs);
|
||||
}
|
||||
List sets = Lists.newArrayListWithExpectedSize(filters.size());
|
||||
boolean allAreDocSet = true;
|
||||
for (Filter filter : filters) {
|
||||
DocIdSet set = filter.getDocIdSet(reader);
|
||||
DocIdSet set = filter.getDocIdSet(context, acceptDocs);
|
||||
if (set == null) { // none matching for this filter, we AND, so return EMPTY
|
||||
return DocSet.EMPTY_DOC_SET;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class FilteredCollector extends Collector {
|
|||
@Override
|
||||
public void setNextReader(AtomicReaderContext context) throws IOException {
|
||||
collector.setNextReader(context);
|
||||
docSet = DocSets.convert(context.reader(), filter.getDocIdSet(context));
|
||||
docSet = DocSets.convert(context.reader(), filter.getDocIdSet(context, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
|
||||
package org.elasticsearch.common.lucene.search;
|
||||
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.elasticsearch.common.lucene.docset.GetDocSet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -39,11 +41,11 @@ public class LimitFilter extends NoCacheFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
||||
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
|
||||
if (counter > limit) {
|
||||
return null;
|
||||
}
|
||||
return new LimitDocSet(reader.maxDoc(), limit);
|
||||
return new LimitDocSet(context.reader().maxDoc(), limit);
|
||||
}
|
||||
|
||||
public class LimitDocSet extends GetDocSet {
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
|
||||
package org.elasticsearch.common.lucene.search;
|
||||
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.elasticsearch.common.lucene.docset.AllDocSet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -34,8 +36,8 @@ import java.io.IOException;
|
|||
public class MatchAllDocsFilter extends Filter {
|
||||
|
||||
@Override
|
||||
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
||||
return new AllDocSet(reader.maxDoc());
|
||||
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
|
||||
return new AllDocSet(context.reader().maxDoc());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
|
||||
package org.elasticsearch.common.lucene.search;
|
||||
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.util.Bits;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -31,7 +33,7 @@ import java.io.IOException;
|
|||
public class MatchNoDocsFilter extends Filter {
|
||||
|
||||
@Override
|
||||
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
||||
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue