cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1050410 - in /cassandra/branches/cassandra-0.6: CHANGES.txt src/java/org/apache/cassandra/tools/SSTableExport.java
Date Fri, 17 Dec 2010 15:00:07 GMT
Author: jbellis
Date: Fri Dec 17 15:00:06 2010
New Revision: 1050410

URL: http://svn.apache.org/viewvc?rev=1050410&view=rev
Log:
large row support for SSTableExport
patch by Ilya Mykov; reviewed by jbellis for CASSANDRA-1867

Modified:
    cassandra/branches/cassandra-0.6/CHANGES.txt
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/SSTableExport.java

Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=1050410&r1=1050409&r2=1050410&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Fri Dec 17 15:00:06 2010
@@ -22,6 +22,7 @@
  * change exception for read requests during bootstrap from 
    InvalidRequest to Unavailable (CASSANDRA-1862)
  * make compaction buckets deterministic (CASSANDRA-1265)
+ * large row support for SSTableExport (CASSANDRA-1867)
 
 
 0.6.8

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/SSTableExport.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/SSTableExport.java?rev=1050410&r1=1050409&r2=1050410&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/SSTableExport.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/SSTableExport.java
Fri Dec 17 15:00:06 2010
@@ -80,66 +80,62 @@ public class SSTableExport
         return String.format("%s: ", quote(val));
     }
     
-    private static String serializeColumns(Collection<IColumn> cols, AbstractType comp)
+    private static void serializeColumns(PrintStream outs, Collection<IColumn> cols,
AbstractType comp)
     {
-        StringBuilder json = new StringBuilder("[");
+        outs.print("[");
         
         Iterator<IColumn> iter = cols.iterator();
         while (iter.hasNext())
         {
-            json.append("[");
+            outs.print("[");
             IColumn column = iter.next();
-            json.append(quote(bytesToHex(column.name())));
-            json.append(", ");
-            json.append(quote(bytesToHex(column.value())));
-            json.append(", ");
-            json.append(column.timestamp());
-            json.append(", ");
-            json.append(column.isMarkedForDelete());
-            json.append("]");
+            outs.print(quote(bytesToHex(column.name())));
+            outs.print(", ");
+            outs.print(quote(bytesToHex(column.value())));
+            outs.print(", ");
+            outs.print(column.timestamp());
+            outs.print(", ");
+            outs.print(column.isMarkedForDelete());
+            outs.print("]");
             if (iter.hasNext())
-                json.append(", ");
+                outs.print(", ");
         }
         
-        json.append("]");
-        
-        return json.toString();
+        outs.print("]");
     }
     
-    private static String serializeRow(IteratingRow row) throws IOException
+    private static void serializeRow(PrintStream outs, IteratingRow row) throws IOException
     {
         ColumnFamily cf = row.getColumnFamily();
         AbstractType comparator = cf.getComparator();
-        StringBuilder json = new StringBuilder(asKey(row.getKey().key));
+        outs.print(asKey(row.getKey().key));
         
         if (cf.isSuper())
         {
-            json.append("{ ");
+            outs.print("{ ");
 
             Iterator<IColumn> iter = cf.getSortedColumns().iterator();
             while (iter.hasNext())
             {
                 IColumn column = iter.next();
-                json.append(asKey(bytesToHex(column.name())));
-                json.append("{");
-                json.append(asKey("deletedAt"));
-                json.append(column.getMarkedForDeleteAt());
-                json.append(", ");
-                json.append(asKey("subColumns"));
-                json.append(serializeColumns(column.getSubColumns(), comparator));
-                json.append("}");
+                outs.print(asKey(bytesToHex(column.name())));
+                outs.print("{");
+                outs.print(asKey("deletedAt"));
+                outs.print(column.getMarkedForDeleteAt());
+                outs.print(", ");
+                outs.print(asKey("subColumns"));
+                serializeColumns(outs, column.getSubColumns(), comparator);
+                outs.print("}");
                 if (iter.hasNext())
-                    json.append(", ");
+                    outs.print(", ");
             }
             
-            json.append("}");
+            outs.print("}");
         }
         else
         {
-            json.append(serializeColumns(cf.getSortedColumns(), comparator));
+            serializeColumns(outs, cf.getSortedColumns(), comparator);
         }
-     
-        return json.toString();
     }
 
     /**
@@ -214,10 +210,10 @@ public class SSTableExport
                 IteratingRow row = scanner.next();
                 try
                 {
-                    String jsonOut = serializeRow(row);
                     if (i != 1)
                         outs.println(",");
-                    outs.print("  " + jsonOut);
+                    outs.print("  ");
+                    serializeRow(outs, row);
                 }
                 catch (IOException ioexc)
                 {
@@ -269,8 +265,8 @@ public class SSTableExport
                 continue;
             try
             {
-                String jsonOut = serializeRow(row);
-                outs.print("  " + jsonOut);
+                outs.print("  ");
+                serializeRow(outs, row);
                 if (scanner.hasNext())
                     outs.println(",");
                 else



Mime
View raw message