lucene 4: Upgraded IndexedGeoBoundingBoxFilter & InMemoryGeoBoundingBoxFilter.

This commit is contained in:
Martijn van Groningen 2012-11-01 13:11:37 +01:00 committed by Shay Banon
parent d42d153c48
commit 673712c0b2
2 changed files with 15 additions and 13 deletions

View File

@ -19,9 +19,10 @@
package org.elasticsearch.index.search.geo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.Filter;
import org.apache.lucene.util.Bits;
import org.elasticsearch.common.lucene.docset.GetDocSet;
import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.mapper.geo.GeoPointFieldData;
@ -62,14 +63,14 @@ public class InMemoryGeoBoundingBoxFilter extends Filter {
}
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptedDocs) throws IOException {
final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, context.reader(), fieldName);
//checks to see if bounding box crosses 180 degrees
if (topLeft.lon > bottomRight.lon) {
return new Meridian180GeoBoundingBoxDocSet(reader.maxDoc(), fieldData, topLeft, bottomRight);
return new Meridian180GeoBoundingBoxDocSet(context.reader().maxDoc(), fieldData, topLeft, bottomRight);
} else {
return new GeoBoundingBoxDocSet(reader.maxDoc(), fieldData, topLeft, bottomRight);
return new GeoBoundingBoxDocSet(context.reader().maxDoc(), fieldData, topLeft, bottomRight);
}
}

View File

@ -19,9 +19,10 @@
package org.elasticsearch.index.search.geo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.Filter;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.common.lucene.docset.DocSets;
@ -58,16 +59,16 @@ public class IndexedGeoBoundingBoxFilter {
}
@Override
public FixedBitSet getDocIdSet(IndexReader reader) throws IOException {
public FixedBitSet getDocIdSet(AtomicReaderContext context, Bits acceptedDocs) throws IOException {
FixedBitSet main;
DocIdSet set = lonFilter1.getDocIdSet(reader);
DocIdSet set = lonFilter1.getDocIdSet(context, acceptedDocs);
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
main = null;
} else {
main = (FixedBitSet) set;
}
set = lonFilter2.getDocIdSet(reader);
set = lonFilter2.getDocIdSet(context, acceptedDocs);
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
if (main == null) {
return null;
@ -82,7 +83,7 @@ public class IndexedGeoBoundingBoxFilter {
}
}
set = latFilter.getDocIdSet(reader);
set = latFilter.getDocIdSet(context, acceptedDocs);
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
return null;
}
@ -124,14 +125,14 @@ public class IndexedGeoBoundingBoxFilter {
}
@Override
public FixedBitSet getDocIdSet(IndexReader reader) throws IOException {
public FixedBitSet getDocIdSet(AtomicReaderContext context, Bits acceptedDocs) throws IOException {
FixedBitSet main;
DocIdSet set = lonFilter.getDocIdSet(reader);
DocIdSet set = lonFilter.getDocIdSet(context, acceptedDocs);
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
return null;
}
main = (FixedBitSet) set;
set = latFilter.getDocIdSet(reader);
set = latFilter.getDocIdSet(context, acceptedDocs);
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
return null;
}