mirror of https://github.com/apache/lucene.git
LUCENE-8914: Move compare logic to IntersectVisitor in FloatPointNearestNeighbor (#783)
Move the logic for discarding inner modes to the IntersectVisitor so we take advantage of the change introduced in LUCENE-7862
This commit is contained in:
parent
41ae03a9a0
commit
f026053d4d
|
@ -54,6 +54,9 @@ Improvements
|
|||
|
||||
* LUCENE-8894: Add APIs to find SPI names for Tokenizer/CharFilter/TokenFilter factory classes. (Tomoko Uchida)
|
||||
|
||||
* LUCENE-8914: move the logic for discarding inner modes to the IntersectVisitor so we take advantage
|
||||
of the change introduced in LUCENE-7862. (Ignacio Vera)
|
||||
|
||||
Other
|
||||
|
||||
* LUCENE-8778 LUCENE-8911: Define analyzer SPI names as static final fields and document the names in Javadocs.
|
||||
|
|
|
@ -190,6 +190,18 @@ public class FloatPointNearestNeighbor {
|
|||
|
||||
@Override
|
||||
public PointValues.Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
|
||||
for (int d = 0, offset = 0; d < dims; ++d, offset += Float.BYTES) {
|
||||
float cellMaxAtDim = FloatPoint.decodeDimension(maxPackedValue, offset);
|
||||
if (cellMaxAtDim < min[d]) {
|
||||
// System.out.println(" skipped because cell max at " + d + " (" + cellMaxAtDim + ") < visitor.min[" + d + "] (" + min[d] + ")");
|
||||
return PointValues.Relation.CELL_OUTSIDE_QUERY;
|
||||
}
|
||||
float cellMinAtDim = FloatPoint.decodeDimension(minPackedValue, offset);
|
||||
if (cellMinAtDim > max[d]) {
|
||||
// System.out.println(" skipped because cell min at " + d + " (" + cellMinAtDim + ") > visitor.max[" + d + "] (" + max[d] + ")");
|
||||
return PointValues.Relation.CELL_OUTSIDE_QUERY;
|
||||
}
|
||||
}
|
||||
return PointValues.Relation.CELL_CROSSES_QUERY;
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +255,7 @@ public class FloatPointNearestNeighbor {
|
|||
approxBestDistanceSquared(minPackedValue, maxPackedValue, origin)));
|
||||
}
|
||||
|
||||
LOOP_OVER_CELLS: while (cellQueue.size() > 0) {
|
||||
while (cellQueue.size() > 0) {
|
||||
Cell cell = cellQueue.poll();
|
||||
// System.out.println(" visit " + cell);
|
||||
|
||||
|
@ -262,20 +274,9 @@ public class FloatPointNearestNeighbor {
|
|||
// Non-leaf block: split into two cells and put them back into the queue:
|
||||
|
||||
if (hitQueue.size() == topN) {
|
||||
for (int d = 0, offset = 0; d < visitor.dims; ++d, offset += Float.BYTES) {
|
||||
float cellMaxAtDim = FloatPoint.decodeDimension(cell.maxPacked, offset);
|
||||
float cellMinAtDim = FloatPoint.decodeDimension(cell.minPacked, offset);
|
||||
if (cellMaxAtDim < visitor.min[d] || cellMinAtDim > visitor.max[d]) {
|
||||
// this cell is outside our search radius; don't bother exploring any more
|
||||
|
||||
// if (cellMaxAtDim < visitor.min[d]) {
|
||||
// System.out.println(" skipped because cell max at " + d + " (" + cellMaxAtDim + ") < visitor.min[" + d + "] (" + visitor.min[d] + ")");
|
||||
// } else {
|
||||
// System.out.println(" skipped because cell min at " + d + " (" + cellMinAtDim + ") > visitor.max[" + d + "] (" + visitor.max[d] + ")");
|
||||
// }
|
||||
|
||||
continue LOOP_OVER_CELLS;
|
||||
}
|
||||
if (visitor.compare(cell.minPacked, cell.maxPacked) == PointValues.Relation.CELL_OUTSIDE_QUERY) {
|
||||
// this cell is outside our search radius; don't bother exploring any more
|
||||
continue;
|
||||
}
|
||||
}
|
||||
BytesRef splitValue = BytesRef.deepCopyOf(cell.index.getSplitDimValue());
|
||||
|
|
Loading…
Reference in New Issue