Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-9176: Handle the case when there is only one leaf node in TestEstimatePointCount (#1212)

Ignacio Vera1fe4177ac093
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 0e968f1d8b4..5f907b1d205 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
@@ -196,7 +196,7 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase {
if (multiValues) {
assertEquals(docCount, (long) (docCount * (1d - Math.pow( (numDocs - pointCount) / points.size() , points.size() / docCount))));
} else {
- assertEquals(pointCount, docCount);
+ assertEquals(Math.min(pointCount, numDocs), docCount);
}
r.close();
dir.close();
@@ -259,7 +259,7 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase {
};
// If all points match, then the point count is numLeaves * maxPointsInLeafNode
- final int numLeaves = (int) Long.highestOneBit( ((points.size() - 1) / actualMaxPointsInLeafNode)) << 1;
+ final int numLeaves = (int) Math.max(Long.highestOneBit( ((points.size() - 1) / actualMaxPointsInLeafNode)) << 1, 1);
assertEquals(numLeaves * actualMaxPointsInLeafNode, points.estimatePointCount(allPointsVisitor));
assertEquals(numDocs, points.estimateDocCount(allPointsVisitor));
@@ -310,7 +310,7 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase {
if (multiValues) {
assertEquals(docCount, (long) (docCount * (1d - Math.pow( (numDocs - pointCount) / points.size() , points.size() / docCount))));
} else {
- assertEquals(pointCount, docCount);
+ assertEquals(Math.min(pointCount, numDocs), docCount);
}
r.close();
dir.close();