smiklosovic commented on code in PR #2254:
URL: https://github.com/apache/cassandra/pull/2254#discussion_r1176661551
##########
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()) {
Review Comment:
We could quickly return null if `name` is null so we are not looping
unnecessarily.
--
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]