smiklosovic commented on code in PR #2254:
URL: https://github.com/apache/cassandra/pull/2254#discussion_r1176679835


##########
src/java/org/apache/cassandra/schema/CompressionParams.java:
##########
@@ -97,128 +109,185 @@
     // TODO: deprecated, should now be carefully removed. Doesn't affect 
schema code as it isn't included in equals() and hashCode()
     private volatile double crcCheckChance = 1.0;
 
-    public static CompressionParams fromMap(Map<String, String> opts)
-    {
-        Map<String, String> options = copyOptions(opts);
-
-        String sstableCompressionClass;
-
-        if (!opts.isEmpty() && isEnabled(opts) && 
!containsSstableCompressionClass(opts))
-            throw new ConfigurationException(format("Missing sub-option '%s' 
for the 'compression' option.", CLASS));
 
-        if (!removeEnabled(options))
-        {
-            sstableCompressionClass = null;
+    public enum CompressorType
+    {
+        lz4("LZ4Compressor"),
+        none(null),
+        noop("NoopCompressor"),
+        snappy("SnappyCompressor"),
+        deflate("DeflateCompressor"),
+        zstd("ZstdCompressor");
 
-            if (!options.isEmpty())
-                throw new ConfigurationException(format("If the '%s' option is 
set to false no other options must be specified", ENABLED));
-        }
-        else
-        {
-            sstableCompressionClass = removeSstableCompressionClass(options);
+        String className;
+        CompressorType(String className) {
+            this.className = className;
         }
 
-        int chunkLength = removeChunkLength(options);
-        double minCompressRatio = removeMinCompressRatio(options);
-
-        CompressionParams cp = new CompressionParams(sstableCompressionClass, 
options, chunkLength, minCompressRatio);
-        cp.validate();
-
-        return cp;
+        static CompressorType forClass(String name) {
+            for (CompressorType type : CompressorType.values()) {
+                if (Objects.equal(type.className, name)) {
+                    return type;
+                }
+            }
+            return null;
+        }
     }
 
-    public Class<? extends ICompressor> klass()
+    public static CompressionParams defaultParams()
     {
-        return sstableCompressor.getClass();
+        return 
fromParameterizedClass(DatabaseDescriptor.getSSTableCompressionOptions());
     }
 
-    public static CompressionParams noCompression()
+    public static CompressionParams fromParameterizedClass(ParameterizedClass 
options)
     {
-        return new CompressionParams((ICompressor) null, DEFAULT_CHUNK_LENGTH, 
Integer.MAX_VALUE, 0.0, Collections.emptyMap());
-    }
+        if (options == null)
+        {

Review Comment:
   braces around one return statement are not necessary, are they?



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