belliottsmith commented on code in PR #2144:
URL: https://github.com/apache/cassandra/pull/2144#discussion_r1127607981
##########
src/java/org/apache/cassandra/service/accord/AccordStateCache.java:
##########
@@ -18,117 +18,115 @@
package org.apache.cassandra.service.accord;
-import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
+import java.util.function.ToLongFunction;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
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;
+
+import static
org.apache.cassandra.service.accord.AccordLoadingState.LoadingState.FAILED;
+import static
org.apache.cassandra.service.accord.AccordLoadingState.LoadingState.LOADED;
/**
* 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;
Review Comment:
We have a doubly-linked list, and idiomatically these have a dummy header
(embedded in the owning class, i.e. so that `AccordStateCache` would extend
`Node` or some super class). We have templates for this already around the
codebase, e.g. `IntrusiveLinkedList`.
--
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]