Skip to content

Apache Lucene open-source search software

LUCENE-7640: Fix test failure.

Adrien Grandc7fdd1097141
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 08dc6c60827..8f0be3afcc7 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
@@ -253,25 +253,28 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase {
}));
// If only one point matches, then the point count is (actualMaxPointsInLeafNode + 1) / 2
- assertEquals((actualMaxPointsInLeafNode + 1) / 2,
- points.estimatePointCount(new IntersectVisitor() {
- @Override
- public void visit(int docID, byte[] packedValue) throws IOException {}
-
- @Override
- public void visit(int docID) throws IOException {}
-
- @Override
- public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
- for (int dim = 0; dim < 2; ++dim) {
- if (StringHelper.compare(3, uniquePointValue[dim], 0, maxPackedValue, dim * 3) > 0 ||
- StringHelper.compare(3, uniquePointValue[dim], 0, minPackedValue, dim * 3) < 0) {
- return Relation.CELL_OUTSIDE_QUERY;
- }
+ // in general, or maybe 2x that if the point is a split value
+ final long pointCount = points.estimatePointCount(new IntersectVisitor() {
+ @Override
+ public void visit(int docID, byte[] packedValue) throws IOException {}
+
+ @Override
+ public void visit(int docID) throws IOException {}
+
+ @Override
+ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
+ for (int dim = 0; dim < 2; ++dim) {
+ if (StringHelper.compare(3, uniquePointValue[dim], 0, maxPackedValue, dim * 3) > 0 ||
+ StringHelper.compare(3, uniquePointValue[dim], 0, minPackedValue, dim * 3) < 0) {
+ return Relation.CELL_OUTSIDE_QUERY;
}
- return Relation.CELL_CROSSES_QUERY;
}
- }));
+ return Relation.CELL_CROSSES_QUERY;
+ }
+ });
+ assertTrue(""+pointCount,
+ pointCount == (actualMaxPointsInLeafNode + 1) / 2 || // common case
+ pointCount == 2*((actualMaxPointsInLeafNode + 1) / 2)); // if the point is a split value
r.close();
dir.close();
diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
index fecdaa5082b..b9dad6fff80 100644
--- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
+++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
@@ -1173,23 +1173,26 @@ public class TestBKD extends LuceneTestCase {
}));
// If only one point matches, then the point count is (actualMaxPointsInLeafNode + 1) / 2
- assertEquals((actualMaxPointsInLeafNode + 1) / 2,
- points.estimatePointCount(new IntersectVisitor() {
- @Override
- public void visit(int docID, byte[] packedValue) throws IOException {}
-
- @Override
- public void visit(int docID) throws IOException {}
-
- @Override
- public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
- if (StringHelper.compare(numBytesPerDim, uniquePointValue, 0, maxPackedValue, 0) > 0 ||
- StringHelper.compare(numBytesPerDim, uniquePointValue, 0, minPackedValue, 0) < 0) {
- return Relation.CELL_OUTSIDE_QUERY;
- }
- return Relation.CELL_CROSSES_QUERY;
- }
- }));
+ // in general, or maybe 2x that if the point is a split value
+ final long pointCount = points.estimatePointCount(new IntersectVisitor() {
+ @Override
+ public void visit(int docID, byte[] packedValue) throws IOException {}
+
+ @Override
+ public void visit(int docID) throws IOException {}
+
+ @Override
+ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
+ if (StringHelper.compare(numBytesPerDim, uniquePointValue, 0, maxPackedValue, 0) > 0 ||
+ StringHelper.compare(numBytesPerDim, uniquePointValue, 0, minPackedValue, 0) < 0) {
+ return Relation.CELL_OUTSIDE_QUERY;
+ }
+ return Relation.CELL_CROSSES_QUERY;
+ }
+ });
+ assertTrue(""+pointCount,
+ pointCount == (actualMaxPointsInLeafNode + 1) / 2 || // common case
+ pointCount == 2*((actualMaxPointsInLeafNode + 1) / 2)); // if the point is a split value
pointsIn.close();
dir.close();