belliottsmith commented on code in PR #2144:
URL: https://github.com/apache/cassandra/pull/2144#discussion_r1126802737


##########
src/java/org/apache/cassandra/service/accord/AccordStateCache.java:
##########
@@ -34,101 +34,97 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import accord.api.Data;
+import accord.utils.Invariants;
+import accord.utils.async.AsyncChains;
+import accord.utils.async.AsyncResult;
 import org.apache.cassandra.utils.ObjectSizes;
-import org.apache.cassandra.utils.concurrent.Future;
-import org.apache.cassandra.utils.concurrent.FutureCombiner;
 
 /**
  * Cache for AccordCommand and AccordCommandsForKey, available memory is 
shared between the two object types.
  *
  * Supports dynamic object sizes. After each acquire/free cycle, the cacheable 
objects size is recomputed to
  * account for data added/removed during txn processing if it's modified flag 
is set
- *
- * TODO: explain how items move to and from the active pool and are evicted
  */
 public class AccordStateCache
 {
     private static final Logger logger = 
LoggerFactory.getLogger(AccordStateCache.class);
 
-    private static class WriteOnlyGroup<K, V extends AccordState<K>>
+    public static class Node<K, V> extends AccordLoadingState<K, V>
     {
-        private boolean locked = false;
-        private List<AccordState.WriteOnly<K, V>> items = new ArrayList<>();
+        static final long EMPTY_SIZE = ObjectSizes.measure(new 
AccordStateCache.Node(null));
 
-        @Override
-        public String toString()
+        private Node<?, ?> prev;
+        private Node<?, ?> next;
+        private int references = 0;
+        private long lastQueriedEstimatedSizeOnHeap = 0;
+
+        public Node(K key)
         {
-            return "WriteOnlyGroup{" +
-                   "locked=" + locked +
-                   ", items=" + items +
-                   '}';
+            super(key);
         }
 
-        void lock()
+        public int referenceCount()
         {
-            locked = true;
+            return references;
         }
 
-        void add(AccordState.WriteOnly<K, V> item)
+        boolean isLoaded()
         {
-            items.add(item);
+            return state() == LoadingState.LOADED;
         }
 
-        void purge()
+        public boolean isComplete()
         {
-            if (locked)
-                return;
-
-            while (!items.isEmpty())
+            switch (state())
             {
-                AccordState.WriteOnly<K, V> item = items.get(0);
-
-                // we can't remove items out of order, so if we encounter a 
write is still pending, we stop
-                if (item.future() == null || !item.future().isDone())
-                    break;
-
-                items.remove(0);
+                case PENDING:
+                case NOT_FOUND:
+                    return false;
+                case FAILED:
+                case LOADED:
+                    return true;
+                default: throw new UnsupportedOperationException("Unknown 
state: " + state());
             }
         }
 
-        boolean isEmpty()
+        private boolean isUnlinked()

Review Comment:
   Unlinked felt ambiguous to me as a reader - the next and prev are 
potentially links, but so potentially are the references. Perhaps 
isInEvictionQueue?



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