You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "dcapwell (via GitHub)" <gi...@apache.org> on 2023/03/14 17:41:18 UTC

[GitHub] [cassandra] dcapwell commented on a diff in pull request #2209: CASSANDRA-18213: CEP-15: (Accord) Migrate Accord away from JDK random to a new interface RandomSource

dcapwell commented on code in PR #2209:
URL: https://github.com/apache/cassandra/pull/2209#discussion_r1135968448


##########
test/unit/org/apache/cassandra/utils/AccordGenerators.java:
##########
@@ -18,48 +18,26 @@
 
 package org.apache.cassandra.utils;
 
-import java.util.function.ToIntFunction;
-import java.util.function.ToLongFunction;
-
 import accord.local.Command;
-import accord.local.Node;
 import accord.primitives.PartialTxn;
-import accord.primitives.Routable;
 import accord.primitives.Timestamp;
-import accord.primitives.Txn;
 import accord.primitives.TxnId;
 import accord.utils.Gen;
 import accord.utils.Gens;
 import org.apache.cassandra.service.accord.AccordTestUtils;
 
+import static accord.utils.AccordGens.txnIds;
 import static org.apache.cassandra.service.accord.AccordTestUtils.createPartialTxn;
 
 public class AccordGenerators
 {
     private AccordGenerators() {}
 
-    public static Gen.LongGen epochs()
-    {
-        return Gens.longs().between(0, Timestamp.MAX_EPOCH);
-    }
-
-    public static Gen<TxnId> ids()
-    {
-        return ids(epochs()::nextLong, Gen.Random::nextLong, Gen.Random::nextInt);
-    }
-
-    public static Gen<TxnId> ids(ToLongFunction<Gen.Random> epochs, ToLongFunction<Gen.Random> hlcs, ToIntFunction<Gen.Random> nodes)
-    {
-        Gen<Txn.Kind> kinds = Gens.enums().all(Txn.Kind.class);
-        Gen<Routable.Domain> domains = Gens.enums().all(Routable.Domain.class);
-        return rs -> new TxnId(epochs.applyAsLong(rs), hlcs.applyAsLong(rs), kinds.next(rs), domains.next(rs), new Node.Id(nodes.applyAsInt(rs)));
-    }
-

Review Comment:
   this got moved to `AccordGens` so accord manages this rather than C*



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org