File tree Expand file tree Collapse file tree 1 file changed +1
-1
lines changed
server/src/main/java/org/elasticsearch/search/query Expand file tree Collapse file tree 1 file changed +1
-1
lines changed Original file line number Diff line number Diff line change @@ -584,7 +584,7 @@ static long estimateMedianValue(PointValues pointValues) throws IOException {
584584 long minValue = LongPoint .decodeDimension (pointValues .getMinPackedValue (), 0 );
585585 long maxValue = LongPoint .decodeDimension (pointValues .getMaxPackedValue (), 0 );
586586 while (minValue < maxValue ) {
587- long avgValue = Math .floorDiv (minValue + maxValue , 2 );
587+ long avgValue = Math .floorDiv (minValue , 2 ) + Math . floorDiv ( maxValue , 2 ); // to avoid overflow first divide each value by 2
588588 long countLeft = estimatePointCount (pointValues , minValue , avgValue );
589589 long countRight = estimatePointCount (pointValues , avgValue + 1 , maxValue );
590590 if (countLeft >= countRight ) {
You can’t perform that action at this time.
0 commit comments