Skip to content

Commit

Permalink
Merge branch 'cassandra-3.11' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
krummas committed Apr 13, 2021
2 parents d9e5dd2 + 7152d40 commit 1d24c7c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -52,6 +52,7 @@
* Restore sasi dependencies jflex, snowball-stemmer, and concurrent-trees, in the cassandra-all pom (CASSANDRA-16303)
* Fix DecimalDeserializer#toString OOM (CASSANDRA-14925)
Merged from 3.11:
* Add autocomplete and error messages for provide_overlapping_tombstones (CASSANDRA-16350)
* Upgrade jackson-databind to 2.9.10.8 (CASSANDRA-16462)
* Fix digest computation for queries with fetched but non queried columns (CASSANDRA-15962)
* Reduce amount of allocations during batch statement execution (CASSANDRA-16201)
Expand Down
4 changes: 3 additions & 1 deletion pylib/cqlshlib/cql3handling.py
Expand Up @@ -58,7 +58,7 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet):
# (CQL3 option name, schema_columnfamilies column name (or None if same),
# list of known map keys)
('compaction', 'compaction_strategy_options',
('class', 'max_threshold', 'tombstone_compaction_interval', 'tombstone_threshold', 'enabled', 'unchecked_tombstone_compaction', 'only_purge_repaired_tombstones')),
('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')),
('caching', None,
Expand Down Expand Up @@ -554,6 +554,8 @@ def cf_prop_val_mapval_completer(ctxt, cass):
if opt == 'compaction':
if key == 'class':
return list(map(escape_value, CqlRuleSet.available_compaction_classes))
if key == 'provide_overlapping_tombstones':
return [Hint('<NONE|ROW|CELL>')]
return [Hint('<option_value>')]
elif opt == 'compression':
if key == 'sstable_compression':
Expand Down
8 changes: 5 additions & 3 deletions pylib/cqlshlib/test/test_cqlsh_completion.py
Expand Up @@ -657,7 +657,8 @@ def create_columnfamily_table_template(self, name):
'tombstone_compaction_interval',
'tombstone_threshold',
'unchecked_tombstone_compaction',
'only_purge_repaired_tombstones'])
'only_purge_repaired_tombstones',
'provide_overlapping_tombstones'])
self.trycompletions(prefix + " new_table (col_a int PRIMARY KEY) WITH compaction = "
+ "{'class': 'SizeTieredCompactionStrategy'}",
choices=[';', 'AND'])
Expand All @@ -677,14 +678,15 @@ def create_columnfamily_table_template(self, name):
'timestamp_resolution', 'min_threshold', 'class', 'max_threshold',
'tombstone_compaction_interval', 'tombstone_threshold',
'enabled', 'unchecked_tombstone_compaction',
'max_window_size_seconds', 'only_purge_repaired_tombstones'])
'max_window_size_seconds',
'only_purge_repaired_tombstones', 'provide_overlapping_tombstones'])
self.trycompletions(prefix + " new_table (col_a int PRIMARY KEY) WITH compaction = "
+ "{'class': 'TimeWindowCompactionStrategy', '",
choices=['compaction_window_unit', 'compaction_window_size',
'timestamp_resolution', 'min_threshold', 'class', 'max_threshold',
'tombstone_compaction_interval', 'tombstone_threshold',
'enabled', 'unchecked_tombstone_compaction',
'only_purge_repaired_tombstones'])
'only_purge_repaired_tombstones','provide_overlapping_tombstones'])

def test_complete_in_create_columnfamily(self):
self.trycompletions('CREATE C', choices=['COLUMNFAMILY', 'CUSTOM'])
Expand Down
21 changes: 19 additions & 2 deletions src/java/org/apache/cassandra/schema/CompactionParams.java
Expand Up @@ -18,9 +18,11 @@
package org.apache.cassandra.schema;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -61,6 +63,13 @@ public enum TombstoneOption
NONE,
ROW,
CELL;

private static final TombstoneOption[] copyOfValues = values();

