Skip to content

Apache Lucene open-source search software

LUCENE-9244: In 2D, a point can be shared by four leaves (#1279)

Ignacio Veraf018c4c81377
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 76cd42be5c8..590e514f5ac 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -174,6 +174,9 @@ Other
* LUCENE-9275: Make TestLatLonMultiPolygonShapeQueries more resilient for CONTAINS queries. (Ignacio Vera)
+* LUCENE-9244: Adjust TestLucene60PointsFormat#testEstimatePointCount2Dims so it does not fail when a point
+ is shared by multiple leaves. (Ignacio Vera)
+
======================= Lucene 8.5.0 =======================
API Changes
diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java b/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java
index 33c145f9ed1..4487ed012b6 100644
--- a/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java
+++ b/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java
@@ -299,12 +299,13 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase {
return Relation.CELL_CROSSES_QUERY;
}
};
- // If only one point matches, then the point count is (actualMaxPointsInLeafNode + 1) / 2
- // in general, or maybe 2x that if the point is a split value
+
final long pointCount = points.estimatePointCount(onePointMatchVisitor);
- assertTrue(""+pointCount,
- pointCount == (actualMaxPointsInLeafNode + 1) / 2 || // common case
- pointCount == 2*((actualMaxPointsInLeafNode + 1) / 2)); // if the point is a split value
+ // The number of matches needs to be multiple of count per leaf
+ final long countPerLeaf = (actualMaxPointsInLeafNode + 1) / 2;
+ assertTrue(""+pointCount, pointCount % countPerLeaf == 0);
+ // in extreme cases, a point can be be shared by 4 leaves
+ assertTrue(""+pointCount, pointCount / countPerLeaf <= 4 && pointCount / countPerLeaf >= 1);
final long docCount = points.estimateDocCount(onePointMatchVisitor);
if (multiValues) {