yifan-c commented on code in PR #4642:
URL: https://github.com/apache/cassandra/pull/4642#discussion_r2870642064


##########
src/java/org/apache/cassandra/db/compression/CompressionDictionaryManager.java:
##########
@@ -464,7 +464,15 @@ private int 
internalTrainingParameterResolution(CompressionParams compressionPar
             else
                 resolvedValue = userSuppliedValue;
 
-            return new 
DataStorageSpec.IntKibibytesBound(resolvedValue).toBytes();
+            DataStorageSpec.IntKibibytesBound bound = new 
DataStorageSpec.IntKibibytesBound(resolvedValue);
+
+            if (bound.toBytesInLong() == 0)
+                throw new IllegalArgumentException("can not be equal to 0 
bytes.");
+
+            if (bound.toBytesInLong() > Integer.MAX_VALUE)
+                throw new IllegalArgumentException("can not be bigger than " + 
Integer.MAX_VALUE + " bytes.");
+
+            return bound.toBytes();

Review Comment:
   Instead of having the value range validation in this method and the other 
source files. You can create `DataStorageSpec.IntBytesBound` instead. 
   
   For example, keep the one-liner here.
   ```java
   return new DataStorageSpec.IntBytesBound(resolvedValue).toBytes();
   ```



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