From 1a46179c4e7bbfdd1350bda6a685168ef40c6681 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 31 Oct 2012 13:58:07 +0100 Subject: [PATCH] lucene 4: Upgraded AndFilter, FilteredCollector, LimitFilter, MatchAllDocsFilter and MatchNoDocsFilter. --- .../org/elasticsearch/common/lucene/search/AndFilter.java | 8 +++++--- .../common/lucene/search/FilteredCollector.java | 2 +- .../elasticsearch/common/lucene/search/LimitFilter.java | 6 ++++-- .../common/lucene/search/MatchAllDocsFilter.java | 6 ++++-- .../common/lucene/search/MatchNoDocsFilter.java | 4 +++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java index 704643baea3..8c8abfa3dde 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java @@ -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; } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java b/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java index 38ce581c5a7..e5d8d12f7d6 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java index ece97578047..f0fc3bb02a7 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java index fd382a83380..0f597e280eb 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsFilter.java index 8c80431c973..b380752bc16 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsFilter.java @@ -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; }