Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/java/org/apache/cassandra/schema/MemtableParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public Memtable.Factory factory()
* Returns a map representation of the memtable configuration for backward compatibility with CC 4.0.
* This is used when outputting schema in a format compatible with CC 4.0.
*
* For the "default" configuration key, we output {'class': 'default'} to ensure round-trip
* consistency.
* For the "default" configuration key, we output an empty map {} to let each Cassandra version
* interpret "default" according to its own configuration. This ensures backward compatibility
* with CC 4.0 which uses an empty map to represent the default memtable configuration.
*
* For other configurations, CC 4.0 accepts both short class names (e.g., 'TrieMemtable') and
* fully qualified names (e.g., 'org.apache.cassandra.db.memtable.TrieMemtable'). For standard
Expand All @@ -84,7 +85,7 @@ public Memtable.Factory factory()
public Map<String, String> toMapForCC4()
{
if ("default".equals(configurationKey))
return ImmutableMap.of("class", "default");
return ImmutableMap.of();

ParameterizedClass definition = CONFIGURATION_DEFINITIONS.get(configurationKey);
if (definition != null && definition.class_name != null)
Expand Down
12 changes: 7 additions & 5 deletions test/unit/org/apache/cassandra/db/SchemaCQLHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,9 @@ public void testSchemaBackwardCompatibilityCc40()
Assertions.assertThat(cql).doesNotContain("incremental_backups");
// Should contain other properties
Assertions.assertThat(cql).contains("bloom_filter_fp_chance");
// Should use map format for memtable (CC 4.0 compatible) with short class name
Assertions.assertThat(cql).contains("memtable = {'class': 'default'}");
// Should use empty map for default memtable (CC 4.0 compatible)
// This lets each Cassandra version interpret "default" according to its own configuration
Assertions.assertThat(cql).contains("memtable = {}");
// Should NOT contain fully qualified class name
Assertions.assertThat(cql).doesNotContain("org.apache.cassandra.db.memtable");

Expand Down Expand Up @@ -931,12 +932,13 @@ public void testToMapForCC4OutputFormat()
Assertions.assertThat(cql5).contains("memtable = {'class': 'SkipListMemtable'");
Assertions.assertThat(cql5).doesNotContain("org.apache.cassandra.db.memtable.SkipListMemtable");

// Test that tables created with memtable = 'default' output 'default' in CC 4.0 mode
// Test that tables created with memtable = 'default' output empty map in CC 4.0 mode
// This ensures backward compatibility with CC 4.0 which uses {} for default memtable
String tableName6 = createTable(keyspace, "CREATE TABLE %s (id int PRIMARY KEY, value text) WITH memtable = 'default'");
ColumnFamilyStore cfs6 = Keyspace.open(keyspace).getColumnFamilyStore(tableName6);
String cql6 = SchemaCQLHelper.getTableMetadataAsCQL(cfs6.metadata(), cfs6.keyspace.getMetadata());
// Should output 'default' as the class name
Assertions.assertThat(cql6).contains("memtable = {'class': 'default'");
// Should output empty map to let each version interpret "default" according to its own configuration
Assertions.assertThat(cql6).contains("memtable = {}");

// Test that custom memtables from other packages preserve fully qualified class names
// Note: We can't easily test this without adding a custom memtable configuration to cassandra.yaml,
Expand Down