You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by db...@apache.org on 2014/11/30 01:20:44 UTC
cassandra git commit: use try-with-resources
Repository: cassandra
Updated Branches:
refs/heads/trunk 1850ec727 -> f0ea366b3
use try-with-resources
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f0ea366b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f0ea366b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f0ea366b
Branch: refs/heads/trunk
Commit: f0ea366b3d7733572e7de6a2eb3c9c197f484864
Parents: 1850ec7
Author: Dave Brosius <db...@mebigfatguy.com>
Authored: Sat Nov 29 19:19:54 2014 -0500
Committer: Dave Brosius <db...@mebigfatguy.com>
Committed: Sat Nov 29 19:19:54 2014 -0500
----------------------------------------------------------------------
.../cassandra/io/sstable/SSTableLoaderTest.java | 14 +++--
.../io/sstable/SSTableSimpleWriterTest.java | 62 ++++++++++----------
2 files changed, 39 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ea366b/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java
index 815fc68..b245994 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java
@@ -70,14 +70,16 @@ public class SSTableLoaderTest
File dataDir = new File(tempdir.getAbsolutePath() + File.separator + KEYSPACE1 + File.separator + CF_STANDARD);
assert dataDir.mkdirs();
CFMetaData cfmeta = Schema.instance.getCFMetaData(KEYSPACE1, CF_STANDARD);
- SSTableSimpleUnsortedWriter writer = new SSTableSimpleUnsortedWriter(dataDir,
+ DecoratedKey key = Util.dk("key1");
+
+ try (SSTableSimpleUnsortedWriter writer = new SSTableSimpleUnsortedWriter(dataDir,
cfmeta,
StorageService.getPartitioner(),
- 1);
- DecoratedKey key = Util.dk("key1");
- writer.newRow(key.getKey());
- writer.addColumn(ByteBufferUtil.bytes("col1"), ByteBufferUtil.bytes(100), 1);
- writer.close();
+ 1))
+ {
+ writer.newRow(key.getKey());
+ writer.addColumn(ByteBufferUtil.bytes("col1"), ByteBufferUtil.bytes(100), 1);
+ }
SSTableLoader loader = new SSTableLoader(dataDir, new SSTableLoader.Client()
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ea366b/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
index df9c56b..499caf7 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
@@ -64,42 +64,42 @@ public class SSTableSimpleWriterTest
assert dir.exists();
IPartitioner partitioner = StorageService.getPartitioner();
- SSTableSimpleUnsortedWriter writer = new SSTableSimpleUnsortedWriter(dir, partitioner, keyspaceName, cfname, IntegerType.instance, null, 16);
-
- int k = 0;
-
- // Adding a few rows first
- for (; k < 10; ++k)
+ try (SSTableSimpleUnsortedWriter writer = new SSTableSimpleUnsortedWriter(dir, partitioner, keyspaceName, cfname, IntegerType.instance, null, 16))
{
- writer.newRow(bytes("Key" + k));
- writer.addColumn(bytes(1), bytes("v"), 0);
- writer.addColumn(bytes(2), bytes("v"), 0);
- writer.addColumn(bytes(3), bytes("v"), 0);
- }
-
- // Testing multiple opening of the same row
- // We'll write column 0, 5, 10, .., on the first row, then 1, 6, 11, ... on the second one, etc.
- for (int i = 0; i < INC; ++i)
- {
- writer.newRow(bytes("Key" + k));
- for (int j = 0; j < NBCOL; ++j)
+ int k = 0;
+
+ // Adding a few rows first
+ for (; k < 10; ++k)
{
- writer.addColumn(bytes(i + INC * j), bytes("v"), 1);
+ writer.newRow(bytes("Key" + k));
+ writer.addColumn(bytes(1), bytes("v"), 0);
+ writer.addColumn(bytes(2), bytes("v"), 0);
+ writer.addColumn(bytes(3), bytes("v"), 0);
+ }
+
+
+ // Testing multiple opening of the same row
+ // We'll write column 0, 5, 10, .., on the first row, then 1, 6, 11, ... on the second one, etc.
+ for (int i = 0; i < INC; ++i)
+ {
+ writer.newRow(bytes("Key" + k));
+ for (int j = 0; j < NBCOL; ++j)
+ {
+ writer.addColumn(bytes(i + INC * j), bytes("v"), 1);
+ }
+ }
+ k++;
+
+ // Adding a few more rows
+ for (; k < 20; ++k)
+ {
+ writer.newRow(bytes("Key" + k));
+ writer.addColumn(bytes(1), bytes("v"), 0);
+ writer.addColumn(bytes(2), bytes("v"), 0);
+ writer.addColumn(bytes(3), bytes("v"), 0);
}
}
- k++;
-
- // Adding a few more rows
- for (; k < 20; ++k)
- {
- writer.newRow(bytes("Key" + k));
- writer.addColumn(bytes(1), bytes("v"), 0);
- writer.addColumn(bytes(2), bytes("v"), 0);
- writer.addColumn(bytes(3), bytes("v"), 0);
- }
-
- writer.close();
// Now add that newly created files to the column family
ColumnFamilyStore cfs = t.getColumnFamilyStore(cfname);