aweisberg commented on code in PR #3694:
URL: https://github.com/apache/cassandra/pull/3694#discussion_r1848850613
##########
src/java/org/apache/cassandra/service/accord/api/AccordRoutingKey.java:
##########
@@ -318,6 +319,119 @@ public long serializedSize(TokenKey key, int version)
}
}
+ // Allows the creation of a Range that is begin inclusive or end exclusive
for a given Token
+ public static final class MinTokenKey extends TokenKey
+ {
+ private static final long EMPTY_SIZE;
+
+ @Override
+ public Range asRange()
+ {
+ AccordRoutingKey before = token.isMinimum()
+ ? new SentinelKey(table, true)
+ : new MinTokenKey(table,
token.decreaseSlightly());
+
+ return new TokenRange(before, this);
+ }
+
+ static
+ {
+ EMPTY_SIZE = ObjectSizes.measure(new MinTokenKey(null, null));
+ }
+
+ public MinTokenKey(TableId tableId, Token token)
+ {
+ super(tableId, token);
+ }
+
+ public MinTokenKey withToken(Token token)
+ {
+ return new MinTokenKey(table, token);
+ }
+
+ @Override
+ public Token token()
+ {
+ return token;
+ }
+
+ @Override
+ public RoutingKeyKind kindOfRoutingKey()
+ {
+ return RoutingKeyKind.MIN_TOKEN;
+ }
+
+ @Override
+ public String suffix()
+ {
+ return token.toString();
+ }
+
+ public long estimatedSizeOnHeap()
+ {
+ return EMPTY_SIZE + token().getHeapSize();
+ }
+
+ public AccordRoutingKey withTable(TableId table)
+ {
+ return new MinTokenKey(table, token);
+ }
+
+ public static final MinTokenKey.Serializer serializer = new
MinTokenKey.Serializer();
+ public static class Serializer implements
AccordKeySerializer<MinTokenKey>
Review Comment:
I didn't extend because it seemed like it was different enough from a
`TokenKey` that having it pass `instance` checks would be misleading and it
also makes overriding methods that need to be different tricky.
I'll update them to share a serializer.
--
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]