dcapwell commented on code in PR #4078:
URL: https://github.com/apache/cassandra/pull/4078#discussion_r2040347579


##########
src/java/org/apache/cassandra/service/accord/serializers/TableMetadatasAndKeys.java:
##########
@@ -0,0 +1,270 @@
+/*
+ * 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 org.apache.cassandra.service.accord.serializers;
+
+import java.io.IOException;
+import java.util.Comparator;
+
+import accord.api.Key;
+import accord.api.Sliceable;
+import accord.primitives.AbstractRanges;
+import accord.primitives.Keys;
+import accord.primitives.Participants;
+import accord.primitives.Ranges;
+import accord.primitives.Routable;
+import accord.primitives.Seekable;
+import accord.primitives.Seekables;
+import accord.utils.Invariants;
+import accord.utils.VIntCoding;
+import org.apache.cassandra.db.DecoratedKey;
+import org.apache.cassandra.io.UnversionedSerializer;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.schema.TableId;
+import org.apache.cassandra.schema.TableMetadata;
+import org.apache.cassandra.service.accord.api.PartitionKey;
+import org.apache.cassandra.service.accord.serializers.TableMetadatas.Multi;
+import org.apache.cassandra.utils.btree.BTreeSet;
+
+import static accord.primitives.Routable.Domain.Range;
+import static accord.primitives.Routables.Slice.Minimal;
+
+public class TableMetadatasAndKeys extends 
IVersionedWithKeysSerializer.AbstractWithKeysSerializer implements 
Sliceable<TableMetadatasAndKeys>
+{
+    public static class KeyCollector extends 
AbstractSortedCollector<PartitionKey, Keys>
+    {
+        private static final Comparator<Object> comparator = 
Comparator.comparing(v -> ((PartitionKey) v));
+
+        public final TableMetadatas tables;
+
+        public KeyCollector(TableMetadatas tables)
+        {
+            this.tables = tables;
+        }
+
+        public TableMetadatasAndKeys buildTablesAndKeys()
+        {
+            return new TableMetadatasAndKeys(tables, build());
+        }
+
+        @Override
+        Comparator<Object> comparator()
+        {
+            return comparator;
+        }
+
+        public PartitionKey collect(TableMetadata table, DecoratedKey key)
+        {
+            TableId tableId = tables.get(table.id).id;
+            if (count == 1)
+            {
+                PartitionKey one = (PartitionKey) buffer;
+                if (one.prefix() == table && one.partitionKey().equals(key))

Review Comment:
   for me: look very closely at `one.prefix() == table` and any possible way 
for this to not be true when `.equals` would be true.  There was a race 
condition with `intern` that invalidated, so this patch is what needs to *own* 
this deduping



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