You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sa...@apache.org on 2016/03/16 12:18:47 UTC

[3/6] cassandra git commit: SSTableExport supports secondary index tables

SSTableExport supports secondary index tables

Patch by Sam Tunnicliffe; reviewed by Yuki Morishita for CASSANDRA-11330


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

Branch: refs/heads/trunk
Commit: 0a5e2204ce74390bfbeb3fa3d74914cf47a13258
Parents: dcc57d0
Author: Sam Tunnicliffe <sa...@beobal.com>
Authored: Wed Mar 9 18:59:20 2016 +0000
Committer: Sam Tunnicliffe <sa...@beobal.com>
Committed: Wed Mar 16 11:07:24 2016 +0000

----------------------------------------------------------------------
 CHANGES.txt                                           |  1 +
 .../org/apache/cassandra/db/SerializationHeader.java  |  2 +-
 .../org/apache/cassandra/tools/SSTableExport.java     | 14 ++++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0a5e2204/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 87691f9..28de247 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.5
+ * SSTableExport supports secondary index tables (CASSANDRA-11330)
  * Fix sstabledump to include missing info in debug output (CASSANDRA-11321)
  * Establish and implement canonical bulk reading workload(s) (CASSANDRA-10331)
  * Fix paging for IN queries on tables without clustering columns (CASSANDRA-11208)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0a5e2204/src/java/org/apache/cassandra/db/SerializationHeader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SerializationHeader.java b/src/java/org/apache/cassandra/db/SerializationHeader.java
index 6aee0b6..6e03756 100644
--- a/src/java/org/apache/cassandra/db/SerializationHeader.java
+++ b/src/java/org/apache/cassandra/db/SerializationHeader.java
@@ -362,7 +362,7 @@ public class SerializationHeader
                                  keyType, clusteringTypes, staticColumns, regularColumns, stats);
         }
 
-        public AbstractType<?> getKetType()
+        public AbstractType<?> getKeyType()
         {
             return keyType;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0a5e2204/src/java/org/apache/cassandra/tools/SSTableExport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/SSTableExport.java b/src/java/org/apache/cassandra/tools/SSTableExport.java
index 3ee9193..fd3b9cb 100644
--- a/src/java/org/apache/cassandra/tools/SSTableExport.java
+++ b/src/java/org/apache/cassandra/tools/SSTableExport.java
@@ -35,10 +35,9 @@ import org.apache.cassandra.db.PartitionPosition;
 import org.apache.cassandra.db.SerializationHeader;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.db.rows.UnfilteredRowIterator;
-import org.apache.cassandra.dht.AbstractBounds;
-import org.apache.cassandra.dht.Bounds;
-import org.apache.cassandra.dht.IPartitioner;
+import org.apache.cassandra.dht.*;
 import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.index.SecondaryIndexManager;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.sstable.ISSTableScanner;
 import org.apache.cassandra.io.sstable.KeyIterator;
@@ -100,7 +99,10 @@ public class SSTableExport
         ValidationMetadata validationMetadata = (ValidationMetadata) sstableMetadata.get(MetadataType.VALIDATION);
         SerializationHeader.Component header = (SerializationHeader.Component) sstableMetadata.get(MetadataType.HEADER);
 
-        IPartitioner partitioner = FBUtilities.newPartitioner(validationMetadata.partitioner);
+        IPartitioner partitioner = SecondaryIndexManager.isIndexColumnFamily(desc.cfname)
+                                   ? new LocalPartitioner(header.getKeyType())
+                                   : FBUtilities.newPartitioner(validationMetadata.partitioner);
+
         CFMetaData.Builder builder = CFMetaData.Builder.create("keyspace", "table").withPartitioner(partitioner);
         header.getStaticColumns().entrySet().stream()
                 .forEach(entry -> {
@@ -112,7 +114,7 @@ public class SSTableExport
                     ColumnIdentifier ident = ColumnIdentifier.getInterned(UTF8Type.instance.getString(entry.getKey()), true);
                     builder.addRegularColumn(ident, entry.getValue());
                 });
-        builder.addPartitionKey("PartitionKey", header.getKetType());
+        builder.addPartitionKey("PartitionKey", header.getKeyType());
         for (int i = 0; i < header.getClusteringTypes().size(); i++)
         {
             builder.addClusteringColumn("clustering" + (i > 0 ? i : ""), header.getClusteringTypes().get(i));
@@ -250,4 +252,4 @@ public class SSTableExport
         String header = "Dump contents of given SSTable to standard output in JSON format.";
         new HelpFormatter().printHelp(usage, header, options, "");
     }
-}
\ No newline at end of file
+}