lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1622351 - /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/StringHelper.java
Date Wed, 03 Sep 2014 20:36:08 GMT
Author: mikemccand
Date: Wed Sep  3 20:36:08 2014
New Revision: 1622351

URL: http://svn.apache.org/r1622351
Log:
LUCENE-5895: fix bug (when 2nd long from xorshift was negative) causing ids to be prefixed
by 16 0s

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/StringHelper.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/StringHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/StringHelper.java?rev=1622351&r1=1622350&r2=1622351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/StringHelper.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/StringHelper.java Wed Sep
 3 20:36:08 2014
@@ -281,8 +281,12 @@ public abstract class StringHelper {
       x1 = s1 ^ s0 ^ (s1 >>> 17) ^ (s0 >>> 26); // b, c
     }
 
+    // First make unsigned versions of x0, x1:
+    BigInteger unsignedX0 = new BigInteger(1, BigInteger.valueOf(x0).toByteArray());
+    BigInteger unsignedX1 = new BigInteger(1, BigInteger.valueOf(x1).toByteArray());
+
     // Concatentate bits of x0 and x1, as unsigned 128 bit integer:
-    nextId = new BigInteger(1, BigInteger.valueOf(x0).shiftLeft(64).or(BigInteger.valueOf(x1)).toByteArray());
+    nextId = unsignedX0.shiftLeft(64).or(unsignedX1);
   }
 
   /** Generates a non-cryptographic globally unique id. */



Mime
View raw message