You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/04/11 11:09:43 UTC

[GitHub] [cassandra-accord] belliottsmith commented on a diff in pull request #2: Initial Cassandra integration

belliottsmith commented on code in PR #2:
URL: https://github.com/apache/cassandra-accord/pull/2#discussion_r847208996


##########
accord-core/src/main/java/accord/messages/TxnRequest.java:
##########
@@ -33,113 +29,51 @@ public Scope scope()
      */
     public static class Scope
     {
-        public static class KeysForEpoch
-        {
-            public final long epoch;
-            public final Keys keys;
-
-            public KeysForEpoch(long epoch, Keys keys)
-            {
-                this.epoch = epoch;
-                this.keys = keys;
-            }
-
-            static KeysForEpoch forTopology(Topology topology, Node.Id node, Keys keys)
-            {
-                KeyRanges topologyRanges = topology.rangesForNode(node);
-                if (topologyRanges == null)
-                    return null;
-                topologyRanges = topologyRanges.intersection(keys);
-                Keys scopeKeys = keys.intersection(topologyRanges);
-                return !topologyRanges.isEmpty() ? new KeysForEpoch(topology.epoch(), scopeKeys) : null;
-            }
+        private final long minRequiredEpoch;
+        private final Keys keys;
 
-            @Override
-            public boolean equals(Object o)
-            {
-                if (this == o) return true;
-                if (o == null || getClass() != o.getClass()) return false;
-                KeysForEpoch that = (KeysForEpoch) o;
-                return epoch == that.epoch && keys.equals(that.keys);
-            }
-
-            @Override
-            public int hashCode()
-            {
-                return Objects.hash(epoch, keys);
-            }
-
-            @Override
-            public String toString()
-            {
-                return "EpochRanges{" +
-                        "epoch=" + epoch +
-                        ", keys=" + keys +
-                        '}';
-            }
-        }
-
-        private final long maxEpoch;
-        private final KeysForEpoch[] epochs;
-
-        public Scope(long maxEpoch, KeysForEpoch... epochKeys)
-        {
-            this.maxEpoch = maxEpoch;
-            this.epochs = epochKeys;
-        }
-
-        public int size()
-        {
-            return epochs.length;
-        }
-
-        public KeysForEpoch get(int i)
+        public Scope(long minRequiredEpoch, Keys keys)
         {
-            return epochs[i];
+            this.minRequiredEpoch = minRequiredEpoch;
+            this.keys = keys;
         }
 
-        public static Scope forTopologies(Node.Id node, Topologies topologies, Keys keys)
+        public static Scope forTopologies(Node.Id node, Topologies topologies, Keys txnKeys)
         {
-            List<KeysForEpoch> ranges = new ArrayList<>(topologies.size());
+            long minEpoch = 0;
+            Keys scopeKeys = Keys.EMPTY;
+            Keys lastKeys = null;
             for (int i=topologies.size() - 1; i>=0; i--)
             {
                 Topology topology = topologies.get(i);
-                KeysForEpoch keysForEpoch = KeysForEpoch.forTopology(topology, node, keys);
-                if (keysForEpoch != null)
+                KeyRanges topologyRanges = topology.rangesForNode(node);
+                if (topologyRanges == null)
+                    continue;
+                topologyRanges = topologyRanges.intersection(txnKeys);
+                Keys epochKeys = txnKeys.intersection(topologyRanges);
+                if (lastKeys == null || !lastKeys.equals(epochKeys))

Review Comment:
   could this be `lastKeys.containsAll(epochKeys)`?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org