From 1fe4177ac093ebe55428ab3a0e51e13a1a933567 Mon Sep 17 00:00:00 2001 From: Ignacio Vera Date: Mon, 27 Jan 2020 09:52:25 +0100 Subject: [PATCH] LUCENE-9176: Handle the case when there is only one leaf node in TestEstimatePointCount (#1212) --- .../lucene/codecs/lucene60/TestLucene60PointsFormat.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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();