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 2025/05/02 16:52:35 UTC

[PR] CASSANDRA-20577: add new utility method based off review feedback [cassandra-accord]

dcapwell opened a new pull request, #189:
URL: https://github.com/apache/cassandra-accord/pull/189

   (no comment)


-- 
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


Re: [PR] CASSANDRA-20577: add new utility method based off review feedback [cassandra-accord]

Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #189:
URL: https://github.com/apache/cassandra-accord/pull/189#discussion_r2072007553


##########
accord-core/src/test/java/accord/utils/Property.java:
##########
@@ -944,6 +944,19 @@ public CommandsBuilder<State, SystemUnderTest> addIf(Predicate<State> predicate,
             return this;
         }
 
+        @SafeVarargs
+        public final CommandsBuilder<State, SystemUnderTest> addAllIf(Predicate<State> predicate,
+                                                                      Setup<State, SystemUnderTest> first,
+                                                                      Setup<State, SystemUnderTest> second,
+                                                                      Setup<State, SystemUnderTest>... reset)

Review Comment:
   the reason for this style is to force you to use `addIf` when there is only 1 `Setup`, so can only call if-and-only-if there are at least 2.



-- 
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


Re: [PR] CASSANDRA-20577: add new utility method based off review feedback [cassandra-accord]

Posted by "yifan-c (via GitHub)" <gi...@apache.org>.
yifan-c commented on code in PR #189:
URL: https://github.com/apache/cassandra-accord/pull/189#discussion_r2071899614


##########
accord-core/src/test/java/accord/utils/Property.java:
##########
@@ -944,6 +944,19 @@ public CommandsBuilder<State, SystemUnderTest> addIf(Predicate<State> predicate,
             return this;
         }
 
+        @SafeVarargs
+        public final CommandsBuilder<State, SystemUnderTest> addAllIf(Predicate<State> predicate,
+                                                                      Setup<State, SystemUnderTest> first,
+                                                                      Setup<State, SystemUnderTest> second,
+                                                                      Setup<State, SystemUnderTest>... reset)

Review Comment:
   `rest`?



##########
accord-core/src/test/java/accord/utils/Property.java:
##########
@@ -944,6 +944,19 @@ public CommandsBuilder<State, SystemUnderTest> addIf(Predicate<State> predicate,
             return this;
         }
 
+        @SafeVarargs
+        public final CommandsBuilder<State, SystemUnderTest> addAllIf(Predicate<State> predicate,

Review Comment:
   To me, `addAllIf` is hard to understand. My mental model when processing it reads as 
   ```
   if (predicate) 
   {
      first;
      second;
      rest...;
   }
   ```
   So, maybe just `addIf`. 
   I guess you mean "add all the if statements". Since they are using the same predicate, it is really one single `if` statement. 



-- 
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


Re: [PR] CASSANDRA-20577: add new utility method based off review feedback [cassandra-accord]

Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell merged PR #189:
URL: https://github.com/apache/cassandra-accord/pull/189


-- 
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


Re: [PR] CASSANDRA-20577: add new utility method based off review feedback [cassandra-accord]

Posted by "dcapwell (via GitHub)" <gi...@apache.org>.
dcapwell commented on code in PR #189:
URL: https://github.com/apache/cassandra-accord/pull/189#discussion_r2072020795


##########
accord-core/src/test/java/accord/utils/Property.java:
##########
@@ -944,6 +944,19 @@ public CommandsBuilder<State, SystemUnderTest> addIf(Predicate<State> predicate,
             return this;
         }
 
+        @SafeVarargs
+        public final CommandsBuilder<State, SystemUnderTest> addAllIf(Predicate<State> predicate,

Review Comment:
   > My mental model when processing it reads as
   
   That is what it is doing, but it doesn't do it right away, it does this later on.
   
   `addIf(predicte, stmt)`. this doesn't add the `stmt` to the builder if the predicate is true.  What this actually does is the following (logically)
   
   ```
   conditionals.put(predicate, stmt); // multiple stmt can share the same predicate
   ```
   
   then when the stateful builder executes it calls `public Gen<Command<State, SystemUnderTest, ?>> commands(State state) throws Throwable`
   
   What we do here is 
   
   ```
   Map<Gen, Weight> weights = ...
   weights.addAll(unconditional);
   for (predicate, stmts) in conditionals:
     if predicate.test(state):
       stmts.forEach(stmt ->     weights.put(stmt, weightGen.next(rs)));
   
   Gen gen = Gens.pick(weights);
   ```
   
   So we eval the `predicate` each "step" and add the commands then.  
   
   So given this, your mental model is in fact correct, its just delayed.



-- 
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