You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mv...@apache.org on 2017/06/19 09:42:18 UTC

lucene-solr:master: LUCENE-7571: Take into account float precision loss when generating unique values.

Repository: lucene-solr
Updated Branches:
  refs/heads/master 64093d6df -> 09b0eee5b


LUCENE-7571: Take into account float precision loss when generating unique values.


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

Branch: refs/heads/master
Commit: 09b0eee5bbc90652b78aece27cba89998dff7816
Parents: 64093d6
Author: Martijn van Groningen <ma...@gmail.com>
Authored: Mon Jun 19 11:41:59 2017 +0200
Committer: Martijn van Groningen <mv...@apache.org>
Committed: Mon Jun 19 11:41:59 2017 +0200

----------------------------------------------------------------------
 .../src/test/org/apache/lucene/search/join/TestJoinUtil.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/09b0eee5/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
index 49dd333..1503de8 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
@@ -1325,7 +1325,10 @@ public class TestJoinUtil extends LuceneTestCase {
       String uniqueRandomValue;
       do {
         // the trick is to generate values which will be ordered similarly for string, ints&longs, positive nums makes it easier
-        final int nextInt = random.nextInt(Integer.MAX_VALUE);
+        //
+        // Additionally in order to avoid precision loss when joining via a float field we can't generate values higher than
+        // 0xFFFFFF, so we can't use Integer#MAX_VALUE as upper bound here:
+        final int nextInt = random.nextInt(0xFFFFFF);
         uniqueRandomValue = String.format(Locale.ROOT, "%08x", nextInt);
         assert nextInt == Integer.parseUnsignedInt(uniqueRandomValue,16);
       } while ("".equals(uniqueRandomValue) || trackSet.contains(uniqueRandomValue));