Updated Branches: refs/heads/trunk 881429ff8 -> ecaa6cd1b
Revert "add single-CF specialization of RowMutation constructor" This reverts commit a9b075d5fa9d6ee9df1d30a6ee969896b3b99f63. Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ecaa6cd1 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ecaa6cd1 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ecaa6cd1 Branch: refs/heads/trunk Commit: ecaa6cd1b74b8caeec03e505f04d676414bb633d Parents: 881429f Author: Brandon Williams <[email protected]> Authored: Mon Mar 4 20:35:28 2013 -0600 Committer: Brandon Williams <[email protected]> Committed: Mon Mar 4 20:35:28 2013 -0600 ---------------------------------------------------------------------- .../org/apache/cassandra/db/BatchlogManager.java | 4 +- .../apache/cassandra/db/CollationController.java | 2 +- .../org/apache/cassandra/db/CounterColumn.java | 3 +- src/java/org/apache/cassandra/db/RowMutation.java | 10 +--- src/java/org/apache/cassandra/db/SystemTable.java | 6 ++- .../apache/cassandra/service/RowDataResolver.java | 3 +- .../org/apache/cassandra/tracing/TraceState.java | 3 +- src/java/org/apache/cassandra/tracing/Tracing.java | 6 ++- .../apache/cassandra/db/ColumnFamilyStoreTest.java | 6 ++- .../org/apache/cassandra/db/MultitableTest.java | 6 ++- .../apache/cassandra/db/RecoveryManager2Test.java | 3 +- .../apache/cassandra/db/RecoveryManager3Test.java | 6 ++- .../apache/cassandra/db/RecoveryManagerTest.java | 9 ++- .../cassandra/db/RecoveryManagerTruncateTest.java | 3 +- test/unit/org/apache/cassandra/db/ScrubTest.java | 8 ++- .../apache/cassandra/db/SerializationsTest.java | 6 ++- test/unit/org/apache/cassandra/db/TableTest.java | 37 ++++++++++----- .../cassandra/streaming/StreamingTransferTest.java | 6 ++- 18 files changed, 82 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/db/BatchlogManager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/BatchlogManager.java b/src/java/org/apache/cassandra/db/BatchlogManager.java index 3229941..fcbfa9b 100644 --- a/src/java/org/apache/cassandra/db/BatchlogManager.java +++ b/src/java/org/apache/cassandra/db/BatchlogManager.java @@ -137,8 +137,10 @@ public class BatchlogManager implements BatchlogManagerMBean ColumnFamily cf = ColumnFamily.create(CFMetaData.BatchlogCF); cf.addColumn(new Column(WRITTEN_AT, writtenAt, timestamp)); cf.addColumn(new Column(DATA, data, timestamp)); + RowMutation rm = new RowMutation(Table.SYSTEM_KS, UUIDType.instance.decompose(uuid)); + rm.add(cf); - return new RowMutation(Table.SYSTEM_KS, UUIDType.instance.decompose(uuid), cf); + return rm; } private static ByteBuffer serializeRowMutations(Collection<RowMutation> mutations) http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/db/CollationController.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/CollationController.java b/src/java/org/apache/cassandra/db/CollationController.java index eb065d6..3e659cb 100644 --- a/src/java/org/apache/cassandra/db/CollationController.java +++ b/src/java/org/apache/cassandra/db/CollationController.java @@ -186,7 +186,7 @@ public class CollationController && cfs.getCompactionStrategy() instanceof SizeTieredCompactionStrategy) { Tracing.trace("Defragmenting requested data"); - RowMutation rm = new RowMutation(cfs.table.getName(), filter.key.key, returnCF.cloneMe()); + RowMutation rm = new RowMutation(cfs.table.getName(), new Row(filter.key, returnCF.cloneMe())); // skipping commitlog and index updates is fine since we're just de-fragmenting existing data Table.open(rm.getTable()).apply(rm, false, false); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/db/CounterColumn.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/CounterColumn.java b/src/java/org/apache/cassandra/db/CounterColumn.java index f94672d..a24687b 100644 --- a/src/java/org/apache/cassandra/db/CounterColumn.java +++ b/src/java/org/apache/cassandra/db/CounterColumn.java @@ -346,7 +346,8 @@ public class CounterColumn extends Column private static void sendToOtherReplica(DecoratedKey key, ColumnFamily cf) throws RequestExecutionException, IOException { - RowMutation rm = new RowMutation(cf.metadata().ksName, key.key, cf); + RowMutation rm = new RowMutation(cf.metadata().ksName, key.key); + rm.add(cf); final InetAddress local = FBUtilities.getBroadcastAddress(); String localDataCenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(local); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/db/RowMutation.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java index 465891b..f17bb54 100644 --- a/src/java/org/apache/cassandra/db/RowMutation.java +++ b/src/java/org/apache/cassandra/db/RowMutation.java @@ -56,14 +56,10 @@ public class RowMutation implements IMutation this(table, key, new HashMap<UUID, ColumnFamily>()); } - public RowMutation(String table, ByteBuffer key, ColumnFamily cf) - { - this(table, key, Collections.singletonMap(cf.id(), cf)); - } - public RowMutation(String table, Row row) { - this(table, row.key.key, row.cf); + this(table, row.key.key); + add(row.cf); } protected RowMutation(String table, ByteBuffer key, Map<UUID, ColumnFamily> modifications) @@ -104,6 +100,7 @@ public class RowMutation implements IMutation */ public static RowMutation hintFor(RowMutation mutation, UUID targetId) throws IOException { + RowMutation rm = new RowMutation(Table.SYSTEM_KS, UUIDType.instance.decompose(targetId)); UUID hintId = UUIDGen.getTimeUUID(); // determine the TTL for the RowMutation @@ -116,7 +113,6 @@ public class RowMutation implements IMutation // serialize the hint with id and version as a composite column name ByteBuffer name = HintedHandOffManager.comparator.decompose(hintId, MessagingService.current_version); ByteBuffer value = ByteBuffer.wrap(FBUtilities.serialize(mutation, serializer, MessagingService.current_version)); - RowMutation rm = new RowMutation(Table.SYSTEM_KS, UUIDType.instance.decompose(targetId)); rm.add(SystemTable.HINTS_CF, name, value, System.currentTimeMillis(), ttl); return rm; http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/db/SystemTable.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java index 70152d3..85547cd 100644 --- a/src/java/org/apache/cassandra/db/SystemTable.java +++ b/src/java/org/apache/cassandra/db/SystemTable.java @@ -607,7 +607,8 @@ public class SystemTable { ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_KS, INDEX_CF); cf.addColumn(new Column(ByteBufferUtil.bytes(indexName), ByteBufferUtil.EMPTY_BYTE_BUFFER, FBUtilities.timestampMicros())); - RowMutation rm = new RowMutation(Table.SYSTEM_KS, ByteBufferUtil.bytes(table), cf); + RowMutation rm = new RowMutation(Table.SYSTEM_KS, ByteBufferUtil.bytes(table)); + rm.add(cf); rm.apply(); forceBlockingFlush(INDEX_CF); } @@ -683,7 +684,8 @@ public class SystemTable ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_KS, COUNTER_ID_CF); cf.addColumn(new Column(newCounterId.bytes(), ip, now)); - RowMutation rm = new RowMutation(Table.SYSTEM_KS, ALL_LOCAL_NODE_ID_KEY, cf); + RowMutation rm = new RowMutation(Table.SYSTEM_KS, ALL_LOCAL_NODE_ID_KEY); + rm.add(cf); rm.apply(); forceBlockingFlush(COUNTER_ID_CF); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/service/RowDataResolver.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/RowDataResolver.java b/src/java/org/apache/cassandra/service/RowDataResolver.java index 1d57531..e04d7c5 100644 --- a/src/java/org/apache/cassandra/service/RowDataResolver.java +++ b/src/java/org/apache/cassandra/service/RowDataResolver.java @@ -119,7 +119,8 @@ public class RowDataResolver extends AbstractRowResolver continue; // create and send the row mutation message based on the diff - RowMutation rowMutation = new RowMutation(table, key.key, diffCf); + RowMutation rowMutation = new RowMutation(table, key.key); + rowMutation.add(diffCf); MessageOut repairMessage; // use a separate verb here because we don't want these to be get the white glove hint- // on-timeout behavior that a "real" mutation gets http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/tracing/TraceState.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tracing/TraceState.java b/src/java/org/apache/cassandra/tracing/TraceState.java index 9cdb0f3..8fb3119 100644 --- a/src/java/org/apache/cassandra/tracing/TraceState.java +++ b/src/java/org/apache/cassandra/tracing/TraceState.java @@ -99,7 +99,8 @@ public class TraceState Tracing.addColumn(cf, Tracing.buildName(cfMeta, eventId, ByteBufferUtil.bytes("thread")), threadName); Tracing.addColumn(cf, Tracing.buildName(cfMeta, eventId, ByteBufferUtil.bytes("source_elapsed")), elapsed); Tracing.addColumn(cf, Tracing.buildName(cfMeta, eventId, ByteBufferUtil.bytes("activity")), message); - RowMutation mutation = new RowMutation(Tracing.TRACE_KS, sessionIdBytes, cf); + RowMutation mutation = new RowMutation(Tracing.TRACE_KS, sessionIdBytes); + mutation.add(cf); StorageProxy.mutate(Arrays.asList(mutation), ConsistencyLevel.ANY); } }); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/src/java/org/apache/cassandra/tracing/Tracing.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tracing/Tracing.java b/src/java/org/apache/cassandra/tracing/Tracing.java index 6281ca7..17241b9 100644 --- a/src/java/org/apache/cassandra/tracing/Tracing.java +++ b/src/java/org/apache/cassandra/tracing/Tracing.java @@ -178,7 +178,8 @@ public class Tracing CFMetaData cfMeta = CFMetaData.TraceSessionsCf; ColumnFamily cf = ColumnFamily.create(cfMeta); addColumn(cf, buildName(cfMeta, bytes("duration")), elapsed); - RowMutation mutation = new RowMutation(TRACE_KS, sessionIdBytes, cf); + RowMutation mutation = new RowMutation(TRACE_KS, sessionIdBytes); + mutation.add(cf); StorageProxy.mutate(Arrays.asList(mutation), ConsistencyLevel.ANY); } }); @@ -220,7 +221,8 @@ public class Tracing addColumn(cf, buildName(cfMeta, bytes("request")), request); addColumn(cf, buildName(cfMeta, bytes("started_at")), started_at); addParameterColumns(cf, parameters); - RowMutation mutation = new RowMutation(TRACE_KS, sessionIdBytes, cf); + RowMutation mutation = new RowMutation(TRACE_KS, sessionIdBytes); + mutation.add(cf); StorageProxy.mutate(Arrays.asList(mutation), ConsistencyLevel.ANY); } }); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java index c17a688..e92c4b7 100644 --- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java +++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java @@ -723,19 +723,21 @@ public class ColumnFamilyStoreTest extends SchemaLoader private static void putColsSuper(ColumnFamilyStore cfs, DecoratedKey key, ByteBuffer scfName, Column... cols) throws Throwable { + RowMutation rm = new RowMutation(cfs.table.getName(), key.key); ColumnFamily cf = ColumnFamily.create(cfs.table.getName(), cfs.name); for (Column col : cols) cf.addColumn(col.withUpdatedName(CompositeType.build(scfName, col.name()))); - RowMutation rm = new RowMutation(cfs.table.getName(), key.key, cf); + rm.add(cf); rm.apply(); } private static void putColsStandard(ColumnFamilyStore cfs, DecoratedKey key, Column... cols) throws Throwable { + RowMutation rm = new RowMutation(cfs.table.getName(), key.key); ColumnFamily cf = ColumnFamily.create(cfs.table.getName(), cfs.name); for (Column col : cols) cf.addColumn(col); - RowMutation rm = new RowMutation(cfs.table.getName(), key.key, cf); + rm.add(cf); rm.apply(); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/MultitableTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/MultitableTest.java b/test/unit/org/apache/cassandra/db/MultitableTest.java index c22bf0d..1b22ce3 100644 --- a/test/unit/org/apache/cassandra/db/MultitableTest.java +++ b/test/unit/org/apache/cassandra/db/MultitableTest.java @@ -43,14 +43,16 @@ public class MultitableTest extends SchemaLoader DecoratedKey dk = Util.dk("keymulti"); ColumnFamily cf; + rm = new RowMutation("Keyspace1", dk.key); cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "val1", 1L)); - rm = new RowMutation("Keyspace1", dk.key, cf); + rm.add(cf); rm.apply(); + rm = new RowMutation("Keyspace2", dk.key); cf = ColumnFamily.create("Keyspace2", "Standard1"); cf.addColumn(column("col2", "val2", 1L)); - rm = new RowMutation("Keyspace2", dk.key, cf); + rm.add(cf); rm.apply(); table1.getColumnFamilyStore("Standard1").forceBlockingFlush(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java b/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java index 030e7ba..9787c7f 100644 --- a/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java +++ b/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java @@ -71,9 +71,10 @@ public class RecoveryManager2Test extends SchemaLoader private void insertRow(String cfname, String key) throws IOException { + RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key)); ColumnFamily cf = ColumnFamily.create("Keyspace1", cfname); cf.addColumn(column("col1", "val1", 1L)); - RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key), cf); + rm.add(cf); rm.apply(); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java b/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java index b63be9e..f45b5da 100644 --- a/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java +++ b/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java @@ -48,14 +48,16 @@ public class RecoveryManager3Test extends SchemaLoader DecoratedKey dk = Util.dk("keymulti"); ColumnFamily cf; + rm = new RowMutation("Keyspace1", dk.key); cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "val1", 1L)); - rm = new RowMutation("Keyspace1", dk.key, cf); + rm.add(cf); rm.apply(); + rm = new RowMutation("Keyspace2", dk.key); cf = ColumnFamily.create("Keyspace2", "Standard3"); cf.addColumn(column("col2", "val2", 1L)); - rm = new RowMutation("Keyspace2", dk.key, cf); + rm.add(cf); rm.apply(); table1.getColumnFamilyStore("Standard1").clearUnsafe(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java b/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java index e521e08..96889b8 100644 --- a/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java +++ b/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java @@ -48,14 +48,16 @@ public class RecoveryManagerTest extends SchemaLoader DecoratedKey dk = Util.dk("keymulti"); ColumnFamily cf; + rm = new RowMutation("Keyspace1", dk.key); cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "val1", 1L)); - rm = new RowMutation("Keyspace1", dk.key, cf); + rm.add(cf); rm.apply(); + rm = new RowMutation("Keyspace2", dk.key); cf = ColumnFamily.create("Keyspace2", "Standard3"); cf.addColumn(column("col2", "val2", 1L)); - rm = new RowMutation("Keyspace2", dk.key, cf); + rm.add(cf); rm.apply(); table1.getColumnFamilyStore("Standard1").clearUnsafe(); @@ -79,9 +81,10 @@ public class RecoveryManagerTest extends SchemaLoader for (int i = 0; i < 10; ++i) { + rm = new RowMutation("Keyspace1", dk.key); cf = ColumnFamily.create("Keyspace1", "Counter1"); cf.addColumn(new CounterColumn(ByteBufferUtil.bytes("col"), 1L, 1L)); - rm = new RowMutation("Keyspace1", dk.key, cf); + rm.add(cf); rm.apply(); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java b/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java index 51d69b1..6776e65 100644 --- a/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java +++ b/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java @@ -47,9 +47,10 @@ public class RecoveryManagerTruncateTest extends SchemaLoader ColumnFamily cf; // add a single cell + rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("keymulti")); cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "val1", 1L)); - rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("keymulti"), cf); + rm.add(cf); rm.apply(); // Make sure data was written http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/ScrubTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/ScrubTest.java b/test/unit/org/apache/cassandra/db/ScrubTest.java index f92844a..a652f7f 100644 --- a/test/unit/org/apache/cassandra/db/ScrubTest.java +++ b/test/unit/org/apache/cassandra/db/ScrubTest.java @@ -137,9 +137,11 @@ public class ScrubTest extends SchemaLoader Table table = Table.open(TABLE); ColumnFamilyStore cfs = table.getColumnFamilyStore(CF3); + RowMutation rm; + rm = new RowMutation(TABLE, ByteBufferUtil.bytes(1)); ColumnFamily cf = ColumnFamily.create(TABLE, CF3); cf.delete(new DeletionInfo(0, 1)); // expired tombstone - RowMutation rm = new RowMutation(TABLE, ByteBufferUtil.bytes(1), cf); + rm.add(cf); rm.applyUnsafe(); cfs.forceBlockingFlush(); @@ -225,10 +227,12 @@ public class ScrubTest extends SchemaLoader { String key = String.valueOf(i); // create a row and update the birthdate value, test that the index query fetches the new version + RowMutation rm; + rm = new RowMutation(TABLE, ByteBufferUtil.bytes(key)); ColumnFamily cf = ColumnFamily.create(TABLE, CF); cf.addColumn(column("c1", "1", 1L)); cf.addColumn(column("c2", "2", 1L)); - RowMutation rm = new RowMutation(TABLE, ByteBufferUtil.bytes(key), cf); + rm.add(cf); rm.applyUnsafe(); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/SerializationsTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/SerializationsTest.java b/test/unit/org/apache/cassandra/db/SerializationsTest.java index 429b6a5..5be7096 100644 --- a/test/unit/org/apache/cassandra/db/SerializationsTest.java +++ b/test/unit/org/apache/cassandra/db/SerializationsTest.java @@ -214,8 +214,10 @@ public class SerializationsTest extends AbstractSerializationsTester RowMutation emptyRm = new RowMutation(statics.KS, statics.Key); RowMutation standardRowRm = new RowMutation(statics.KS, statics.StandardRow); RowMutation superRowRm = new RowMutation(statics.KS, statics.SuperRow); - RowMutation standardRm = new RowMutation(statics.KS, statics.Key, statics.StandardCf); - RowMutation superRm = new RowMutation(statics.KS, statics.Key, statics.SuperCf); + RowMutation standardRm = new RowMutation(statics.KS, statics.Key); + standardRm.add(statics.StandardCf); + RowMutation superRm = new RowMutation(statics.KS, statics.Key); + superRm.add(statics.SuperCf); Map<UUID, ColumnFamily> mods = new HashMap<UUID, ColumnFamily>(); mods.put(statics.StandardCf.metadata().cfId, statics.StandardCf); mods.put(statics.SuperCf.metadata().cfId, statics.SuperCf); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/db/TableTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/TableTest.java b/test/unit/org/apache/cassandra/db/TableTest.java index cb564f7..0b14ccb 100644 --- a/test/unit/org/apache/cassandra/db/TableTest.java +++ b/test/unit/org/apache/cassandra/db/TableTest.java @@ -63,9 +63,10 @@ public class TableTest extends SchemaLoader final Table table = Table.open("Keyspace2"); final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard3"); + RowMutation rm = new RowMutation("Keyspace2", TEST_KEY.key); ColumnFamily cf = ColumnFamily.create("Keyspace2", "Standard3"); cf.addColumn(column("col1","val1", 1L)); - RowMutation rm = new RowMutation("Keyspace2", TEST_KEY.key, cf); + rm.add(cf); rm.apply(); Runnable verify = new WrappedRunnable() @@ -93,11 +94,12 @@ public class TableTest extends SchemaLoader final Table table = Table.open("Keyspace1"); final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1"); + RowMutation rm = new RowMutation("Keyspace1", TEST_KEY.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1","val1", 1L)); cf.addColumn(column("col2","val2", 1L)); cf.addColumn(column("col3","val3", 1L)); - RowMutation rm = new RowMutation("Keyspace1", TEST_KEY.key, cf); + rm.add(cf); rm.apply(); Runnable verify = new WrappedRunnable() @@ -122,12 +124,13 @@ public class TableTest extends SchemaLoader DecoratedKey key = TEST_SLICE_KEY; Table table = Table.open("Keyspace1"); ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1"); + RowMutation rm = new RowMutation("Keyspace1", key.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1"); // First write "a", "b", "c" cf.addColumn(column("a", "val1", 1L)); cf.addColumn(column("b", "val2", 1L)); cf.addColumn(column("c", "val3", 1L)); - RowMutation rm = new RowMutation("Keyspace1", key.key, cf); + rm.add(cf); rm.apply(); cf = cfStore.getColumnFamily(key, ByteBufferUtil.bytes("b"), ByteBufferUtil.bytes("c"), false, 100); @@ -144,9 +147,10 @@ public class TableTest extends SchemaLoader public void testGetSliceNoMatch() throws Throwable { Table table = Table.open("Keyspace1"); + RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("row1000")); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard2"); cf.addColumn(column("col1", "val1", 1)); - RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("row1000"), cf); + rm.add(cf); rm.apply(); validateGetSliceNoMatch(table); @@ -168,12 +172,13 @@ public class TableTest extends SchemaLoader final DecoratedKey ROW = Util.dk("row4"); final NumberFormat fmt = new DecimalFormat("000"); + RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1"); // at this rate, we're getting 78-79 cos/block, assuming the blocks are set to be about 4k. // so if we go to 300, we'll get at least 4 blocks, which is plenty for testing. for (int i = 0; i < 300; i++) cf.addColumn(column("col" + fmt.format(i), "omg!thisisthevalue!"+i, 1L)); - RowMutation rm = new RowMutation("Keyspace1", ROW.key, cf); + rm.add(cf); rm.apply(); Runnable verify = new WrappedRunnable() @@ -226,9 +231,10 @@ public class TableTest extends SchemaLoader for (int i = 0; i < 10; i++) { + RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "StandardLong1"); cf.addColumn(new Column(ByteBufferUtil.bytes((long)i), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0)); - RowMutation rm = new RowMutation("Keyspace1", ROW.key, cf); + rm.add(cf); rm.apply(); } @@ -236,9 +242,10 @@ public class TableTest extends SchemaLoader for (int i = 10; i < 20; i++) { + RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "StandardLong1"); cf.addColumn(new Column(ByteBufferUtil.bytes((long)i), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0)); - RowMutation rm = new RowMutation("Keyspace1", ROW.key, cf); + rm.add(cf); rm.apply(); cf = cfs.getColumnFamily(ROW, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, true, 1); @@ -269,6 +276,7 @@ public class TableTest extends SchemaLoader final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1"); final DecoratedKey ROW = Util.dk("row1"); + RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "val1", 1L)); cf.addColumn(column("col3", "val3", 1L)); @@ -276,7 +284,7 @@ public class TableTest extends SchemaLoader cf.addColumn(column("col5", "val5", 1L)); cf.addColumn(column("col7", "val7", 1L)); cf.addColumn(column("col9", "val9", 1L)); - RowMutation rm = new RowMutation("Keyspace1", ROW.key, cf); + rm.add(cf); rm.apply(); rm = new RowMutation("Keyspace1", ROW.key); @@ -324,11 +332,13 @@ public class TableTest extends SchemaLoader final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1"); final DecoratedKey ROW = Util.dk("row5"); + RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "val1", 1L)); cf.addColumn(expiringColumn("col2", "val2", 1L, 60)); // long enough not to be tombstoned cf.addColumn(column("col3", "val3", 1L)); - RowMutation rm = new RowMutation("Keyspace1", ROW.key, cf); + + rm.add(cf); rm.apply(); Runnable verify = new WrappedRunnable() @@ -358,6 +368,7 @@ public class TableTest extends SchemaLoader final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1"); final DecoratedKey ROW = Util.dk("row2"); + RowMutation rm = new RowMutation("Keyspace1", ROW.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "val1", 1L)); cf.addColumn(column("col2", "val2", 1L)); @@ -365,15 +376,16 @@ public class TableTest extends SchemaLoader cf.addColumn(column("col4", "val4", 1L)); cf.addColumn(column("col5", "val5", 1L)); cf.addColumn(column("col6", "val6", 1L)); - RowMutation rm = new RowMutation("Keyspace1", ROW.key, cf); + rm.add(cf); rm.apply(); cfStore.forceBlockingFlush(); + rm = new RowMutation("Keyspace1", ROW.key); cf = ColumnFamily.create("Keyspace1", "Standard1"); cf.addColumn(column("col1", "valx", 2L)); cf.addColumn(column("col2", "valx", 2L)); cf.addColumn(column("col3", "valx", 2L)); - rm = new RowMutation("Keyspace1", ROW.key, cf); + rm.add(cf); rm.apply(); Runnable verify = new WrappedRunnable() @@ -406,10 +418,11 @@ public class TableTest extends SchemaLoader Table table = Table.open("Keyspace1"); ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1"); DecoratedKey key = Util.dk("row3"); + RowMutation rm = new RowMutation("Keyspace1", key.key); ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1"); for (int i = 1000; i < 2000; i++) cf.addColumn(column("col" + i, ("v" + i), 1L)); - RowMutation rm = new RowMutation("Keyspace1", key.key, cf); + rm.add(cf); rm.apply(); cfStore.forceBlockingFlush(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaa6cd1/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java b/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java index dd2d4f4..76d66b7 100644 --- a/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java +++ b/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java @@ -139,10 +139,11 @@ public class StreamingTransferTest extends SchemaLoader public void mutate(String key, String col, long timestamp) throws Exception { long val = key.hashCode(); + RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key)); ColumnFamily cf = ColumnFamily.create(table.getName(), cfs.name); cf.addColumn(column(col, "v", timestamp)); cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), ByteBufferUtil.bytes(val), timestamp)); - RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key), cf); + rm.add(cf); logger.debug("Applying row to transfer " + rm); rm.apply(); } @@ -327,10 +328,11 @@ public class StreamingTransferTest extends SchemaLoader { public void mutate(String key, String colName, long timestamp) throws Exception { + RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key)); ColumnFamily cf = ColumnFamily.create(table.getName(), cfs.name); cf.addColumn(column(colName, "value", timestamp)); cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), ByteBufferUtil.bytes(new Date(timestamp).toString()), timestamp)); - RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key), cf); + rm.add(cf); logger.debug("Applying row to transfer " + rm); rm.apply(); }
