cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Migrate pre-2.0 key/value/column aliases to system.schema_columns
Date Wed, 18 Sep 2013 12:14:26 GMT
Updated Branches:
  refs/heads/cassandra-2.0 88e3977ce -> e638acec9


Migrate pre-2.0 key/value/column aliases to system.schema_columns

patch by Aleksey Yeschenko; reviewed by Sylvain Lebresne for
CASSANRA-6009


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

Branch: refs/heads/cassandra-2.0
Commit: e638acec945924d31c35fa6308b62ab6873bec6a
Parents: 88e3977
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Wed Sep 18 15:12:09 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Wed Sep 18 15:12:09 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../org/apache/cassandra/db/SystemKeyspace.java | 27 ++++++++++++++++++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e638acec/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 46e1b43..0142c53 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -20,6 +20,8 @@
  * Fix paged ranges with multiple replicas (CASSANDRA-6004)
  * Fix potential AssertionError during tracing (CASSANDRA-6041)
  * Fix NPE in sstablesplit (CASSANDRA-6027)
+ * Migrate pre-2.0 key/value/column aliases to system.schema_columns
+   (CASSANDRA-6009)
 Merged from 1.2:
  * Tuning knobs for dealing with large blobs and many CFs (CASSANDRA-5982)
  * (Hadoop) Fix CQLRW for thrift tables (CASSANDRA-6002)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e638acec/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 3e608b3..0342dbb 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -97,6 +97,8 @@ public class SystemKeyspace
     {
         setupVersion();
 
+        copyAllAliasesToColumnsProper();
+
         // add entries to system schema columnfamilies for the hardcoded system definitions
         for (String ksname : Schema.systemKeyspaceNames)
         {
@@ -114,6 +116,31 @@ public class SystemKeyspace
         }
     }
 
+    // Starting with 2.0 (CASSANDRA-5125) we keep all the 'aliases' in system.schema_columns
together with the regular columns,
+    // but only for the newly-created tables. This migration is for the pre-2.0 created tables.
+    private static void copyAllAliasesToColumnsProper()
+    {
+        for (UntypedResultSet.Row row : processInternal(String.format("SELECT * FROM system.%s",
SCHEMA_COLUMNFAMILIES_CF)))
+        {
+            CFMetaData table = CFMetaData.fromSchema(row);
+            String query = String.format("SELECT writetime(type) "
+                                         + "FROM system.%s "
+                                         + "WHERE keyspace_name = '%s' AND columnfamily_name
= '%s'",
+                                         SCHEMA_COLUMNFAMILIES_CF,
+                                         table.ksName,
+                                         table.cfName);
+            long timestamp = processInternal(query).one().getLong("writetime(type)");
+            try
+            {
+                table.toSchema(timestamp).apply();
+            }
+            catch (ConfigurationException e)
+            {
+                // shouldn't happen
+            }
+        }
+    }
+
     private static void setupVersion()
     {
         String req = "INSERT INTO system.%s (key, release_version, cql_version, thrift_version,
native_protocol_version, data_center, rack, partitioner) VALUES ('%s', '%s', '%s', '%s', '%s',
'%s', '%s', '%s')";


Mime
View raw message