You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2015/07/10 21:16:48 UTC

cassandra git commit: Remove dead iSchemaKeyspace/LegacySchemaMigrator code

Repository: cassandra
Updated Branches:
  refs/heads/trunk 16044a6f4 -> c734cb8b6


Remove dead iSchemaKeyspace/LegacySchemaMigrator code


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c734cb8b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c734cb8b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c734cb8b

Branch: refs/heads/trunk
Commit: c734cb8b60c9bc96303d0cf5b77a7eabec5a49e4
Parents: 16044a6
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Fri Jul 10 21:50:16 2015 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Fri Jul 10 22:16:46 2015 +0300

----------------------------------------------------------------------
 .../org/apache/cassandra/db/SystemKeyspace.java |  1 -
 .../cassandra/schema/LegacySchemaMigrator.java  |  7 +-
 .../apache/cassandra/schema/SchemaKeyspace.java | 89 ++------------------
 .../schema/LegacySchemaMigratorTest.java        |  2 -
 4 files changed, 6 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c734cb8b/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index f0c91d6..e8247a3 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -301,7 +301,6 @@ public final class SystemKeyspace
                 + "default_time_to_live int,"
                 + "default_validator text,"
                 + "dropped_columns map<text, bigint>,"
-                + "dropped_columns_types map<text, text>,"
                 + "gc_grace_seconds int,"
                 + "is_dense boolean,"
                 + "key_validator text,"

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c734cb8b/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java b/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
index 4748820..996b5ff 100644
--- a/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
+++ b/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
@@ -330,12 +330,7 @@ public final class LegacySchemaMigrator
             cfm.bloomFilterFpChance(cfm.getBloomFilterFpChance());
 
         if (tableRow.has("dropped_columns"))
-        {
-            Map<String, String> types = tableRow.has("dropped_columns_types")
-                                      ? tableRow.getMap("dropped_columns_types", UTF8Type.instance, UTF8Type.instance)
-                                      : Collections.<String, String>emptyMap();
-            addDroppedColumns(cfm, tableRow.getMap("dropped_columns", UTF8Type.instance, LongType.instance), types);
-        }
+            addDroppedColumns(cfm, tableRow.getMap("dropped_columns", UTF8Type.instance, LongType.instance), Collections.emptyMap());
 
         cfm.triggers(createTriggersFromTriggerRows(triggerRows));
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c734cb8b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
index 5aad59f..8411104 100644
--- a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
+++ b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
@@ -1010,18 +1010,11 @@ public final class SchemaKeyspace
 
         // We don't really use the default validator but as we have it for backward compatibility, we use it to know if it's a counter table
         AbstractType<?> defaultValidator = TypeParser.parse(result.getString("default_validator"));
-        boolean isCounter =  defaultValidator instanceof CounterColumnType;
+        boolean isCounter = defaultValidator instanceof CounterColumnType;
 
         UUID cfId = result.getUUID("cf_id");
 
         boolean isCQLTable = !isSuper && !isDense && isCompound;
-        boolean isStaticCompactTable = !isDense && !isCompound;
-
-        // Internally, compact tables have a specific layout, see CompactTables. But when upgrading from
-        // previous versions, they may not have the expected schema, so detect if we need to upgrade and do
-        // it in createColumnsFromColumnRows.
-        // We can remove this once we don't support upgrade from versions < 3.0.
-        boolean needsUpgrade = !isCQLTable && checkNeedsUpgrade(serializedColumnDefinitions, isSuper, isStaticCompactTable);
 
         List<ColumnDefinition> columnDefs = createColumnsFromColumnRows(serializedColumnDefinitions,
                                                                         ksName,
@@ -1029,12 +1022,7 @@ public final class SchemaKeyspace
                                                                         rawComparator,
                                                                         subComparator,
                                                                         isSuper,
-                                                                        isCQLTable,
-                                                                        isStaticCompactTable,
-                                                                        needsUpgrade);
-
-        if (needsUpgrade)
-            addDefinitionForUpgrade(columnDefs, ksName, cfName, isStaticCompactTable, isSuper, rawComparator, subComparator, defaultValidator);
+                                                                        isCQLTable);
 
         CFMetaData cfm = CFMetaData.create(ksName, cfName, cfId, isDense, isCompound, isSuper, isCounter, columnDefs);
 
@@ -1078,67 +1066,6 @@ public final class SchemaKeyspace
         return cfm;
     }
 
