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-unsubscr...@cassandra.apache.org

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


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

Reply via email to