Fixed doc id's to bitset id for sorting with a multi segmented index FieldSourceComparator still uses bitset id's

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@783517 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick O'Leary 2009-06-10 20:59:26 +00:00
parent eb6fbfa3d5
commit 5509306e40
3 changed files with 50 additions and 30 deletions

View File

@ -51,7 +51,7 @@ public class CartesianShapeFilter extends Filter {
TermDocs termDocs = reader.termDocs();
List<Double> area = shape.getArea();
int sz = area.size();
log.info("Area size "+ sz);
log.fine("Area size "+ sz);
// iterate through each boxid
for (int i =0; i< sz; i++) {
@ -68,7 +68,7 @@ public class CartesianShapeFilter extends Filter {
}
long end = System.currentTimeMillis();
log.info("BoundaryBox Time Taken: "+ (end - start) + " found: "+bits.cardinality()+" candidates");
log.fine("BoundaryBox Time Taken: "+ (end - start) + " found: "+bits.cardinality()+" candidates");
return bits;
}

View File

@ -48,8 +48,8 @@ public class DistanceFieldComparatorSource extends FieldComparatorSource {
}
@Override
public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed)
throws IOException {
public FieldComparator newComparator(String fieldname, int numHits,
int sortPos, boolean reversed) throws IOException {
dsdlc = new DistanceScoreDocLookupComparator(distanceFilter, numHits);
return dsdlc;
}
@ -59,8 +59,10 @@ public class DistanceFieldComparatorSource extends FieldComparatorSource {
private DistanceFilter distanceFilter;
private double[] values;
private double bottom;
private int offset =0;
public DistanceScoreDocLookupComparator(DistanceFilter distanceFilter, int numHits) {
public DistanceScoreDocLookupComparator(DistanceFilter distanceFilter,
int numHits) {
this.distanceFilter = distanceFilter;
values = new double[numHits];
return;
@ -78,15 +80,14 @@ public class DistanceFieldComparatorSource extends FieldComparatorSource {
return 0;
}
public void cleanUp() {
distanceFilter = null;
}
@Override
public int compareBottom(int doc) {
final double v2 = distanceFilter.getDistance(doc);
double v2 = distanceFilter.getDistance(doc+ offset);
if (bottom > v2) {
return 1;
} else if (bottom < v2) {
@ -97,7 +98,7 @@ public class DistanceFieldComparatorSource extends FieldComparatorSource {
@Override
public void copy(int slot, int doc) {
values[slot] = distanceFilter.getDistance(doc);
values[slot] = distanceFilter.getDistance(doc + offset);
}
@Override
@ -107,10 +108,12 @@ public class DistanceFieldComparatorSource extends FieldComparatorSource {
}
@Override
public void setNextReader(IndexReader reader, int docBase, int numSlotsFull)
throws IOException {
// TODO Auto-generated method stub
public void setNextReader(IndexReader reader, int docBase,
int numSlotsFull) throws IOException {
// each reader in a segmented base
// has an offset based on the maxDocs of previous readers
offset = docBase;
}
@Override

View File

@ -45,7 +45,7 @@ public class LatLongDistanceFilter extends DistanceFilter {
String latField;
String lngField;
Logger log = Logger.getLogger(getClass().getName());
int offset =0;
int nextOffset = 0;
Map<Integer,Double> distances = null;
@ -89,12 +89,18 @@ public class LatLongDistanceFilter extends DistanceFilter {
// distances for the same point
// TODO: Why is this a WeakHashMap?
WeakHashMap<String,Double> cdistance = new WeakHashMap<String,Double>(maxdocs);
long start = System.currentTimeMillis();
String[] latIndex = FieldCache.DEFAULT.getStrings(reader, latField);
String[] lngIndex = FieldCache.DEFAULT.getStrings(reader, lngField);
/* store calculated distances for reuse by other components */
distances = new HashMap<Integer,Double>(maxdocs);
if (distances == null){
distances = new HashMap<Integer,Double>();
}
for (int i = 0 ; i < maxdocs; i++) {
String sx = latIndex[i];
@ -121,11 +127,22 @@ public class LatLongDistanceFilter extends DistanceFilter {
}
distances.put(i, d);
// why was i storing all distances again?
if (d < distance){
bits.set(i);
distances.put(i+ nextOffset, d); // include nextOffset for multi segment reader
}
i = bits.nextSetBit(i+1);
}
int size = bits.cardinality();
nextOffset += reader.maxDoc(); // this should be something that's part of indexReader
long end = System.currentTimeMillis();
log.fine("Bits 1: Time taken : "+ (end - start) +
", results : "+ distances.size() +
", cached : "+ cdistance.size() +
", incoming size: "+ size+
", nextOffset: "+ nextOffset);
return bits;
}
@ -146,13 +163,9 @@ public class LatLongDistanceFilter extends DistanceFilter {
HashMap<String,Double> cdistance = new HashMap<String,Double>(size);
/* store calculated distances for reuse by other components */
boolean db = false;
offset += reader.maxDoc();
if (distances == null){
distances = new HashMap<Integer,Double>();
}else {
db=true;
}
long start = System.currentTimeMillis();
@ -193,20 +206,24 @@ public class LatLongDistanceFilter extends DistanceFilter {
// why was i storing all distances again?
if (d < distance){
result.set(i);
distances.put(i+ nextOffset, d); // include nextOffset for multireader
int did = i + nextOffset;
distances.put(did, d); // include nextOffset for multi segment reader
}
i = bits.nextSetBit(i+1);
}
long end = System.currentTimeMillis();
nextOffset += reader.maxDoc(); // this should be something that's part of indexReader
log.fine("Time taken : "+ (end - start) +
", results : "+ distances.size() +
", cached : "+ cdistance.size() +
", incoming size: "+ size);
", incoming size: "+ size+
", nextOffset: "+ nextOffset);
cdistance = null;
nextOffset += offset; // this should be something that's part of indexReader
return result;
}