cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [1/9] cassandra git commit: Fix SSTableLoader fail when the loaded table contains dropped columns (CASSANDRA-13276)
Date Thu, 20 Apr 2017 13:48:59 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 175e4f8ce -> f5b36f12d
  refs/heads/cassandra-3.11 42904c653 -> 4d24958dd
  refs/heads/trunk b687641f7 -> 50ba850be


Fix SSTableLoader fail when the loaded table contains dropped columns (CASSANDRA-13276)


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

Branch: refs/heads/cassandra-3.11
Commit: 175e4f8ce868ea04a5e11a8d5212d8c397ea0d12
Parents: b063b38
Author: adelapena <a.penya.garcia@gmail.com>
Authored: Thu Apr 20 13:16:15 2017 +0100
Committer: adelapena <a.penya.garcia@gmail.com>
Committed: Thu Apr 20 13:16:15 2017 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../utils/NativeSSTableLoaderClient.java        | 43 +++++++++++++++-----
 2 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/175e4f8c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 81d5b06..6a1e486 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.14
+ * Fix SSTableLoader fail when the loaded table contains dropped columns (CASSANDRA-13276)
  * Avoid name clashes in CassandraIndexTest (CASSANDRA-13427)
  * Handling partially written hint files (CASSANDRA-12728) 
  * Interrupt replaying hints on decommission (CASSANDRA-13308)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/175e4f8c/src/java/org/apache/cassandra/utils/NativeSSTableLoaderClient.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/NativeSSTableLoaderClient.java b/src/java/org/apache/cassandra/utils/NativeSSTableLoaderClient.java
index 4c6b12e..97237d0 100644
--- a/src/java/org/apache/cassandra/utils/NativeSSTableLoaderClient.java
+++ b/src/java/org/apache/cassandra/utils/NativeSSTableLoaderClient.java
@@ -18,7 +18,9 @@
 package org.apache.cassandra.utils;
 
 import java.net.InetAddress;
+import java.nio.ByteBuffer;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 import com.datastax.driver.core.*;
 
@@ -184,16 +186,29 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
         for (Row colRow : session.execute(columnsQuery, keyspace, name))
             defs.add(createDefinitionFromRow(colRow, keyspace, name, types));
 
-        return CFMetaData.create(keyspace,
-                                 name,
-                                 id,
-                                 isDense,
-                                 isCompound,
-                                 isSuper,
-                                 isCounter,
-                                 isView,
-                                 defs,
-                                 partitioner);
+        CFMetaData metadata = CFMetaData.create(keyspace,
+                                                name,
+                                                id,
+                                                isDense,
+                                                isCompound,
+                                                isSuper,
+                                                isCounter,
+                                                isView,
+                                                defs,
+                                                partitioner);
+
+        String droppedColumnsQuery = String.format("SELECT * FROM %s.%s WHERE keyspace_name
= ? AND table_name = ?",
+                                                   SchemaKeyspace.NAME,
+                                                   SchemaKeyspace.DROPPED_COLUMNS);
+        Map<ByteBuffer, CFMetaData.DroppedColumn> droppedColumns = new HashMap<>();
+        for (Row colRow : session.execute(droppedColumnsQuery, keyspace, name))
+        {
+            CFMetaData.DroppedColumn droppedColumn = createDroppedColumnFromRow(colRow, keyspace);
+            droppedColumns.put(UTF8Type.instance.decompose(droppedColumn.name), droppedColumn);
+        }
+        metadata.droppedColumns(droppedColumns);
+
+        return metadata;
     }
 
     private static ColumnDefinition createDefinitionFromRow(Row row, String keyspace, String
table, Types types)
@@ -211,4 +226,12 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
         ColumnDefinition.Kind kind = ColumnDefinition.Kind.valueOf(row.getString("kind").toUpperCase());
         return new ColumnDefinition(keyspace, table, name, type, position, kind);
     }
+
+    private static CFMetaData.DroppedColumn createDroppedColumnFromRow(Row row, String keyspace)
+    {
+        String name = row.getString("column_name");
+        AbstractType<?> type = CQLTypeParser.parse(keyspace, row.getString("type"),
Types.none());
+        long droppedTime = TimeUnit.MILLISECONDS.toMicros(row.getTimestamp("dropped_time").getTime());
+        return new CFMetaData.DroppedColumn(name, type, droppedTime);
+    }
 }


Mime
View raw message