-    // Should only be called on compact tables
-    private static boolean checkNeedsUpgrade(UntypedResultSet defs, boolean isSuper, boolean isStaticCompactTable)
-    {
-        if (isSuper)
-        {
-            // Check if we've added the "supercolumn map" column yet or not
-            for (UntypedResultSet.Row row : defs)
-            {
-                if (row.getString("column_name").isEmpty())
-                    return false;
-            }
-            return true;
-        }
-
-        // For static compact tables, we need to upgrade if the regular definitions haven't been converted to static yet,
-        // i.e. if we don't have a static definition yet.
-        if (isStaticCompactTable)
-            return !hasKind(defs, ColumnDefinition.Kind.STATIC);
-
-        // For dense compact tables, we need to upgrade if we don't have a compact value definition
-        return !hasKind(defs, ColumnDefinition.Kind.REGULAR);
-    }
-
-    private static void addDefinitionForUpgrade(List<ColumnDefinition> defs,
-                                                String ksName,
-                                                String cfName,
-                                                boolean isStaticCompactTable,
-                                                boolean isSuper,
-                                                AbstractType<?> rawComparator,
-                                                AbstractType<?> subComparator,
-                                                AbstractType<?> defaultValidator)
-    {
-        CompactTables.DefaultNames names = CompactTables.defaultNameGenerator(defs);
-
-        if (isSuper)
-        {
-            defs.add(ColumnDefinition.regularDef(ksName, cfName, CompactTables.SUPER_COLUMN_MAP_COLUMN_STR, MapType.getInstance(subComparator, defaultValidator, true), null));
-        }
-        else if (isStaticCompactTable)
-        {
-            defs.add(ColumnDefinition.clusteringKeyDef(ksName, cfName, names.defaultClusteringName(), rawComparator, null));
-            defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), defaultValidator, null));
-        }
-        else
-        {
-            // For dense compact tables, we get here if we don't have a compact value column, in which case we should add it
-            // (we use EmptyType to recognize that the compact value was not declared by the use (see CreateTableStatement too))
-            defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), EmptyType.instance, null));
-        }
-    }
-
-    private static boolean hasKind(UntypedResultSet defs, ColumnDefinition.Kind kind)
-    {
-        for (UntypedResultSet.Row row : defs)
-        {
-            if (deserializeKind(row.getString("type")) == kind)
-                return true;
-        }
-        return false;
-    }
-
     private static void addDroppedColumns(CFMetaData cfm, Map<String, Long> droppedTimes, Map<String, String> types)
     {
         for (Map.Entry<String, Long> entry : droppedTimes.entrySet())
@@ -1201,13 +1128,11 @@ public final class SchemaKeyspace
                                                                       AbstractType<?> rawComparator,
                                                                       AbstractType<?> rawSubComparator,
                                                                       boolean isSuper,
-                                                                      boolean isCQLTable,
-                                                                      boolean isStaticCompactTable,
-                                                                      boolean needsUpgrade)
+                                                                      boolean isCQLTable)
     {
         List<ColumnDefinition> columns = new ArrayList<>();
         for (UntypedResultSet.Row row : rows)
-            columns.add(createColumnFromColumnRow(row, keyspace, table, rawComparator, rawSubComparator, isSuper, isCQLTable, isStaticCompactTable, needsUpgrade));
+            columns.add(createColumnFromColumnRow(row, keyspace, table, rawComparator, rawSubComparator, isSuper, isCQLTable));
         return columns;
     }
 
@@ -1217,13 +1142,9 @@ public final class SchemaKeyspace
                                                               AbstractType<?> rawComparator,
                                                               AbstractType<?> rawSubComparator,
                                                               boolean isSuper,
-                                                              boolean isCQLTable,
-                                                              boolean isStaticCompactTable,
-                                                              boolean needsUpgrade)
+                                                              boolean isCQLTable)
     {
         ColumnDefinition.Kind kind = deserializeKind(row.getString("type"));
-        if (needsUpgrade && isStaticCompactTable && kind == ColumnDefinition.Kind.REGULAR)
-            kind = ColumnDefinition.Kind.STATIC;
 
         Integer componentIndex = null;
         if (row.has("component_index"))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c734cb8b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
index 17cffaf..9275da7 100644
--- a/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
+++ b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
@@ -407,8 +407,6 @@ public class LegacySchemaMigratorTest
             String name = entry.getKey().toString();
             CFMetaData.DroppedColumn column = entry.getValue();
             adder.addMapEntry("dropped_columns", name, column.droppedTime);
-            if (column.type != null)
-                adder.addMapEntry("dropped_columns_types", name, column.type.toString());
         }
 
         adder.add("is_dense", table.isDense());