Skip to content

Commit

Permalink
src
Browse files Browse the repository at this point in the history
  • Loading branch information
smiklosovic committed Aug 10, 2023
1 parent 7022d1a commit 461e25d
Show file tree
Hide file tree
Showing 11 changed files with 362 additions and 266 deletions.
1 change: 1 addition & 0 deletions .build/build-rat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<exclude name="**/doc/antora.yml"/>
<exclude name="**/test/conf/cassandra.yaml"/>
<exclude name="**/test/conf/cassandra-old.yaml"/>
<exclude name="**/test/conf/cassandra-with-sstable-compressor.yaml"/>
<exclude name="**/test/conf/cassandra-converters-special-cases-old-names.yaml"/>
<exclude name="**/test/conf/cassandra-converters-special-cases.yaml"/>
<exclude name="**/test/conf/cassandra_encryption.yaml"/>
Expand Down
44 changes: 44 additions & 0 deletions conf/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,50 @@ commitlog_segment_size: 32MiB
#
# flush_compression: fast

# Defines the default compression used on tables when none is specified
# in the CQL command.
#
# The class_name is the compressor class name. It may be one of the aliases,
# the class name of a system ICompressor implementation, or fully qualified
# name of a class that implements ICompressor and has a public static 'create' method that accepts
# a Map<String, String> argument and returns an instance of the class.
#
# class aliases are:
# Alias System compressor impl.
# deflate DeflateCompressor
# lz4 LZ4Compressor
# none (null) -- compresson disabled
# noop NoopCompressor
# snappy SnappyCompressor
# zstd ZstdCompressor
#
# The standard parameters are any required or optional parameter for the instantiation of the
# specified class, or one of the following standard parameters:
# Parameter Usage
# enabled Disables compression if set to false. Defaults to true.
# chunk_length The length of the compresson chunks, must include KiB, MiB or GiB suffix, defaults to 16KiB.
# chunk_length_in_kb Same as above but expects an integer.
# min_compress_ratio The minimal acceptable compression, must greater than or equal to 1.0.
# max_compressed_length The maximum size for a compressed block. Must be less than or equal to chunk_length.
# Must include KiB, MiB or GiB suffix. Defaults to Integer.MAX_VALUE
#
# Only one of the min_compress_ratio and max_compressed_length options can be specified.
# They are mathematically related in that 'chunk_length / max_compressed_length = min_compress_ratio'.
# If neither option is specified a min_compress_ratio of 0.0 and a max_compressed_length of
# Integer.MAX_VALUE KB is the default.
#
# Only one of chunk_length or chunk_length_in_kb may be specified.
#
# Additional class specific parameters may be added to the parameters section. The value of the class specific
# parameter must be a string.
#
#sstable_compression:
# - class_name: lz4
# parameters:
# - enabled: "true"
# chunk_length: 16KiB
# max_compressed_length: 16KiB

# any class that implements the SeedProvider interface and has a
# constructor that takes a Map<String, String> of parameters will do.
seed_provider:
Expand Down
6 changes: 3 additions & 3 deletions pylib/cqlshlib/cql3handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet):
('class', 'max_threshold', 'tombstone_compaction_interval', 'tombstone_threshold', 'enabled',
'unchecked_tombstone_compaction', 'only_purge_repaired_tombstones', 'provide_overlapping_tombstones')),
('compression', 'compression_parameters',
('sstable_compression', 'chunk_length_kb', 'crc_check_chance')),
('class', 'chunk_length', 'chunk_length_in_kb', 'crc_check_chance', 'enabled', 'min_compress_ratio', 'max_compressed_length')),
('caching', None,
('rows_per_partition', 'keys')),
)
Expand Down Expand Up @@ -498,7 +498,7 @@ def cf_prop_val_completer(ctxt, cass):
exist_opts = ctxt.get_binding('propname')
this_opt = exist_opts[-1]
if this_opt == 'compression':
return ["{'sstable_compression': '"]
return ["{'class': '"]
if this_opt == 'compaction':
return ["{'class': '"]
if this_opt == 'caching':
Expand Down Expand Up @@ -563,7 +563,7 @@ def cf_prop_val_mapval_completer(ctxt, cass):
return [Hint('<NONE|ROW|CELL>')]
return [Hint('<option_value>')]
elif opt == 'compression':
if key == 'sstable_compression':
if key == 'class':
return list(map(escape_value, CqlRuleSet.available_compression_classes))
return [Hint('<option_value>')]
elif opt == 'caching':
Expand Down
3 changes: 3 additions & 0 deletions src/java/org/apache/cassandra/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,9 @@ public enum PaxosOnLinearizabilityViolation
*/
public ParameterizedClass default_compaction = null;

@Nullable
public ParameterizedClass sstable_compression;

public static Supplier<Config> getOverrideLoadConfig()
{
return overrideLoadConfig;
Expand Down
16 changes: 15 additions & 1 deletion src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ public class DatabaseDescriptor
private static ImmutableMap<String, SSTableFormat<?, ?>> sstableFormats;
private static volatile SSTableFormat<?, ?> selectedSSTableFormat;

private static ParameterizedClass sstableCompression;

private static Function<CommitLog, AbstractCommitLogSegmentManager> commitLogSegmentMgrProvider = c -> DatabaseDescriptor.isCDCEnabled()
? new CommitLogSegmentManagerCDC(c, DatabaseDescriptor.getCommitLogLocation())
: new CommitLogSegmentManagerStandard(c, DatabaseDescriptor.getCommitLogLocation());
Expand Down Expand Up @@ -867,7 +869,7 @@ else if (conf.repair_session_space.toMebibytes() > (int) (Runtime.getRuntime().m
if (conf.allow_extra_insecure_udfs)
logger.warn("Allowing java.lang.System.* access in UDFs is dangerous and not recommended. Set allow_extra_insecure_udfs: false to disable.");

if(conf.scripted_user_defined_functions_enabled)
if (conf.scripted_user_defined_functions_enabled)
throw new ConfigurationException("JavaScript user-defined functions were removed in CASSANDRA-18252. " +
"Hooks are planned to be introduced as part of CASSANDRA-17280");

Expand Down Expand Up @@ -966,6 +968,8 @@ else if (conf.max_value_size.toMebibytes() >= 2048)
if (conf.paxos_state_purging == null)
conf.paxos_state_purging = PaxosStatePurging.legacy;

sstableCompression = conf.sstable_compression;

logInitializationOutcome(logger);

if (conf.max_space_usable_for_compactions_in_percentage < 0 || conf.max_space_usable_for_compactions_in_percentage > 1)
Expand Down Expand Up @@ -2569,6 +2573,16 @@ public static void setFlushCompression(Config.FlushCompression compression)
conf.flush_compression = compression;
}

public static ParameterizedClass getSSTableCompression()
{
return sstableCompression;
}

public static void setSSTableCompression(ParameterizedClass compressor)
{
conf.sstable_compression = compressor;
}

/**
* Maximum number of buffers in the compression pool. The default value is 3, it should not be set lower than that
* (one segment in compression, one written to, one in reserve); delays in compression may cause the log to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static CompressionParams buildCompressionParams(TableMetadata metadata,
if (!compressor.recommendedUses().contains(ICompressor.Uses.FAST_COMPRESSION))
{
// The default compressor is generally fast (LZ4 with 16KiB block size)
compressionParams = CompressionParams.DEFAULT;
compressionParams = CompressionParams.defaultParams();
break;
}
// else fall through
Expand Down
Loading

0 comments on commit 461e25d

Please sign in to comment.