aweisberg commented on code in PR #7:
URL: https://github.com/apache/cassandra-accord/pull/7#discussion_r1014235152


##########
accord-core/src/main/java/accord/primitives/Txn.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.primitives;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import accord.local.Command;
+import accord.local.CommandStore;
+
+import accord.api.*;
+import accord.local.SafeCommandStore;
+import accord.utils.ReducingFuture;
+import org.apache.cassandra.utils.concurrent.Future;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public interface Txn
+{
+    enum Kind
+    {
+        READ, WRITE;
+
+        public boolean isWrite()
+        {
+            return this == WRITE;
+        }
+    }
+
+    class InMemory implements Txn
+    {
+        private final Kind kind;
+        private final Keys keys;
+        private final Read read;
+        private final Query query;
+        private final Update update;
+
+        public InMemory(@Nonnull Keys keys, @Nonnull Read read, @Nonnull Query 
query)
+        {
+            this.kind = Kind.READ;
+            this.keys = keys;
+            this.read = read;
+            this.query = query;
+            this.update = null;
+        }
+
+        public InMemory(@Nonnull Keys keys, @Nonnull Read read, @Nonnull Query 
query, @Nullable Update update)
+        {
+            this.kind = Kind.WRITE;
+            this.keys = keys;
+            this.read = read;
+            this.update = update;
+            this.query = query;
+        }
+
+        protected InMemory(@Nonnull Kind kind, @Nonnull Keys keys, @Nonnull 
Read read, @Nullable Query query, @Nullable Update update)
+        {
+            this.kind = kind;
+            this.keys = keys;
+            this.read = read;
+            this.update = update;
+            this.query = query;
+        }
+
+        @Override
+        public PartialTxn slice(KeyRanges ranges, boolean includeQuery)
+        {
+            return new PartialTxn.InMemory(
+                    ranges, kind(), keys().slice(ranges),
+                    read().slice(ranges), includeQuery ? query() : null,
+                    update() == null ? null : update().slice(ranges)
+            );
+        }
+
+        @Override
+        public Kind kind()
+        {
+            return kind;
+        }
+
+        @Override
+        public Keys keys()
+        {
+            return keys;
+        }
+
+        @Override
+        public Read read()
+        {
+            return read;
+        }
+
+        @Override
+        public Query query()
+        {
+            return query;
+        }
+
+        @Override
+        public Update update()
+        {
+            return update;
+        }
+
+        @Override
+        public boolean equals(Object o)

Review Comment:
   Then implement `hashCode` to throw `UnsupportedOperationException`?
   
   Your point is valid, but I don't think we should leave it at them 
disagreeing.
   
   I also did a quick check and I am not sure we use `equals` anywhere either.



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