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

This commit is contained in:
Ignacio Vera 2020-01-27 09:52:25 +01:00 committed by GitHub
parent ae95f0ab68
commit 1fe4177ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -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();