cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/3] cassandra git commit: Fix upgrading schema with super columns with non-text subcomparators
Date Mon, 20 Jun 2016 17:09:04 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 0a0e97df5 -> b671522d0
  refs/heads/trunk 88229a47a -> fb781c99b


Fix upgrading schema with super columns with non-text subcomparators

patch by Aleksey Yeschenko; reviewed by Jeremiah Jordan for
CASSANDRA-12023


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

Branch: refs/heads/cassandra-3.0
Commit: b671522d008017bc46e48ffee4c43375d96c4f26
Parents: 0a0e97d
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Mon Jun 20 16:06:56 2016 +0100
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Jun 20 18:04:56 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 src/java/org/apache/cassandra/db/CompactTables.java      | 11 +++++++----
 .../apache/cassandra/schema/LegacySchemaMigrator.java    |  6 ++++--
 3 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b671522d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7873742..cc682c4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.8
+ * Fix upgrading schema with super columns with non-text subcomparators (CASSANDRA-12023)
  * Add TimeWindowCompactionStrategy (CASSANDRA-9666)
 Merged from 2.2:
  * Don't send erroneous NEW_NODE notifications on restart (CASSANDRA-11038)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b671522d/src/java/org/apache/cassandra/db/CompactTables.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CompactTables.java b/src/java/org/apache/cassandra/db/CompactTables.java
index a72e7f2..a73b865 100644
--- a/src/java/org/apache/cassandra/db/CompactTables.java
+++ b/src/java/org/apache/cassandra/db/CompactTables.java
@@ -91,12 +91,15 @@ public abstract class CompactTables
         return columns.regulars.getSimple(0);
     }
 
-    public static AbstractType<?> columnDefinitionComparator(ColumnDefinition.Kind
kind, boolean isSuper, AbstractType<?> rawComparator, AbstractType<?> rawSubComparator)
+    public static AbstractType<?> columnDefinitionComparator(String kind, boolean isSuper,
AbstractType<?> rawComparator, AbstractType<?> rawSubComparator)
     {
+        if ("compact_value".equals(kind))
+            return UTF8Type.instance;
+
         if (isSuper)
-            return kind == ColumnDefinition.Kind.REGULAR ? rawSubComparator : UTF8Type.instance;
-        else
-            return kind == ColumnDefinition.Kind.STATIC ? rawComparator : UTF8Type.instance;
+            return "regular".equals(kind) ? rawSubComparator : UTF8Type.instance;
+
+        return "static".equals(kind) ? rawComparator : UTF8Type.instance;
     }
 
     public static boolean hasEmptyCompactValue(CFMetaData metadata)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b671522d/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 7411b93..924bd7a 100644
--- a/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
+++ b/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
@@ -662,7 +662,9 @@ public final class LegacySchemaMigrator
                                                               boolean isStaticCompactTable,
                                                               boolean needsUpgrade)
     {
-        ColumnDefinition.Kind kind = deserializeKind(row.getString("type"));
+        String rawKind = row.getString("type");
+
+        ColumnDefinition.Kind kind = deserializeKind(rawKind);
         if (needsUpgrade && isStaticCompactTable && kind == ColumnDefinition.Kind.REGULAR)
             kind = ColumnDefinition.Kind.STATIC;
 
@@ -678,7 +680,7 @@ public final class LegacySchemaMigrator
         // we need to use the comparator fromString method
         AbstractType<?> comparator = isCQLTable
                                      ? UTF8Type.instance
-                                     : CompactTables.columnDefinitionComparator(kind, isSuper,
rawComparator, rawSubComparator);
+                                     : CompactTables.columnDefinitionComparator(rawKind,
isSuper, rawComparator, rawSubComparator);
         ColumnIdentifier name = ColumnIdentifier.getInterned(comparator.fromString(row.getString("column_name")),
comparator);
 
         AbstractType<?> validator = parseType(row.getString("validator"));


Mime
View raw message