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 2021/11/29 10:43:36 UTC

[GitHub] [cassandra] jacek-lewandowski commented on a change in pull request #1276: CASSANDRA-17048: UUID based sstable generation numbers

jacek-lewandowski commented on a change in pull request #1276:
URL: https://github.com/apache/cassandra/pull/1276#discussion_r758238981



##########
File path: src/java/org/apache/cassandra/io/sstable/SequenceBasedSSTableUniqueIdentifier.java
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.io.sstable;
+
+import java.nio.ByteBuffer;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Generation identifier based on sequence of integers.
+ * This has been the standard implementation in C* since inception.
+ */
+public class SequenceBasedSSTableUniqueIdentifier implements SSTableUniqueIdentifier
+{
+    public final int generation;
+
+    public SequenceBasedSSTableUniqueIdentifier(final int generation)
+    {
+        assert generation >= 0;
+
+        this.generation = generation;
+    }
+
+    @Override
+    public int compareTo(SSTableUniqueIdentifier o)
+    {
+        if (o instanceof SequenceBasedSSTableUniqueIdentifier)
+            return Integer.compare(this.generation, ((SequenceBasedSSTableUniqueIdentifier) o).generation);
+
+        return -1;
+    }

Review comment:
       Ok, I'll move it to a separate comparator and remove `Comparable` from the interfaces inherited by `SSTableUniqueIdentifier`




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