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


##########
accord-core/src/main/java/accord/impl/InMemoryCommandStore.java:
##########
@@ -388,20 +395,32 @@ private void loadCommandsForKey(RoutableKey key,
         timestampsForKey.put(key, timestampsForKey((Key) 
key).createSafeReference());
     }
 
+    protected void validateRead(Command current) {}
+
     protected final InMemorySafeStore createSafeStore(PreLoadContext context, 
RangesForEpoch ranges)
     {
         Map<TxnId, InMemorySafeCommand> commands = new HashMap<>();
         Map<RoutableKey, InMemorySafeCommandsForKey> commandsForKey = new 
HashMap<>();
         Map<RoutableKey, InMemorySafeTimestampsForKey> timestampsForKey = new 
HashMap<>();
 
         context.forEachId(txnId -> commands.put(txnId, lazyReference(txnId)));
+        for (InMemorySafeCommand safe : commands.values())
+        {
+            GlobalCommand global = safe.unsafeGlobal();
+            if (global == null) continue;
+            Command current = global.value();
+            if (current == null) continue;
+            validateRead(current);
+        }
 
         for (Seekable seekable : context.keys())
         {
             switch (seekable.domain())
             {
                 case Key:
                     RoutableKey key = (RoutableKey) seekable;
+                    if (context.keyHistory() == KeyHistory.NONE)

Review Comment:
   switched to
   
   ```
   switch (context.keyHistory())
                       {
                           case NONE:
                               continue;
                           case COMMANDS:
                               commandsForKey.put(key, commandsForKey((Key) 
key).createSafeReference());
                               break;
                           case TIMESTAMPS:
                               timestampsForKey.put(key, timestampsForKey((Key) 
key).createSafeReference());
                               break;
                           default: throw new 
UnsupportedOperationException("Unknown key history: " + context.keyHistory());
                       }
   ```



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