blambov commented on code in PR #2064:
URL: https://github.com/apache/cassandra/pull/2064#discussion_r1088788127


##########
src/java/org/apache/cassandra/io/sstable/Component.java:
##########
@@ -35,43 +41,49 @@
 {
     public static final char separator = '-';
 
-    final static EnumSet<Type> TYPES = EnumSet.allOf(Type.class);
+    final static ImmutableSet<Type> TYPES = Type.all;
 
     /**
      * WARNING: Be careful while changing the names or string representation 
of the enum
      * members. Streaming code depends on the names during streaming (Ref: 
CASSANDRA-14556).
      */
-    public enum Type
+    public static class Type
     {
+        private final static List<Type> singletonsCollector = new 
ArrayList<>(11);
         // the base data for an sstable: the remaining components can be 
regenerated
         // based on the data component
-        DATA("Data.db"),
-        // index of the row keys with pointers to their positions in the data 
file
-        PRIMARY_INDEX("Index.db"),
-        // serialized bloom filter for the row keys in the sstable
-        FILTER("Filter.db"),
+        public static final Type DATA = new Type("DATA", "Data.db", name -> 
Component.DATA);
         // file to hold information about uncompressed data length, chunk 
offsets etc.
-        COMPRESSION_INFO("CompressionInfo.db"),
+        public static final Type COMPRESSION_INFO = new 
Type("COMPRESSION_INFO", "CompressionInfo.db", name -> 
Component.COMPRESSION_INFO);
         // statistical metadata about the content of the sstable
-        STATS("Statistics.db"),
+        public static final Type STATS = new Type("STATS", "Statistics.db", 
name -> Component.STATS);
+        // serialized bloom filter for the row keys in the sstable
+        public static final Type FILTER = new Type("FILTER", "Filter.db", name 
-> Component.FILTER);
         // holds CRC32 checksum of the data file
-        DIGEST("Digest.crc32"),
+        public static final Type DIGEST = new Type("DIGEST","Digest.crc32", 
name -> Component.DIGEST);
         // holds the CRC32 for chunks in an a uncompressed file.
-        CRC("CRC.db"),
-        // holds SSTable Index Summary (sampling of Index component)
-        SUMMARY("Summary.db"),
+        public static final Type CRC = new Type("CRC","CRC.db", name -> 
Component.CRC);
         // table of contents, stores the list of all components for the sstable
-        TOC("TOC.txt"),
+        public static final Type TOC = new Type("TOC","TOC.txt", name -> 
Component.TOC);
         // built-in secondary index (may be multiple per sstable)
-        SECONDARY_INDEX("SI_.*.db"),
+        public static final Type SECONDARY_INDEX = new 
Type("SECONDARY_INDEX","SI_.*.db", name -> new Component(Type.SECONDARY_INDEX, 
name));
         // custom component, used by e.g. custom compaction strategy
-        CUSTOM(null);
+        public static final Type CUSTOM = new Type("CUSTOM",null, name -> new 
Component(Type.CUSTOM, name));
 
-        final String repr;
+        public static final ImmutableSet<Type> all = 
ImmutableSet.copyOf(singletonsCollector);

Review Comment:
   This being final and immutable means we can't register a new type, doesn't 
it?
   
   E.g. the `BigComponentType`s probably aren't here.
   
   Perhaps wrap it an `UnmodifiableSet` like the components?



##########
src/java/org/apache/cassandra/io/util/MmappedRegions.java:
##########
@@ -140,6 +147,25 @@ public void extend(long length)
         copy = new State(state);
     }
 
+    public void extend(CompressionMetadata compressionMetadata)
+    {
+        assert !isCopy() : "Copies cannot be extended";
+
+        if (compressionMetadata.dataLength <= state.length)

Review Comment:
   Nit: there should be a comment why `dataLength` is used here and 
`compressedFileLength` below. (If I'm not mistaken the data length might be 
truncated to shorter than the end of the last chunk, while we do want to map 
the whole chunk to be able to read it).



##########
src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java:
##########
@@ -1415,7 +1418,7 @@ public boolean 
mayContainAssumingKeyIsInRange(DecoratedKey key)
     protected static final class InstanceTidier implements Tidy
     {
         private final Descriptor descriptor;
-        private final TableId tableId;
+        private final Owner owner;

Review Comment:
   Does it make sense for this to be a weak reference? Can the CFS be collected 
before the sstables?



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