Skip to content

Commit 10bf347

Browse files
committed
moved definition in yaml file, reverted MessagingService version checks
1 parent 13e50a9 commit 10bf347

File tree

6 files changed

+66
-69
lines changed

6 files changed

+66
-69
lines changed

conf/cassandra.yaml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -646,46 +646,6 @@ commitlog_disk_access_mode: legacy
646646
#
647647
# flush_compression: fast
648648

649-
# Defines the default compression used on tables when none is specified
650-
# in the CQL command.
651-
#
652-
# The class_name is the compressor class name. It may be one of the aliases,
653-
# the class name of a system ICompressor implementation, or fully qualified
654-
# name of a ICompressor class.
655-
#
656-
# class aliases are:
657-
# Alias System compressor impl.
658-
# deflate DeflateCompressor
659-
# lz4 LZ4Compressor
660-
# none (null) -- compresson disabled
661-
# noop NoopCompressor
662-
# snappy SnappyCompressor
663-
# zstd ZstdCompressor
664-
#
665-
# The standard parameters are any required or optional parameter for the instantiation of the
666-
# specified class, or one of the following standard parameters:
667-
# Parameter Usage
668-
# enabled Disables compression if set to false. Defaults to true.
669-
# chunk_length The length of the compresson chunks, must include KiB, MiB or GiB suffix, defaults to 16KiB.
670-
# min_compress_ratio The minimal acceptable compression, must greater than or equal to 1.0.
671-
# max_compressed_length The maximum size for a compressed block. Must be less than or equal to chunk_length.
672-
# Must include KiB, MiB or GiB suffix. Defaults to Integer.MAX_VALUE
673-
#
674-
# Only one of the min_compress_ratio and max_compressed_length options can be specified.
675-
# They are mathematically related in that 'chunk_length / max_compressed_length = min_compress_ratio'.
676-
# If neither option is specified a min_compress_ratio of 0.0 and a max_compressed_length of
677-
# Integer.MAX_VALUE KB is the default.
678-
#
679-
# Additional class specific parameters may be added to the parameters section. The value of the class specific
680-
# parameter must be a string.
681-
#
682-
#sstable_compression:
683-
# - class_name: lz4
684-
# parameters:
685-
# - enabled: "true"
686-
# chunk_length: 16KiB
687-
# max_compressed_length: 16KiB
688-
689649
# any class that implements the SeedProvider interface and has a
690650
# constructor that takes a Map<String, String> of parameters will do.
691651
seed_provider:
@@ -1153,6 +1113,46 @@ snapshot_links_per_second: 0
11531113
#sstable:
11541114
# selected_format: big
11551115

1116+
# Defines the default compression used on tables when none is specified
1117+
# in the CQL command.
1118+
#
1119+
# The class_name is the compressor class name. It may be one of the aliases,
1120+
# the class name of a system ICompressor implementation, or fully qualified
1121+
# name of a ICompressor class.
1122+
#
1123+
# class aliases are:
1124+
# Alias System compressor impl.
1125+
# deflate DeflateCompressor
1126+
# lz4 LZ4Compressor
1127+
# none (null) -- compresson disabled
1128+
# noop NoopCompressor
1129+
# snappy SnappyCompressor
1130+
# zstd ZstdCompressor
1131+
#
1132+
# The standard parameters are any required or optional parameter for the instantiation of the
1133+
# specified class, or one of the following standard parameters:
1134+
# Parameter Usage
1135+
# enabled Disables compression if set to false. Defaults to true.
1136+
# chunk_length The length of the compresson chunks, must include KiB, MiB or GiB suffix, defaults to 16KiB.
1137+
# min_compress_ratio The minimal acceptable compression, must greater than or equal to 1.0.
1138+
# max_compressed_length The maximum size for a compressed block. Must be less than or equal to chunk_length.
1139+
# Must include KiB, MiB or GiB suffix. Defaults to Integer.MAX_VALUE
1140+
#
1141+
# Only one of the min_compress_ratio and max_compressed_length options can be specified.
1142+
# They are mathematically related in that 'chunk_length / max_compressed_length = min_compress_ratio'.
1143+
# If neither option is specified a min_compress_ratio of 0.0 and a max_compressed_length of
1144+
# Integer.MAX_VALUE KB is the default.
1145+
#
1146+
# Additional class specific parameters may be added to the parameters section. The value of the class specific
1147+
# parameter must be a string.
1148+
#
1149+
# sstable_compression:
1150+
# - class_name: lz4
1151+
# parameters:
1152+
# - enabled: "true"
1153+
# chunk_length: 16KiB
1154+
# max_compressed_length: 16KiB
1155+
11561156
# Granularity of the collation index of rows within a partition.
11571157
# Applies to both BIG and BTI SSTable formats. In both formats,
11581158
# a smaller granularity results in faster lookup of rows within

