Remove deprecated properties in CompressionParams

This patch removes deprecated chunk_length_kb and sstable_compression in favor of
chunk_length_in_kb and class parameters.

The only deprecated compression parameter left, crc_check_chance (which is configurable outside
of compression parameters as a standalone table parameter) is meant to be treated separately.

patch by Stefan Miklosovic; reviewed by Maxim Muzafarov and Brandon Williams for CASSANDRA-18742
This commit is contained in:
Stefan Miklosovic 2023-09-18 14:45:03 +02:00
parent 6de90bf75c
commit b9f614f7e5
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
14 changed files with 40 additions and 117 deletions

View File

@ -1,4 +1,5 @@
5.0-alpha2 5.0-alpha2
* Remove deprecated properties in CompressionParams (CASSANDRA-18742)
* Add support for repair coordinator to retry messages that timeout (CASSANDRA-18816) * Add support for repair coordinator to retry messages that timeout (CASSANDRA-18816)
* Upgrade slf4j-api to 1.7.36 (CASSANDRA-18882) * Upgrade slf4j-api to 1.7.36 (CASSANDRA-18882)
* Make the output of ON/OFF commands in cqlsh consistent (CASSANDRA-18547) * Make the output of ON/OFF commands in cqlsh consistent (CASSANDRA-18547)

View File

@ -225,6 +225,7 @@ Upgrading
- `commitlog_sync_batch_window_in_ms` configuration property in cassandra.yaml was removed. Please ensure your configuration is not using this property. - `commitlog_sync_batch_window_in_ms` configuration property in cassandra.yaml was removed. Please ensure your configuration is not using this property.
- The pluggable metrics reporter called metrics-reporter-config is removed. The way that metrics can be exported is - The pluggable metrics reporter called metrics-reporter-config is removed. The way that metrics can be exported is
fully covered by the dropwizard metrics library itself, using e.g. CsvReporter. See CASSANDRA-18743 for more details. fully covered by the dropwizard metrics library itself, using e.g. CsvReporter. See CASSANDRA-18743 for more details.
- Deprecated CQL compression parameters for table, `sstable_compression` and `chunk_length_kb`, were removed. Please use `class` and `chunk_length_in_kb` instead.
Deprecation Deprecation

View File

@ -66,7 +66,7 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet):
('class', 'max_threshold', 'tombstone_compaction_interval', 'tombstone_threshold', 'enabled', ('class', 'max_threshold', 'tombstone_compaction_interval', 'tombstone_threshold', 'enabled',
'unchecked_tombstone_compaction', 'only_purge_repaired_tombstones', 'provide_overlapping_tombstones')), 'unchecked_tombstone_compaction', 'only_purge_repaired_tombstones', 'provide_overlapping_tombstones')),
('compression', 'compression_parameters', ('compression', 'compression_parameters',
('sstable_compression', 'chunk_length_kb', 'crc_check_chance')), ('class', 'chunk_length_in_kb', 'enabled', 'min_compress_ratio', 'max_compressed_length')),
('caching', None, ('caching', None,
('rows_per_partition', 'keys')), ('rows_per_partition', 'keys')),
) )
@ -500,7 +500,7 @@ def cf_prop_val_completer(ctxt, cass):
exist_opts = ctxt.get_binding('propname') exist_opts = ctxt.get_binding('propname')
this_opt = exist_opts[-1] this_opt = exist_opts[-1]
if this_opt == 'compression': if this_opt == 'compression':
return ["{'sstable_compression': '"] return ["{'class': '"]
if this_opt == 'compaction': if this_opt == 'compaction':
return ["{'class': '"] return ["{'class': '"]
if this_opt == 'caching': if this_opt == 'caching':
@ -565,7 +565,7 @@ def cf_prop_val_mapval_completer(ctxt, cass):
return [Hint('<NONE|ROW|CELL>')] return [Hint('<NONE|ROW|CELL>')]
return [Hint('<option_value>')] return [Hint('<option_value>')]
elif opt == 'compression': elif opt == 'compression':
if key == 'sstable_compression': if key == 'class':
return list(map(escape_value, CqlRuleSet.available_compression_classes)) return list(map(escape_value, CqlRuleSet.available_compression_classes))
return [Hint('<option_value>')] return [Hint('<option_value>')]
elif opt == 'caching': elif opt == 'caching':

