You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2017/07/12 15:56:31 UTC

[3/3] lucene-solr:master: SOLR-10796: fix long overflow in testLongPointFieldRangeFacet()

SOLR-10796: fix long overflow in testLongPointFieldRangeFacet()


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6188c8ce
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6188c8ce
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6188c8ce

Branch: refs/heads/master
Commit: 6188c8ce389d187e49453668bc194074cac72842
Parents: d65cbac
Author: Steve Rowe <sa...@apache.org>
Authored: Wed Jul 12 11:55:50 2017 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Wed Jul 12 11:56:21 2017 -0400

----------------------------------------------------------------------
 .../src/test/org/apache/solr/schema/TestPointFields.java | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6188c8ce/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index b6e00b2..83eaebd 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -1187,15 +1187,20 @@ public class TestPointFields extends SolrTestCaseJ4 {
       sortedValues = values.stream().sorted().collect(Collectors.toList());
     } while ((max = sortedValues.get(sortedValues.size() - 1)) >= Long.MAX_VALUE - numValues); // leave room for rounding 
     long min = sortedValues.get(0);
-    long gap = BigInteger.valueOf(max + numValues).subtract(BigInteger.valueOf(min))
-        .divide(BigInteger.valueOf(numBuckets)).longValueExact();
+    BigInteger bigIntGap =  BigInteger.valueOf(max + numValues).subtract(BigInteger.valueOf(min))
+        .divide(BigInteger.valueOf(numBuckets));
+    long gap = bigIntGap.longValueExact();
     int[] bucketCount = new int[numBuckets];
     int bucketNum = 0;
     long minBucketVal = min;
+    System.err.println("min:" + min + "   max: " + max + "   gap: " + gap);
+    System.err.println("bucketNum: " + bucketNum + "   minBucketVal: " + minBucketVal);
     for (Long value : sortedValues) {
-      while (value - minBucketVal >= gap) {
+      System.err.println("value: " + value);
+      while (BigInteger.valueOf(value).subtract(BigInteger.valueOf(minBucketVal)).compareTo(bigIntGap) > 0) {
         ++bucketNum;
         minBucketVal += gap;
+        System.err.println("bucketNum: " + bucketNum + "   minBucketVal: " + minBucketVal);
       }
       ++bucketCount[bucketNum];
     }