cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [3/3] git commit: Merge branch 'cassandra-2.1.0' into cassandra-2.1
Date Thu, 07 Aug 2014 14:22:52 GMT
Merge branch 'cassandra-2.1.0' into cassandra-2.1

Conflicts:
	src/java/org/apache/cassandra/tools/SSTableExport.java


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

Branch: refs/heads/cassandra-2.1
Commit: ddda54145e1c8dc77a105c5ef5d87645ed321fb8
Parents: 78b734e eea547c
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Thu Aug 7 16:22:36 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Thu Aug 7 16:22:36 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../apache/cassandra/tools/SSTableExport.java   | 132 ++++++++++---------
 2 files changed, 74 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ddda5414/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ddda5414/src/java/org/apache/cassandra/tools/SSTableExport.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/tools/SSTableExport.java
index c4d693c,3572296..fca1384
--- a/src/java/org/apache/cassandra/tools/SSTableExport.java
+++ b/src/java/org/apache/cassandra/tools/SSTableExport.java
@@@ -226,20 -228,26 +226,26 @@@ public class SSTableExpor
      throws IOException
      {
          KeyIterator iter = new KeyIterator(desc);
-         DecoratedKey lastKey = null;
-         while (iter.hasNext())
+         try
          {
-             DecoratedKey key = iter.next();
- 
-             // validate order of the keys in the sstable
-             if (lastKey != null && lastKey.compareTo(key) > 0)
-                 throw new IOException("Key out of order! " + lastKey + " > " + key);
-             lastKey = key;
- 
-             outs.println(metadata.getKeyValidator().getString(key.getKey()));
-             checkStream(outs); // flushes
+             DecoratedKey lastKey = null;
+             while (iter.hasNext())
+             {
+                 DecoratedKey key = iter.next();
+ 
+                 // validate order of the keys in the sstable
+                 if (lastKey != null && lastKey.compareTo(key) > 0)
+                     throw new IOException("Key out of order! " + lastKey + " > " + key);
+                 lastKey = key;
+ 
 -                outs.println(bytesToHex(key.getKey()));
++                outs.println(metadata.getKeyValidator().getString(key.getKey()));
+                 checkStream(outs); // flushes
+             }
+         }
+         finally
+         {
+             iter.close();
          }
-         iter.close();
      }
  
      /**
@@@ -256,47 -263,53 +262,52 @@@
      {
          SSTableReader sstable = SSTableReader.open(desc);
          RandomAccessReader dfile = sstable.openDataReader();
+         try
+         {
+             IPartitioner<?> partitioner = sstable.partitioner;
  
-         IPartitioner<?> partitioner = sstable.partitioner;
- 
-         if (excludes != null)
-             toExport.removeAll(Arrays.asList(excludes));
+             if (excludes != null)
+                 toExport.removeAll(Arrays.asList(excludes));
  
-         outs.println("[");
+             outs.println("[");
  
-         int i = 0;
+             int i = 0;
  
-         // last key to compare order
-         DecoratedKey lastKey = null;
+             // last key to compare order
+             DecoratedKey lastKey = null;
  
-         for (String key : toExport)
-         {
-             DecoratedKey decoratedKey = partitioner.decorateKey(metadata.getKeyValidator().fromString(key));
+             for (String key : toExport)
+             {
 -                DecoratedKey decoratedKey = partitioner.decorateKey(hexToBytes(key));
 -
++                DecoratedKey decoratedKey = partitioner.decorateKey(metadata.getKeyValidator().fromString(key));
+                 if (lastKey != null && lastKey.compareTo(decoratedKey) > 0)
+                     throw new IOException("Key out of order! " + lastKey + " > " + decoratedKey);
  
-             if (lastKey != null && lastKey.compareTo(decoratedKey) > 0)
-                 throw new IOException("Key out of order! " + lastKey + " > " + decoratedKey);
+                 lastKey = decoratedKey;
  
-             lastKey = decoratedKey;
+                 RowIndexEntry entry = sstable.getPosition(decoratedKey, SSTableReader.Operator.EQ);
+                 if (entry == null)
+                     continue;
  
-             RowIndexEntry entry = sstable.getPosition(decoratedKey, SSTableReader.Operator.EQ);
-             if (entry == null)
-                 continue;
+                 dfile.seek(entry.position);
+                 ByteBufferUtil.readWithShortLength(dfile); // row key
+                 DeletionInfo deletionInfo = new DeletionInfo(DeletionTime.serializer.deserialize(dfile));
  
-             dfile.seek(entry.position);
-             ByteBufferUtil.readWithShortLength(dfile); // row key
-             DeletionInfo deletionInfo = new DeletionInfo(DeletionTime.serializer.deserialize(dfile));
-             Iterator<OnDiskAtom> atomIterator = sstable.metadata.getOnDiskIterator(dfile,
sstable.descriptor.version);
+                 Iterator<OnDiskAtom> atomIterator = sstable.metadata.getOnDiskIterator(dfile,
sstable.descriptor.version);
+                 checkStream(outs);
  
-             checkStream(outs);
+                 if (i != 0)
+                     outs.println(",");
+                 i++;
+                 serializeRow(deletionInfo, atomIterator, sstable.metadata, decoratedKey,
outs);
+             }
  
-             if (i != 0)
-                 outs.println(",");
-             i++;
-             serializeRow(deletionInfo, atomIterator, sstable.metadata, decoratedKey, outs);
+             outs.println("\n]");
+             outs.flush();
+         }
+         finally
+         {
+             dfile.close();
          }
- 
-         outs.println("\n]");
-         outs.flush();
      }
  
      // This is necessary to accommodate the test suite since you cannot open a Reader more
@@@ -308,36 -321,39 +319,39 @@@
          if (excludes != null)
              excludeSet = new HashSet<String>(Arrays.asList(excludes));
  
- 
          SSTableIdentityIterator row;
          SSTableScanner scanner = reader.getScanner();
+         try
+         {
+             outs.println("[");
  
-         outs.println("[");
+             int i = 0;
  
-         int i = 0;
+             // collecting keys to export
+             while (scanner.hasNext())
+             {
+                 row = (SSTableIdentityIterator) scanner.next();
  
-         // collecting keys to export
-         while (scanner.hasNext())
-         {
-             row = (SSTableIdentityIterator) scanner.next();
 -                String currentKey = bytesToHex(row.getKey().getKey());
++                String currentKey = row.getColumnFamily().metadata().getKeyValidator().getString(row.getKey().getKey());
  
-             String currentKey = row.getColumnFamily().metadata().getKeyValidator().getString(row.getKey().getKey());
+                 if (excludeSet.contains(currentKey))
+                     continue;
+                 else if (i != 0)
+                     outs.println(",");
  
-             if (excludeSet.contains(currentKey))
-                 continue;
-             else if (i != 0)
-                 outs.println(",");
+                 serializeRow(row, row.getKey(), outs);
+                 checkStream(outs);
  
-             serializeRow(row, row.getKey(), outs);
-             checkStream(outs);
+                 i++;
+             }
  
-             i++;
+             outs.println("\n]");
+             outs.flush();
+         }
+         finally
+         {
+             scanner.close();
          }
- 
-         outs.println("\n]");
-         outs.flush();
- 
-         scanner.close();
      }
  
      /**


Mime
View raw message