dcapwell commented on code in PR #6:
URL: https://github.com/apache/cassandra-accord/pull/6#discussion_r946038785


##########
accord-core/src/main/java/accord/messages/BeginRecovery.java:
##########
@@ -289,24 +273,44 @@ public String toString()
         }
     }
 
-    private static Stream<Command> uncommittedStartedBefore(CommandStore 
commandStore, TxnId startedBefore, Keys keys)
+    private static Deps uncommittedStartedBefore(CommandStore commandStore, 
TxnId txnId, Keys keys)
     {
-        return keys.stream().flatMap(key -> {
-            CommandsForKey forKey = commandStore.maybeCommandsForKey(key);
-            if (forKey == null)
-                return Stream.of();
-            return forKey.uncommitted.headMap(startedBefore, 
false).values().stream();
-        });
+        try (Deps.OrderedBuilder builder = Deps.orderedBuilder(true);)
+        {
+            keys.forEach(key -> {
+                CommandsForKey forKey = commandStore.maybeCommandsForKey(key);
+                if (forKey == null)
+                    return;
+
+                // committed txns with an earlier txnid and have our txnid as 
a dependency
+                builder.nextKey(key);
+                forKey.uncommitted.headMap(txnId, false).forEach((ts, command) 
-> {
+                    if (command.is(Accepted) && 
command.savedDeps().contains(txnId) && command.executeAt().compareTo(txnId) > 0)

Review Comment:
   this was `!c.savedDeps().contains(txnId)` before, now its searching 
explicitly for commands that depend on the TxnId?



##########
accord-core/src/main/java/accord/messages/BeginRecovery.java:
##########
@@ -76,19 +76,13 @@ public void process(Node node, Id replyToNode, ReplyContext 
replyContext)
                                          .anyMatch(c -> 
!c.savedDeps().contains(txnId));
 
                 // committed txns with an earlier txnid and have our txnid as 
a dependency
-                earlierCommittedWitness = committedStartedBefore(instance, 
txnId, txn.keys)
-                                          .filter(c -> 
c.savedDeps().contains(txnId))
-                                          .collect(Dependencies::new, 
Dependencies::add, Dependencies::addAll);
+                earlierCommittedWitness = committedStartedBefore(instance, 
txnId, txn.keys);
 
                 // accepted txns with an earlier txnid that don't have our 
txnid as a dependency
-                earlierAcceptedNoWitness = uncommittedStartedBefore(instance, 
txnId, txn.keys)
-                                              .filter(c -> c.is(Accepted)
-                                                           && 
!c.savedDeps().contains(txnId)

Review Comment:
   trying to understand this difference... we now do 
`command.savedDeps().contains(txnId)`... is there a test I can look at that 
hits this subtle difference?



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

Reply via email to