cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adelap...@apache.org
Subject [3/3] cassandra git commit: Fix SSTableLoader fail when the loaded table contains dropped columns (CASSANDRA-13276)
Date Thu, 20 Apr 2017 12:23:03 GMT
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/b687641f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b687641f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b687641f

Branch: refs/heads/trunk
Commit: b687641f78c85f266bae2475da8622c06c39dd0f
Parents: 90e5078
Author: adelapena <a.penya.garcia@gmail.com>
Authored: Thu Apr 20 13:20:53 2017 +0100
Committer: adelapena <a.penya.garcia@gmail.com>
Committed: Thu Apr 20 13:20:53 2017 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../utils/NativeSSTableLoaderClient.java        | 22 ++++++++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b687641f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d462ed1..db863e1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -81,6 +81,7 @@
  * Address message coalescing regression (CASSANDRA-12676)
  * Delete illegal character from StandardTokenizerImpl.jflex (CASSANDRA-13417)
 Merged from 3.0:
+ * 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/b687641f/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 ba702dd..84a4c32 100644
--- a/src/java/org/apache/cassandra/utils/NativeSSTableLoaderClient.java
+++ b/src/java/org/apache/cassandra/utils/NativeSSTableLoaderClient.java
@@ -18,6 +18,7 @@
 package org.apache.cassandra.utils;
 
 import java.net.InetAddress;
+import java.nio.ByteBuffer;
 import java.util.*;
 
 import com.datastax.driver.core.*;
@@ -176,6 +177,17 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
         for (Row colRow : session.execute(columnsQuery, keyspace, name))
             builder.addColumn(createDefinitionFromRow(colRow, keyspace, name, types));
 
+        String droppedColumnsQuery = String.format("SELECT * FROM %s.%s WHERE keyspace_name
= ? AND table_name = ?",
+                                                   SchemaConstants.SCHEMA_KEYSPACE_NAME,
+                                                   SchemaKeyspace.DROPPED_COLUMNS);
+        Map<ByteBuffer, DroppedColumn> droppedColumns = new HashMap<>();
+        for (Row colRow : session.execute(droppedColumnsQuery, keyspace, name))
+        {
+            DroppedColumn droppedColumn = createDroppedColumnFromRow(colRow, keyspace, name);
+            droppedColumns.put(droppedColumn.column.name.bytes, droppedColumn);
+        }
+        builder.droppedColumns(droppedColumns);
+
         return TableMetadataRef.forOfflineTools(builder.build());
     }
 
@@ -194,4 +206,14 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
         org.apache.cassandra.schema.ColumnMetadata.Kind kind = ColumnMetadata.Kind.valueOf(row.getString("kind").toUpperCase());
         return new ColumnMetadata(keyspace, table, name, type, position, kind);
     }
+
+    private static DroppedColumn createDroppedColumnFromRow(Row row, String keyspace, String
table)
+    {
+        String name = row.getString("column_name");
+        AbstractType<?> type = CQLTypeParser.parse(keyspace, row.getString("type"),
Types.none());
+        ColumnMetadata.Kind kind = ColumnMetadata.Kind.valueOf(row.getString("kind").toUpperCase());
+        ColumnMetadata column = new ColumnMetadata(keyspace, table, ColumnIdentifier.getInterned(name,
true), type, ColumnMetadata.NO_POSITION, kind);
+        long droppedTime = row.getTimestamp("dropped_time").getTime();
+        return new DroppedColumn(column, droppedTime);
+    }
 }


Mime
View raw message