View File

@ -34,7 +34,7 @@ CREATE TABLE has_all_types (
uuidcol uuid, uuidcol uuid,
varcharcol varchar, varcharcol varchar,
varintcol varint varintcol varint
) WITH compression = {'sstable_compression':'LZ4Compressor'}; ) WITH compression = {'class':'LZ4Compressor'};
INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol, INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol,
decimalcol, doublecol, durationcol, floatcol, smallintcol, textcol, decimalcol, doublecol, durationcol, floatcol, smallintcol, textcol,

View File

@ -50,8 +50,6 @@ public final class CompressionParams
{ {
private static final Logger logger = LoggerFactory.getLogger(CompressionParams.class); private static final Logger logger = LoggerFactory.getLogger(CompressionParams.class);
private static volatile boolean hasLoggedSsTableCompressionWarning;
private static volatile boolean hasLoggedChunkLengthWarning;
private static volatile boolean hasLoggedCrcCheckChanceWarning; private static volatile boolean hasLoggedCrcCheckChanceWarning;
public static final int DEFAULT_CHUNK_LENGTH = 1024 * 16; public static final int DEFAULT_CHUNK_LENGTH = 1024 * 16;
@ -83,8 +81,6 @@ public final class CompressionParams
private static final String CRC_CHECK_CHANCE_WARNING = "The option crc_check_chance was deprecated as a compression option. " + private static final String CRC_CHECK_CHANCE_WARNING = "The option crc_check_chance was deprecated as a compression option. " +
"You should specify it as a top-level table option instead"; "You should specify it as a top-level table option instead";
@Deprecated public static final String SSTABLE_COMPRESSION = "sstable_compression";
@Deprecated public static final String CHUNK_LENGTH_KB = "chunk_length_kb";
@Deprecated public static final String CRC_CHECK_CHANCE = "crc_check_chance"; @Deprecated public static final String CRC_CHECK_CHANCE = "crc_check_chance";
private final ICompressor sstableCompressor; private final ICompressor sstableCompressor;
@ -102,20 +98,13 @@ public final class CompressionParams
String sstableCompressionClass; String sstableCompressionClass;
if (!opts.isEmpty() && isEnabled(opts) && !containsSstableCompressionClass(opts)) if (!opts.isEmpty() && isEnabled(opts) && !options.containsKey(CLASS))
throw new ConfigurationException(format("Missing sub-option '%s' for the 'compression' option.", CLASS)); throw new ConfigurationException(format("Missing sub-option '%s' for the 'compression' option.", CLASS));
if (!removeEnabled(options)) if (!removeEnabled(options) && !options.isEmpty())
{ throw new ConfigurationException(format("If the '%s' option is set to false no other options must be specified", ENABLED));
sstableCompressionClass = null;
if (!options.isEmpty())
throw new ConfigurationException(format("If the '%s' option is set to false no other options must be specified", ENABLED));
}
else else
{ sstableCompressionClass = removeSSTableCompressionClass(options);
sstableCompressionClass = removeSstableCompressionClass(options);
}
int chunkLength = removeChunkLength(options); int chunkLength = removeChunkLength(options);
double minCompressRatio = removeMinCompressRatio(options); double minCompressRatio = removeMinCompressRatio(options);
@ -133,7 +122,7 @@ public final class CompressionParams
public static CompressionParams noCompression() public static CompressionParams noCompression()
{ {
return new CompressionParams((ICompressor) null, DEFAULT_CHUNK_LENGTH, Integer.MAX_VALUE, 0.0, Collections.emptyMap()); return new CompressionParams(null, DEFAULT_CHUNK_LENGTH, Integer.MAX_VALUE, 0.0, Collections.emptyMap());
} }
// The shorthand methods below are only used for tests. They are a little inconsistent in their choice of // The shorthand methods below are only used for tests. They are a little inconsistent in their choice of
@ -403,29 +392,9 @@ public final class CompressionParams
{ {
if (options.containsKey(CHUNK_LENGTH_IN_KB)) if (options.containsKey(CHUNK_LENGTH_IN_KB))
{ {
if (options.containsKey(CHUNK_LENGTH_KB))
{
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));
}
return parseChunkLength(options.remove(CHUNK_LENGTH_IN_KB)); return parseChunkLength(options.remove(CHUNK_LENGTH_IN_KB));
} }
if (options.containsKey(CHUNK_LENGTH_KB))
{
if (!hasLoggedChunkLengthWarning)
{
hasLoggedChunkLengthWarning = true;
logger.warn("The {} option has been deprecated. You should use {} instead",
CHUNK_LENGTH_KB,
CHUNK_LENGTH_IN_KB);
}
return parseChunkLength(options.remove(CHUNK_LENGTH_KB));
}
return DEFAULT_CHUNK_LENGTH; return DEFAULT_CHUNK_LENGTH;
} }
@ -445,50 +414,25 @@ public final class CompressionParams
return DEFAULT_MIN_COMPRESS_RATIO; return DEFAULT_MIN_COMPRESS_RATIO;
} }
/**
* Returns {@code true} if the specified options contains the name of the compression class to be used,
* {@code false} otherwise.
*
* @param options the options
* @return {@code true} if the specified options contains the name of the compression class to be used,
* {@code false} otherwise.
*/
public static boolean containsSstableCompressionClass(Map<String, String> options)
{
return options.containsKey(CLASS) || options.containsKey(SSTABLE_COMPRESSION);
}
/** /**
* Removes the option specifying the name of the compression class * Removes the option specifying the name of the compression class
* *
* @param options the options * @param options the options
* @return the name of the compression class * @return the name of the compression class
*/ */
private static String removeSstableCompressionClass(Map<String, String> options) private static String removeSSTableCompressionClass(Map<String, String> options)
{ {
if (options.containsKey(CLASS)) if (options.containsKey(CLASS))
{ {
if (options.containsKey(SSTABLE_COMPRESSION))
throw new ConfigurationException(format("The '%s' option must not be used if the compression algorithm is already specified by the '%s' option",
SSTABLE_COMPRESSION,
CLASS));
String clazz = options.remove(CLASS); String clazz = options.remove(CLASS);
if (clazz.isEmpty())
if (clazz == null || clazz.isEmpty())
throw new ConfigurationException(format("The '%s' option must not be empty. To disable compression use 'enabled' : false", CLASS)); throw new ConfigurationException(format("The '%s' option must not be empty. To disable compression use 'enabled' : false", CLASS));
return clazz; return clazz;
} }
if (options.containsKey(SSTABLE_COMPRESSION) && !hasLoggedSsTableCompressionWarning) return null;
{
hasLoggedSsTableCompressionWarning = true;
logger.warn("The {} option has been deprecated. You should use {} instead",
SSTABLE_COMPRESSION,
CLASS);
}
return options.remove(SSTABLE_COMPRESSION);
} }
/** /**

View File

@ -160,7 +160,7 @@ public class PyDtest
query += String.format(" AND CLUSTERING ORDER BY (%s)", clustering); query += String.format(" AND CLUSTERING ORDER BY (%s)", clustering);
if (compression != null) if (compression != null)
query += String.format(" AND compression = { \'sstable_compression\': \'%sCompressor\' }", compression); query += String.format(" AND compression = { \'class\': \'%sCompressor\' }", compression);
else else
query += " AND compression = {}"; query += " AND compression = {}";

View File

@ -203,7 +203,7 @@ public class CachingBenchTest extends CQLTester
DatabaseDescriptor.setFileCacheEnabled(cacheEnabled); DatabaseDescriptor.setFileCacheEnabled(cacheEnabled);
DatabaseDescriptor.setDiskAccessMode(mode); DatabaseDescriptor.setDiskAccessMode(mode);
alterTable("ALTER TABLE %s WITH compaction = { 'class' : '" + compactionClass + "' };"); alterTable("ALTER TABLE %s WITH compaction = { 'class' : '" + compactionClass + "' };");
alterTable("ALTER TABLE %s WITH compression = { 'sstable_compression' : '" + compressorClass + "' };"); alterTable("ALTER TABLE %s WITH compression = { 'class' : '" + compressorClass + "' };");
ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
cfs.disableAutoCompaction(); cfs.disableAutoCompaction();

View File

@ -58,9 +58,9 @@ public class CrcCheckChanceTest extends CQLTester
{ {
//Start with crc_check_chance of 99% //Start with crc_check_chance of 99%
if (newFormat) if (newFormat)
createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c)) WITH compression = {'sstable_compression': 'LZ4Compressor'} AND crc_check_chance = 0.99;"); createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c)) WITH compression = {'class': 'LZ4Compressor'} AND crc_check_chance = 0.99;");
else else
createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c)) WITH compression = {'sstable_compression': 'LZ4Compressor', 'crc_check_chance' : 0.99}"); createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c)) WITH compression = {'class': 'LZ4Compressor', 'crc_check_chance' : 0.99}");
execute("CREATE INDEX foo ON %s(v)"); execute("CREATE INDEX foo ON %s(v)");
@ -82,7 +82,7 @@ public class CrcCheckChanceTest extends CQLTester
if (newFormat) if (newFormat)
alterTable("ALTER TABLE %s WITH crc_check_chance = 0.99"); alterTable("ALTER TABLE %s WITH crc_check_chance = 0.99");
else else
alterTable("ALTER TABLE %s WITH compression = {'sstable_compression': 'LZ4Compressor', 'crc_check_chance': 0.99}"); alterTable("ALTER TABLE %s WITH compression = {'class': 'LZ4Compressor', 'crc_check_chance': 0.99}");
assertRows(execute("SELECT * FROM %s WHERE p=?", "p1"), assertRows(execute("SELECT * FROM %s WHERE p=?", "p1"),
row("p1", "k1", "sv1", "v1"), row("p1", "k1", "sv1", "v1"),
@ -134,7 +134,7 @@ public class CrcCheckChanceTest extends CQLTester
if (newFormat) if (newFormat)
alterTable("ALTER TABLE %s WITH crc_check_chance = 0.5"); alterTable("ALTER TABLE %s WITH crc_check_chance = 0.5");
else else
alterTable("ALTER TABLE %s WITH compression = {'sstable_compression': 'LZ4Compressor', 'crc_check_chance': 0.5}"); alterTable("ALTER TABLE %s WITH compression = {'class': 'LZ4Compressor', 'crc_check_chance': 0.5}");
//We should be able to get the new value by accessing directly the schema metadata //We should be able to get the new value by accessing directly the schema metadata
Assert.assertEquals(0.5, cfs.metadata().params.crcCheckChance, 0.0); Assert.assertEquals(0.5, cfs.metadata().params.crcCheckChance, 0.0);
@ -173,7 +173,7 @@ public class CrcCheckChanceTest extends CQLTester
CompactionManager.instance.disableAutoCompaction(); CompactionManager.instance.disableAutoCompaction();
//Start with crc_check_chance of 99% //Start with crc_check_chance of 99%
createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c)) WITH compression = {'sstable_compression': 'LZ4Compressor', 'crc_check_chance' : 0.99}"); createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c)) WITH compression = {'class': 'LZ4Compressor', 'crc_check_chance' : 0.99}");
ColumnFamilyStore cfs = Keyspace.open(CQLTester.KEYSPACE).getColumnFamilyStore(currentTable()); ColumnFamilyStore cfs = Keyspace.open(CQLTester.KEYSPACE).getColumnFamilyStore(currentTable());

View File

@ -710,18 +710,11 @@ public class AlterTest extends CQLTester
"The 'class' option must not be empty. To disable compression use 'enabled' : false", "The 'class' option must not be empty. To disable compression use 'enabled' : false",
"ALTER TABLE %s WITH compression = { 'class' : ''};"); "ALTER TABLE %s WITH compression = { 'class' : ''};");
assertAlterTableThrowsException(ConfigurationException.class, assertAlterTableThrowsException(ConfigurationException.class,
"If the 'enabled' option is set to false no other options must be specified", "If the 'enabled' option is set to false no other options must be specified",
"ALTER TABLE %s WITH compression = { 'enabled' : 'false', 'class' : 'SnappyCompressor'};"); "ALTER TABLE %s WITH compression = { 'enabled' : 'false', 'class' : 'SnappyCompressor'};");
assertAlterTableThrowsException(ConfigurationException.class,
"The 'sstable_compression' option must not be used if the compression algorithm is already specified by the 'class' option",
"ALTER TABLE %s WITH compression = { 'sstable_compression' : 'SnappyCompressor', 'class' : 'SnappyCompressor'};");
assertAlterTableThrowsException(ConfigurationException.class,
"The 'chunk_length_kb' option must not be used if the chunk length is already specified by the 'chunk_length_in_kb' option",
"ALTER TABLE %s WITH compression = { 'class' : 'SnappyCompressor', 'chunk_length_kb' : 32 , 'chunk_length_in_kb' : 32 };");
assertAlterTableThrowsException(ConfigurationException.class, assertAlterTableThrowsException(ConfigurationException.class,
"Invalid negative min_compress_ratio", "Invalid negative min_compress_ratio",
"ALTER TABLE %s WITH compression = { 'class' : 'SnappyCompressor', 'min_compress_ratio' : -1 };"); "ALTER TABLE %s WITH compression = { 'class' : 'SnappyCompressor', 'min_compress_ratio' : -1 };");

View File

@ -681,25 +681,17 @@ public class CreateTest extends CQLTester
assertSchemaOption("compression", map("chunk_length_in_kb", "32", "class", "org.apache.cassandra.io.compress.SnappyCompressor")); assertSchemaOption("compression", map("chunk_length_in_kb", "32", "class", "org.apache.cassandra.io.compress.SnappyCompressor"));
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))" createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'sstable_compression' : 'SnappyCompressor', 'chunk_length_kb' : 32 };"); + " WITH compression = { 'class' : 'SnappyCompressor', 'min_compress_ratio' : 2 };");
assertSchemaOption("compression", map("chunk_length_in_kb", "32", "class", "org.apache.cassandra.io.compress.SnappyCompressor"));
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'sstable_compression' : 'SnappyCompressor', 'min_compress_ratio' : 2 };");
assertSchemaOption("compression", map("chunk_length_in_kb", "16", "class", "org.apache.cassandra.io.compress.SnappyCompressor", "min_compress_ratio", "2.0")); assertSchemaOption("compression", map("chunk_length_in_kb", "16", "class", "org.apache.cassandra.io.compress.SnappyCompressor", "min_compress_ratio", "2.0"));
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))" createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'sstable_compression' : 'SnappyCompressor', 'min_compress_ratio' : 1 };"); + " WITH compression = { 'class' : 'SnappyCompressor', 'min_compress_ratio' : 1 };");
assertSchemaOption("compression", map("chunk_length_in_kb", "16", "class", "org.apache.cassandra.io.compress.SnappyCompressor", "min_compress_ratio", "1.0")); assertSchemaOption("compression", map("chunk_length_in_kb", "16", "class", "org.apache.cassandra.io.compress.SnappyCompressor", "min_compress_ratio", "1.0"));
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))" createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'sstable_compression' : 'SnappyCompressor', 'min_compress_ratio' : 0 };"); + " WITH compression = { 'class' : 'SnappyCompressor', 'min_compress_ratio' : 0 };");
assertSchemaOption("compression", map("chunk_length_in_kb", "16", "class", "org.apache.cassandra.io.compress.SnappyCompressor")); assertSchemaOption("compression", map("chunk_length_in_kb", "16", "class", "org.apache.cassandra.io.compress.SnappyCompressor"));
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'sstable_compression' : '', 'chunk_length_kb' : 32 };");
assertSchemaOption("compression", map("enabled", "false"));
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))" createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'enabled' : 'false'};"); + " WITH compression = { 'enabled' : 'false'};");
assertSchemaOption("compression", map("enabled", "false")); assertSchemaOption("compression", map("enabled", "false"));
@ -720,14 +712,6 @@ public class CreateTest extends CQLTester
"CREATE TABLE %s (a text, b int, c int, primary key (a, b))" "CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'enabled' : 'false', 'chunk_length_in_kb' : 32};"); + " WITH compression = { 'enabled' : 'false', 'chunk_length_in_kb' : 32};");
assertThrowsConfigurationException("The 'sstable_compression' option must not be used if the compression algorithm is already specified by the 'class' option",
"CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'sstable_compression' : 'SnappyCompressor', 'class' : 'SnappyCompressor'};");
assertThrowsConfigurationException("The 'chunk_length_kb' option must not be used if the chunk length is already specified by the 'chunk_length_in_kb' option",
"CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'class' : 'SnappyCompressor', 'chunk_length_kb' : 32 , 'chunk_length_in_kb' : 32 };");
assertThrowsConfigurationException("chunk_length_in_kb must be a power of 2", assertThrowsConfigurationException("chunk_length_in_kb must be a power of 2",
"CREATE TABLE %s (a text, b int, c int, primary key (a, b))" "CREATE TABLE %s (a text, b int, c int, primary key (a, b))"
+ " WITH compression = { 'class' : 'SnappyCompressor', 'chunk_length_in_kb' : 31 };"); + " WITH compression = { 'class' : 'SnappyCompressor', 'chunk_length_in_kb' : 31 };");

View File

@ -39,7 +39,7 @@ public class GuardrailAllowUncompressedTablesTest extends GuardrailTester
{ {
setGuardrail(true); setGuardrail(true);
String table = createTableName(); String table = createTableName();
schemaChange(String.format("CREATE TABLE %s.%s (k int primary key, v int) WITH compression={'sstable_compression':''}", KEYSPACE, table)); schemaChange(String.format("CREATE TABLE %s.%s (k int primary key, v int) WITH compression={'enabled':false}", KEYSPACE, table));
TableMetadata tmd = Schema.instance.getTableMetadata(KEYSPACE, table); TableMetadata tmd = Schema.instance.getTableMetadata(KEYSPACE, table);
Assert.assertFalse(tmd.params.compression.isEnabled()); Assert.assertFalse(tmd.params.compression.isEnabled());
} }
@ -52,7 +52,7 @@ public class GuardrailAllowUncompressedTablesTest extends GuardrailTester
{ {
setGuardrail(false); setGuardrail(false);
String table = createTableName(); String table = createTableName();
assertFails(String.format("CREATE TABLE %s.%s (k int primary key, v int) WITH compression={'sstable_compression':''}", KEYSPACE, table), "Uncompressed table is not allowed"); assertFails(String.format("CREATE TABLE %s.%s (k int primary key, v int) WITH compression={'enabled': false}", KEYSPACE, table), "Uncompressed table is not allowed");
} }
@Test @Test
@ -61,7 +61,7 @@ public class GuardrailAllowUncompressedTablesTest extends GuardrailTester
setGuardrail(true); setGuardrail(true);
String table = createTableName(); String table = createTableName();
schemaChange(String.format("CREATE TABLE %s.%s (k int primary key, v int)", KEYSPACE, table)); schemaChange(String.format("CREATE TABLE %s.%s (k int primary key, v int)", KEYSPACE, table));
schemaChange(String.format("ALTER TABLE %s.%s WITH compression = {'sstable_compression': ''}", KEYSPACE, table)); schemaChange(String.format("ALTER TABLE %s.%s WITH compression = {'enabled': false}", KEYSPACE, table));
TableMetadata tmd = Schema.instance.getTableMetadata(KEYSPACE, table); TableMetadata tmd = Schema.instance.getTableMetadata(KEYSPACE, table);
Assert.assertFalse(tmd.params.compression.isEnabled()); Assert.assertFalse(tmd.params.compression.isEnabled());
} }
@ -72,6 +72,6 @@ public class GuardrailAllowUncompressedTablesTest extends GuardrailTester
setGuardrail(false); setGuardrail(false);
String table = createTableName(); String table = createTableName();
schemaChange(String.format("CREATE TABLE %s.%s (k int primary key, v int)", KEYSPACE, table)); schemaChange(String.format("CREATE TABLE %s.%s (k int primary key, v int)", KEYSPACE, table));
assertFails(String.format("ALTER TABLE %s.%s WITH compression = {'sstable_compression': ''}", KEYSPACE, table), "Uncompressed table is not allowed"); assertFails(String.format("ALTER TABLE %s.%s WITH compression = {'enabled': false}", KEYSPACE, table), "Uncompressed table is not allowed");
} }
} }

View File

@ -106,7 +106,7 @@ public class CQLCompressionTest extends CQLTester
@Test @Test
public void lz4FlushTest() throws Throwable public void lz4FlushTest() throws Throwable
{ {
createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'sstable_compression': 'LZ4Compressor'};"); createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'class': 'LZ4Compressor'};");
ColumnFamilyStore store = flushTwice(); ColumnFamilyStore store = flushTwice();
// Should flush as LZ4 "fast" // Should flush as LZ4 "fast"
@ -131,7 +131,7 @@ public class CQLCompressionTest extends CQLTester
public void lz4hcFlushTest() throws Throwable public void lz4hcFlushTest() throws Throwable
{ {
createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = " + createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = " +
"{'sstable_compression': 'LZ4Compressor', 'lz4_compressor_type': 'high'};"); "{'class': 'LZ4Compressor', 'lz4_compressor_type': 'high'};");
ColumnFamilyStore store = flushTwice(); ColumnFamilyStore store = flushTwice();
// Should flush as LZ4 "fast" mode // Should flush as LZ4 "fast" mode
@ -155,7 +155,7 @@ public class CQLCompressionTest extends CQLTester
@Test @Test
public void zstdFlushTest() throws Throwable public void zstdFlushTest() throws Throwable
{ {
createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'sstable_compression': 'ZstdCompressor'};"); createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'class': 'ZstdCompressor'};");
ColumnFamilyStore store = flushTwice(); ColumnFamilyStore store = flushTwice();
// Should flush as LZ4 // Should flush as LZ4
@ -177,7 +177,7 @@ public class CQLCompressionTest extends CQLTester
@Test @Test
public void deflateFlushTest() throws Throwable public void deflateFlushTest() throws Throwable
{ {
createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'sstable_compression': 'DeflateCompressor'};"); createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'class': 'DeflateCompressor'};");
ColumnFamilyStore store = flushTwice(); ColumnFamilyStore store = flushTwice();
// Should flush as LZ4 // Should flush as LZ4
@ -200,7 +200,7 @@ public class CQLCompressionTest extends CQLTester
public void useNoCompressorOnFlushTest() throws Throwable public void useNoCompressorOnFlushTest() throws Throwable
{ {
DatabaseDescriptor.setFlushCompression(Config.FlushCompression.none); DatabaseDescriptor.setFlushCompression(Config.FlushCompression.none);
createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'sstable_compression': 'LZ4Compressor'};"); createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'class': 'LZ4Compressor'};");
ColumnFamilyStore store = flushTwice(); ColumnFamilyStore store = flushTwice();
// Should flush as Noop compressor // Should flush as Noop compressor
@ -224,7 +224,7 @@ public class CQLCompressionTest extends CQLTester
{ {
DatabaseDescriptor.setFlushCompression(Config.FlushCompression.table); DatabaseDescriptor.setFlushCompression(Config.FlushCompression.table);
createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'sstable_compression': 'ZstdCompressor'};"); createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'class': 'ZstdCompressor'};");
ColumnFamilyStore store = flushTwice(); ColumnFamilyStore store = flushTwice();
// Should flush as Zstd // Should flush as Zstd
@ -237,7 +237,7 @@ public class CQLCompressionTest extends CQLTester
@Test @Test
public void zstdTableFlushTest() throws Throwable public void zstdTableFlushTest() throws Throwable
{ {
createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'sstable_compression': 'ZstdCompressor'};"); createTable("CREATE TABLE %s (k text PRIMARY KEY, v text) WITH compression = {'class': 'ZstdCompressor'};");
ColumnFamilyStore store = flushTwice(); ColumnFamilyStore store = flushTwice();
// Should flush as LZ4 // Should flush as LZ4

View File

@ -44,7 +44,7 @@ table_definition: |
PRIMARY KEY((name,choice), date, address, dbl, lval, ival, uid) PRIMARY KEY((name,choice), date, address, dbl, lval, ival, uid)
) )
WITH compaction = { 'class':'LeveledCompactionStrategy' } WITH compaction = { 'class':'LeveledCompactionStrategy' }
# AND compression = { 'sstable_compression' : '' } # AND compression = { 'class' : 'LZ4Compressor' }
# AND comment='A table of many types to test wide rows' # AND comment='A table of many types to test wide rows'
# #

View File

@ -140,7 +140,7 @@ public class SettingsSchema implements Serializable
//Compression //Compression
b.append(") WITH compression = {"); b.append(") WITH compression = {");
if (compression != null) if (compression != null)
b.append("'sstable_compression' : '").append(compression).append("'"); b.append("'class' : '").append(compression).append("'");
b.append("}"); b.append("}");
@ -181,7 +181,7 @@ public class SettingsSchema implements Serializable
//Compression //Compression
b.append(") WITH compression = {"); b.append(") WITH compression = {");
if (compression != null) if (compression != null)
b.append("'sstable_compression' : '").append(compression).append("'"); b.append("'class' : '").append(compression).append("'");
b.append("}"); b.append("}");