mirror of https://github.com/apache/lucene.git
LUCENE-5895: fix bug (when 2nd long from xorshift was negative) causing ids to be prefixed by 16 0s
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1622351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f31b2e0e3
commit
1eee3e4ee2
|
@ -281,8 +281,12 @@ public abstract class StringHelper {
|
||||||
x1 = s1 ^ s0 ^ (s1 >>> 17) ^ (s0 >>> 26); // b, c
|
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:
|
// 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. */
|
/** Generates a non-cryptographic globally unique id. */
|
||||||
|
|
Loading…
Reference in New Issue