dcapwell commented on code in PR #3474:
URL: https://github.com/apache/cassandra/pull/3474#discussion_r1723579107
##########
test/unit/org/apache/cassandra/utils/CassandraGenerators.java:
##########
@@ -610,6 +628,58 @@ public static Gen<Token> tokensInRange(Range<Token> range)
throw new UnsupportedOperationException("Unsupported partitioner: " +
partitioner.getClass());
}
+ private enum SupportedPartitioners { Murmur, ByteOrdered, Random, Local,
OrderPreserving}
+
+ public static Gen<IPartitioner> partitioners()
+ {
+ var pGen =
SourceDSL.arbitrary().enumValues(SupportedPartitioners.class);
+ return pGen.flatMap(p -> {
+ switch (p)
+ {
+ case Murmur: return ignore -> Murmur3Partitioner.instance;
+ case ByteOrdered: return ignore ->
ByteOrderedPartitioner.instance;
+ case Random: return ignore -> RandomPartitioner.instance;
+ case OrderPreserving: return ignore ->
OrderPreservingPartitioner.instance;
+ case Local: return localPartitioner();
+ default: throw new AssertionError("Unknown partition: " + p);
+ }
+ });
+ }
+
+ public static Gen<IPartitioner> nonLocalPartitioners()
+ {
+ var pGen =
SourceDSL.arbitrary().enumValues(SupportedPartitioners.class);
+ return pGen.assuming(p -> p != SupportedPartitioners.Local).flatMap(p
-> {
+ switch (p)
+ {
+ case Murmur: return ignore -> Murmur3Partitioner.instance;
+ case ByteOrdered: return ignore ->
ByteOrderedPartitioner.instance;
+ case Random: return ignore -> RandomPartitioner.instance;
+ case OrderPreserving: return ignore ->
OrderPreservingPartitioner.instance;
+ default: throw new AssertionError("Unknown partition: " + p);
+ }
+ });
+ }
Review Comment:
made the change, good suggestions
--
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]