iamaleksey commented on code in PR #2073:
URL: https://github.com/apache/cassandra/pull/2073#discussion_r1071318442
##########
src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java:
##########
@@ -276,4 +277,55 @@ public AbstractType<?> partitionOrdering()
{
return UTF8Type.instance;
}
+
+ @Override
+ public AccordSplitter accordSplitter()
+ {
+ return this;
+ }
+
+ @Override
+ BigInteger valueForToken(Token token)
+ {
+ String chars = ((StringToken) token).token;
+ int charLength = 8;
+ BigInteger value = BigInteger.ZERO;
+ for (int i = 0 ; i < Math.min(8, chars.length()) ; ++i)
+ value = value.add(BigInteger.valueOf(chars.charAt(i) &
0xffffL).shiftLeft((charLength - 1 - i) * 16));
+ return value;
+ }
+
+ @Override
+ Token tokenForValue(BigInteger value)
+ {
+ // TODO (required): test
+ Invariants.checkArgument(value.compareTo(BigInteger.ZERO) >= 0);
+ int charLength = (value.bitLength() + 15) / 16;
+ char[] chars = new char[charLength];
+ for (int i = 0 ; i < charLength ; ++i)
+ chars[i] = (char) value.shiftRight((charLength - 1 - i) *
16).shortValue();
+ return new StringToken(new String(chars));
+ }
+
+ @Override
+ BigInteger minimumValue()
+ {
+ return BigInteger.ZERO;
+ }
+
+ @Override
+ BigInteger maximumValue(BigInteger start)
+ {
+ return BigInteger.ONE.shiftLeft((start.bitLength() + 15) / 16);
Review Comment:
`* 16`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]