src/java/org/apache/cassandra/config/Config.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ public static class SSTableConfig
371371
{
372372
public String selected_format = BigFormat.NAME;
373373
public Map<String, Map<String, String>> format = new HashMap<>();
374+
375+
@Nullable
376+
public ParameterizedClass default_compression;
374377
}
375378

376379
public final SSTableConfig sstable = new SSTableConfig();
@@ -1126,9 +1129,6 @@ public enum PaxosOnLinearizabilityViolation
11261129
*/
11271130
public ParameterizedClass default_compaction = null;
11281131

1129-
@Nullable
1130-
public ParameterizedClass sstable_compression;
1131-
11321132
public static Supplier<Config> getOverrideLoadConfig()
11331133
{
11341134
return overrideLoadConfig;

src/java/org/apache/cassandra/config/DatabaseDescriptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ else if (conf.max_value_size.toMebibytes() >= 2048)
977977
if (conf.paxos_state_purging == null)
978978
conf.paxos_state_purging = PaxosStatePurging.legacy;
979979

980-
sstableCompression = conf.sstable_compression;
980+
sstableCompression = conf.sstable.default_compression;
981981

982982
logInitializationOutcome(logger);
983983

@@ -2677,7 +2677,7 @@ public static ParameterizedClass getSSTableCompression()
26772677

26782678
public static void setSSTableCompression(ParameterizedClass compressor)
26792679
{
2680-
conf.sstable_compression = compressor;
2680+
conf.sstable.default_compression = compressor;
26812681
}
26822682

26832683
/**

src/java/org/apache/cassandra/schema/CompressionParams.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ static class Serializer implements IVersionedSerializer<CompressionParams>
651651
{
652652
public void serialize(CompressionParams parameters, DataOutputPlus out, int version) throws IOException
653653
{
654+
assert version >= MessagingService.VERSION_40;
654655
out.writeUTF(parameters.sstableCompressor.getClass().getSimpleName());
655656
out.writeInt(parameters.otherOptions.size());
656657
for (Map.Entry<String, String> entry : parameters.otherOptions.entrySet())
@@ -659,15 +660,12 @@ public void serialize(CompressionParams parameters, DataOutputPlus out, int vers
659660
out.writeUTF(entry.getValue());
660661
}
661662
out.writeInt(parameters.chunkLength());
662-
if (version >= MessagingService.VERSION_40)
663-
out.writeInt(parameters.maxCompressedLength);
664-
else
665-
if (parameters.maxCompressedLength != Integer.MAX_VALUE)
666-
throw new UnsupportedOperationException("Cannot stream SSTables with uncompressed chunks to pre-4.0 nodes.");
663+
out.writeInt(parameters.maxCompressedLength);
667664
}
668665

669666
public CompressionParams deserialize(DataInputPlus in, int version) throws IOException
670667
{
668+
assert version >= MessagingService.VERSION_40;
671669
String compressorName = in.readUTF();
672670
int optionCount = in.readInt();
673671
Map<String, String> options = new HashMap<>();
@@ -678,9 +676,7 @@ public CompressionParams deserialize(DataInputPlus in, int version) throws IOExc
678676
options.put(key, value);
679677
}
680678
int chunkLength = in.readInt();
681-
int minCompressRatio = Integer.MAX_VALUE; // Earlier Cassandra cannot use uncompressed chunks.
682-
if (version >= MessagingService.VERSION_40)
683-
minCompressRatio = in.readInt();
679+
int minCompressRatio = in.readInt();
684680

685681
CompressionParams parameters;
686682
try
@@ -696,6 +692,7 @@ public CompressionParams deserialize(DataInputPlus in, int version) throws IOExc
696692

697693
public long serializedSize(CompressionParams parameters, int version)
698694
{
695+
assert version >= MessagingService.VERSION_40;
699696
long size = TypeSizes.sizeof(parameters.sstableCompressor.getClass().getSimpleName());
700697
size += TypeSizes.sizeof(parameters.otherOptions.size());
701698
for (Map.Entry<String, String> entry : parameters.otherOptions.entrySet())
@@ -704,8 +701,7 @@ public long serializedSize(CompressionParams parameters, int version)
704701
size += TypeSizes.sizeof(entry.getValue());
705702
}
706703
size += TypeSizes.sizeof(parameters.chunkLength());
707-
if (version >= MessagingService.VERSION_40)
708-
size += TypeSizes.sizeof(parameters.maxCompressedLength());
704+
size += TypeSizes.sizeof(parameters.maxCompressedLength());
709705
return size;
710706
}
711707
}

test/conf/cassandra-with-sstable-compressor.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ memtable:
101101
test_invalid_factory_field:
102102
class_name: org.apache.cassandra.cql3.validation.operations.CreateTest$InvalidMemtableFactoryField
103103

104-
sstable_compression:
105-
class_name: lz4
106-
parameters:
107-
lz4_compressor_type: high
108-
lz4_high_compressor_level: "8"
109-
chunk_length: 32MiB
110-
min_compress_ratio: "1.5"
104+
sstable:
105+
default_compression:
106+
class_name: lz4
107+
parameters:
108+
lz4_compressor_type: high
109+
lz4_high_compressor_level: "8"
110+
chunk_length: 32MiB
111+
min_compress_ratio: "1.5"

test/unit/org/apache/cassandra/config/YamlConfigurationLoaderTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,16 @@ public void readSSTableCompressionFromConfig()
223223
{
224224
Config c = load("test/conf/cassandra.yaml");
225225

226-
assertNull(c.sstable_compression);
226+
assertNull(c.sstable.default_compression);
227227

228228
c = load("test/conf/cassandra-with-sstable-compressor.yaml");
229229

230-
assertNotNull(c.sstable_compression);
231-
assertThat(c.sstable_compression.class_name).isEqualTo("lz4");
232-
assertThat(c.sstable_compression.parameters.remove(CompressionParams.CHUNK_LENGTH)).isEqualTo("32MiB");
233-
assertThat(c.sstable_compression.parameters.remove(CompressionParams.MIN_COMPRESS_RATIO)).isEqualTo("1.5");
234-
assertThat(c.sstable_compression.parameters.remove(CompressionParams.ENABLED)).isNull();
235-
assertThat(c.sstable_compression.parameters.size()).isEqualTo(2);
230+
assertNotNull(c.sstable.default_compression);
231+
assertThat(c.sstable.default_compression.class_name).isEqualTo("lz4");
232+
assertThat(c.sstable.default_compression.parameters.remove(CompressionParams.CHUNK_LENGTH)).isEqualTo("32MiB");
233+
assertThat(c.sstable.default_compression.parameters.remove(CompressionParams.MIN_COMPRESS_RATIO)).isEqualTo("1.5");
234+
assertThat(c.sstable.default_compression.parameters.remove(CompressionParams.ENABLED)).isNull();
235+
assertThat(c.sstable.default_compression.parameters.size()).isEqualTo(2);
236236
}
237237

238238
@Test

0 commit comments

Comments
 (0)