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


##########
src/java/org/apache/cassandra/schema/CompressionParams.java:
##########
@@ -402,29 +411,47 @@ private static Integer parseChunkLength(String 
chLengthKB) throws ConfigurationE
      */
     private static int removeChunkLength(Map<String, String> options)
     {
-        if (options.containsKey(CHUNK_LENGTH_IN_KB))
-        {
-            if (options.containsKey(CHUNK_LENGTH_KB))
+        Integer chunk_length_in_kb = null;
+        String key = null;
+        if (options.containsKey(CHUNK_LENGTH)) {
+            key = CHUNK_LENGTH;
+            String value = options.remove(CHUNK_LENGTH);
+            try
             {
-                throw new ConfigurationException(format("The '%s' option must 
not be used if the chunk length is already specified by the '%s' option",
-                                                        CHUNK_LENGTH_KB,
-                                                        CHUNK_LENGTH_IN_KB));
+                chunk_length_in_kb =  new 
DataStorageSpec.IntKibibytesBound(value).toKibibytes();
+            } catch (IllegalArgumentException e) {
+                throw new ConfigurationException(invalidValue(CHUNK_LENGTH, 
e.getMessage(), value));
             }
-
-            return parseChunkLength(options.remove(CHUNK_LENGTH_IN_KB));
         }
 
-        if (options.containsKey(CHUNK_LENGTH_KB))
+        if (options.containsKey(CHUNK_LENGTH_IN_KB))
         {
-            if (!hasLoggedChunkLengthWarning)
+            key = CHUNK_LENGTH_IN_KB;
+            if (chunk_length_in_kb != null)
+                throw new ConfigurationException(TOO_MANY_CHUNK_LENGTH);
+            else
             {
-                hasLoggedChunkLengthWarning = true;
-                logger.warn("The {} option has been deprecated. You should use 
{} instead",
-                                   CHUNK_LENGTH_KB,
-                                   CHUNK_LENGTH_IN_KB);
+                String chLengthKB = options.remove(CHUNK_LENGTH_IN_KB);
+                try
+                {
+                    int parsed = Integer.parseInt(chLengthKB);
+                    if (parsed > Integer.MAX_VALUE / 1024)
+                        throw new 
ConfigurationException(invalidValue(CHUNK_LENGTH_IN_KB, "Value is too large", 
parsed));
+                    if (parsed <= 0)
+                        throw new 
ConfigurationException(invalidValue(CHUNK_LENGTH_IN_KB, "May not be <= 0", 
parsed));
+                    chunk_length_in_kb = 1024 * parsed;
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new 
ConfigurationException(invalidValue(CHUNK_LENGTH_IN_KB, e.getMessage(), 
chLengthKB));
+                }
             }
+        }
 
-            return parseChunkLength(options.remove(CHUNK_LENGTH_KB));
+        if (chunk_length_in_kb != null) {

Review Comment:
   nit: brace on newline.



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