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


##########
accord-core/src/main/java/accord/impl/InMemoryCommandStore.java:
##########
@@ -92,6 +94,11 @@ public abstract class InMemoryCommandStore extends 
CommandStore
 
     private final TreeMap<TxnId, RangeCommand> rangeCommands = new TreeMap<>();
     private final TreeMap<TxnId, Ranges> historicalRangeCommands = new 
TreeMap<>();
+    /**
+     * Since this cache is fully in-memory the store does not hit states that 
most stores will; that data is not in-memory!
+     * To simulate such behaviors, a "cache" is used to state what is 
in-memory vs what needs to be loaded.
+     */
+    private final Set<Object> cache = new LinkedHashSet<>();

Review Comment:
   ill need to look closer at this change, after rebase we are failing and 
looks like its a cache hit issue... looking at the patch now (a long time 
remove from when I wrote it) I see we do the following
   
   ```
   private static <K, V> V getIfLoaded(K key, Function<K, V> get, Consumer<V> 
add, Function<K, V> getIfLoaded)
       {
           V value = get.apply(key);
           if (value != null)
               return value;
   
           value = getIfLoaded.apply(key);
           if (value == null)
               return null;
           add.accept(value);
           return value;
       }
   ```
   
   where `get` is defined as
   
   ```
   protected InMemorySafeCommand getCommandInternal(TxnId txnId)
           {
               return commands.get(txnId);
           }
   ```
   
   and `getIfLoaded` is
   
   ```
   protected InMemorySafeCommand getIfLoaded(TxnId txnId)
           {
               GlobalCommand global = commandStore.ifPresent(txnId);
               return global != null ? global.createSafeReference() : null;
           }
   ```
   
   so the `get` logic just reaches into the cache... so the `getIfLoaded` only 
happens iff `get` returned `null`... but that is just
   
   ```
   public GlobalCommand ifPresent(TxnId txnId)
       {
           return cacheHit(txnId) ? commands.get(txnId) : null;
       }
   ```
   
   so not sure how that matters at all...



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