cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject git commit: Don't duplicate sstables smaller than split size
Date Wed, 08 Oct 2014 15:57:45 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 38fe0cae5 -> 186e994e2


Don't duplicate sstables smaller than split size

Patch by Changsu Jiang; reviewed by Tyler Hobbs for CASSANDRA-7616


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

Branch: refs/heads/cassandra-2.1
Commit: 186e994e28d24e43989d41f271266dc6e5bc9c43
Parents: 38fe0ca
Author: Changsu Jiang <chsjiang@gmail.com>
Authored: Wed Oct 8 10:56:59 2014 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Wed Oct 8 10:56:59 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                         |  2 ++
 .../apache/cassandra/tools/StandaloneSplitter.java  | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/186e994e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b6299c7..c6735bc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.1.1
+ * Don't duplicate sstables smaller than split size when using
+   the sstablesplitter tool (CASSANDRA-7616)
  * Avoid re-parsing already prepared statements (CASSANDRA-7923)
  * Fix some Thrift slice deletions and updates of COMPACT STORAGE
    tables with some clustering columns omitted (CASSANDRA-7990)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/186e994e/src/java/org/apache/cassandra/tools/StandaloneSplitter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/StandaloneSplitter.java b/src/java/org/apache/cassandra/tools/StandaloneSplitter.java
index 9353ce9..75ad959 100644
--- a/src/java/org/apache/cassandra/tools/StandaloneSplitter.java
+++ b/src/java/org/apache/cassandra/tools/StandaloneSplitter.java
@@ -116,6 +116,11 @@ public class StandaloneSplitter
                 try
                 {
                     SSTableReader sstable = SSTableReader.openNoValidation(fn.getKey(), fn.getValue(),
cfs.metadata);
+                    if (!isSSTableLargerEnough(sstable, options.sizeInMB)) {
+                        System.out.println(String.format("Skipping %s: it's size (%.3f MB)
is less than the split size (%d MB)",
+                                sstable.getFilename(), ((sstable.onDiskLength() * 1.0d) /
1024L) / 1024L, options.sizeInMB));
+                        continue;
+                    }
                     sstables.add(sstable);
 
                     if (options.snapshot) {
@@ -131,6 +136,10 @@ public class StandaloneSplitter
                         e.printStackTrace(System.err);
                 }
             }
+            if (sstables.isEmpty()) {
+                System.out.println("No sstables needed splitting.");
+                System.exit(0);
+            }
             if (options.snapshot)
                 System.out.println(String.format("Pre-split sstables snapshotted into snapshot
%s", snapshotName));
 
@@ -160,6 +169,13 @@ public class StandaloneSplitter
         }
     }
 
+    /**
+     * filter the sstable which size is less than the expected max sstable size.
+     */
+    private static boolean isSSTableLargerEnough(SSTableReader sstable, int sizeInMB) {
+        return sstable.onDiskLength() > sizeInMB * 1024L * 1024L;
+    }
+
     private static class Options
     {
         public final List<String> filenames;


Mime
View raw message