public static Optional<TombstoneOption> forName(String name)
{
return Arrays.stream(copyOfValues).filter(x -> x.name().equals(name)).findFirst();
}
}

public static final int DEFAULT_MIN_THRESHOLD = 4;
Expand Down Expand Up @@ -95,8 +104,16 @@ public static CompactionParams create(Class<? extends AbstractCompactionStrategy
boolean isEnabled = options.containsKey(Option.ENABLED.toString())
? Boolean.parseBoolean(options.get(Option.ENABLED.toString()))
: DEFAULT_ENABLED;
TombstoneOption tombstoneOption = TombstoneOption.valueOf(options.getOrDefault(Option.PROVIDE_OVERLAPPING_TOMBSTONES.toString(),
DEFAULT_PROVIDE_OVERLAPPING_TOMBSTONES.toString()).toUpperCase());
String overlappingTombstoneParm = options.getOrDefault(Option.PROVIDE_OVERLAPPING_TOMBSTONES.toString(),
DEFAULT_PROVIDE_OVERLAPPING_TOMBSTONES.toString()).toUpperCase();
Optional<TombstoneOption> tombstoneOptional = TombstoneOption.forName(overlappingTombstoneParm);
if (!tombstoneOptional.isPresent())
{
throw new ConfigurationException(format("Invalid value %s for 'provide_overlapping_tombstones' compaction sub-option - must be one of the following [%s].",
overlappingTombstoneParm,
StringUtils.join(TombstoneOption.values(), ", ")));
}
TombstoneOption tombstoneOption = tombstoneOptional.get();

Map<String, String> allOptions = new HashMap<>(options);
if (supportsThresholdParams(klass))
Expand Down
Expand Up @@ -39,11 +39,9 @@
import org.apache.cassandra.db.Directories;
import org.apache.cassandra.db.Mutation;
import org.apache.cassandra.db.RangeTombstone;
import org.apache.cassandra.db.RowIndexEntry;
import org.apache.cassandra.db.RowUpdateBuilder;
import org.apache.cassandra.db.Slice;
import org.apache.cassandra.db.compaction.writers.CompactionAwareWriter;
import org.apache.cassandra.db.compaction.writers.MajorLeveledCompactionWriter;
import org.apache.cassandra.db.compaction.writers.MaxSSTableSizeWriter;
import org.apache.cassandra.db.lifecycle.LifecycleTransaction;
import org.apache.cassandra.db.partitions.PartitionUpdate;
Expand All @@ -55,6 +53,7 @@
import org.apache.cassandra.io.sstable.ISSTableScanner;
import org.apache.cassandra.io.sstable.format.SSTableReader;
import org.apache.cassandra.serializers.MarshalException;
import org.apache.cassandra.schema.CompactionParams;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -714,6 +713,29 @@ private void assertTombstones(SSTableReader sstable, boolean expectTS)
assertEquals(expectTS, foundTombstone);
}

@Test(expected = IllegalArgumentException.class)
public void testBadProvidesTombstoneOption()
{
createTable("CREATE TABLE %s (id text PRIMARY KEY)");
Map<String, String> localOptions = new HashMap<>();
localOptions.put("class","SizeTieredCompactionStrategy");
localOptions.put("provide_overlapping_tombstones","IllegalValue");

getCurrentColumnFamilyStore().setCompactionParameters(localOptions);
}
@Test
public void testProvidesTombstoneOptionverifiation()
{
createTable("CREATE TABLE %s (id text PRIMARY KEY)");
Map<String, String> localOptions = new HashMap<>();
localOptions.put("class","SizeTieredCompactionStrategy");
localOptions.put("provide_overlapping_tombstones","row");

getCurrentColumnFamilyStore().setCompactionParameters(localOptions);
assertEquals(CompactionParams.TombstoneOption.ROW, getCurrentColumnFamilyStore().getCompactionStrategyManager().getCompactionParams().tombstoneOption());
}


public boolean verifyStrategies(CompactionStrategyManager manager, Class<? extends AbstractCompactionStrategy> expected)
{
boolean found = false;
Expand Down

0 comments on commit 1d24c7c

Please sign in to comment.