iverase commented on a change in pull request #874: LUCENE-8976: Use exact distance between point and bounding rectangle in FloatPointNearestNeighbor URL: https://github.com/apache/lucene-solr/pull/874#discussion_r323177602
########## File path: lucene/sandbox/src/java/org/apache/lucene/document/FloatPointNearestNeighbor.java ########## @@ -306,44 +250,36 @@ public String toString() { hits[downTo] = hitQueue.poll(); downTo--; } + //System.out.println(visitor.comp); return hits; } - private static double approxBestDistanceSquared(byte[] minPackedValue, byte[] maxPackedValue, float[] value) { - boolean insideCell = true; - float[] min = new float[value.length]; - float[] max = new float[value.length]; - double[] closest = new double[value.length]; + private static double pointToRectangleDistanceSquared(byte[] minPackedValue, byte[] maxPackedValue, float[] value, double worstNearestDistanceSquare) { + double sumOfSquaredDiffs = 0.0d; for (int i = 0, offset = 0 ; i < value.length ; ++i, offset += Float.BYTES) { - min[i] = FloatPoint.decodeDimension(minPackedValue, offset); - max[i] = FloatPoint.decodeDimension(maxPackedValue, offset); - if (insideCell) { - if (value[i] < min[i] || value[i] > max[i]) { - insideCell = false; + double min = FloatPoint.decodeDimension(minPackedValue, offset); + if (value[i] < min) { + double diff = min - (double)value[i]; + sumOfSquaredDiffs += diff * diff; + if (worstNearestDistanceSquare < sumOfSquaredDiffs) { Review comment: Not really, it does not make any difference. I remove it for clarity. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org