Repository: cassandra Updated Branches: refs/heads/trunk 45c7c4561 -> de7c24b39
http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java index a663051..530a03b 100644 --- a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java +++ b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java @@ -39,7 +39,7 @@ import org.apache.cassandra.schema.TableMetadataRef; class SSTableSimpleWriter extends AbstractSSTableSimpleWriter { protected DecoratedKey currentKey; - protected PartitionUpdate update; + protected PartitionUpdate.Builder update; private SSTableTxnWriter writer; @@ -56,7 +56,7 @@ class SSTableSimpleWriter extends AbstractSSTableSimpleWriter return writer; } - PartitionUpdate getUpdateFor(DecoratedKey key) throws IOException + PartitionUpdate.Builder getUpdateFor(DecoratedKey key) throws IOException { assert key != null; @@ -65,9 +65,9 @@ class SSTableSimpleWriter extends AbstractSSTableSimpleWriter if (!key.equals(currentKey)) { if (update != null) - writePartition(update); + writePartition(update.build()); currentKey = key; - update = new PartitionUpdate(metadata.get(), currentKey, columns, 4); + update = new PartitionUpdate.Builder(metadata.get(), currentKey, columns, 4); } assert update != null; @@ -79,7 +79,7 @@ class SSTableSimpleWriter extends AbstractSSTableSimpleWriter try { if (update != null) - writePartition(update); + writePartition(update.build()); if (writer != null) writer.finish(false); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/src/java/org/apache/cassandra/schema/SchemaKeyspace.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java index cd03a40..9d86feb 100644 --- a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java +++ b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java @@ -21,6 +21,7 @@ import java.nio.ByteBuffer; import java.nio.charset.CharacterCodingException; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import com.google.common.collect.*; import com.google.common.collect.Maps; @@ -356,15 +357,15 @@ public final class SchemaKeyspace static Collection<Mutation> convertSchemaToMutations() { - Map<DecoratedKey, Mutation> mutationMap = new HashMap<>(); + Map<DecoratedKey, Mutation.PartitionUpdateCollector> mutationMap = new HashMap<>(); for (String table : ALL) convertSchemaToMutations(mutationMap, table); - return mutationMap.values(); + return mutationMap.values().stream().map(Mutation.PartitionUpdateCollector::build).collect(Collectors.toList()); } - private static void convertSchemaToMutations(Map<DecoratedKey, Mutation> mutationMap, String schemaTableName) + private static void convertSchemaToMutations(Map<DecoratedKey, Mutation.PartitionUpdateCollector> mutationMap, String schemaTableName) { ReadCommand cmd = getReadCommandForTableSchema(schemaTableName); try (ReadExecutionController executionController = cmd.executionController(); @@ -378,9 +379,8 @@ public final class SchemaKeyspace continue; DecoratedKey key = partition.partitionKey(); - Mutation mutation = mutationMap.computeIfAbsent(key, k -> new Mutation(SchemaConstants.SCHEMA_KEYSPACE_NAME, key)); - - mutation.add(makeUpdateForSchema(partition, cmd.columnFilter())); + Mutation.PartitionUpdateCollector puCollector = mutationMap.computeIfAbsent(key, k -> new Mutation.PartitionUpdateCollector(SchemaConstants.SCHEMA_KEYSPACE_NAME, key)); + puCollector.add(makeUpdateForSchema(partition, cmd.columnFilter())); } } } @@ -423,7 +423,7 @@ public final class SchemaKeyspace @SuppressWarnings("unchecked") private static DecoratedKey decorate(TableMetadata metadata, Object value) { - return metadata.partitioner.decorateKey(((AbstractType)metadata.partitionKeyType).decompose(value)); + return metadata.partitioner.decorateKey(((AbstractType) metadata.partitionKeyType).decompose(value)); } static Mutation.SimpleBuilder makeCreateKeyspaceMutation(String name, KeyspaceParams params, long timestamp) http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/src/java/org/apache/cassandra/service/DataResolver.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/DataResolver.java b/src/java/org/apache/cassandra/service/DataResolver.java index 933014f..54f4b0c 100644 --- a/src/java/org/apache/cassandra/service/DataResolver.java +++ b/src/java/org/apache/cassandra/service/DataResolver.java @@ -207,7 +207,7 @@ public class DataResolver extends ResponseResolver private final DecoratedKey partitionKey; private final RegularAndStaticColumns columns; private final boolean isReversed; - private final PartitionUpdate[] repairs = new PartitionUpdate[sources.length]; + private final PartitionUpdate.Builder[] repairs = new PartitionUpdate.Builder[sources.length]; private final Row.Builder[] currentRows = new Row.Builder[sources.length]; private final RowDiffListener diffListener; @@ -268,10 +268,10 @@ public class DataResolver extends ResponseResolver }; } - private PartitionUpdate update(int i) + private PartitionUpdate.Builder update(int i) { if (repairs[i] == null) - repairs[i] = new PartitionUpdate(command.metadata(), partitionKey, columns, 1); + repairs[i] = new PartitionUpdate.Builder(command.metadata(), partitionKey, columns, 1); return repairs[i]; } @@ -468,7 +468,7 @@ public class DataResolver extends ResponseResolver { for (int i = 0; i < repairs.length; i++) if (null != repairs[i]) - sendRepairMutation(repairs[i], sources[i]); + sendRepairMutation(repairs[i].build(), sources[i]); } private void sendRepairMutation(PartitionUpdate partition, InetAddress destination) http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/src/java/org/apache/cassandra/service/paxos/Commit.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/paxos/Commit.java b/src/java/org/apache/cassandra/service/paxos/Commit.java index 6d672f5..422eaa8 100644 --- a/src/java/org/apache/cassandra/service/paxos/Commit.java +++ b/src/java/org/apache/cassandra/service/paxos/Commit.java @@ -59,8 +59,8 @@ public class Commit public static Commit newProposal(UUID ballot, PartitionUpdate update) { - update.updateAllTimestamp(UUIDGen.microsTimestamp(ballot)); - return new Commit(ballot, update); + PartitionUpdate withNewTimestamp = new PartitionUpdate.Builder(update, 0).updateAllTimestamp(UUIDGen.microsTimestamp(ballot)).build(); + return new Commit(ballot, withNewTimestamp); } public static Commit emptyCommit(DecoratedKey key, TableMetadata metadata) http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/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 e5c5727..b553a12 100644 --- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java +++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java @@ -170,7 +170,9 @@ public class ColumnFamilyStoreTest ByteBuffer val = ByteBufferUtil.bytes("val1"); // insert - ColumnMetadata newCol = ColumnMetadata.regularColumn(cfs.metadata(), ByteBufferUtil.bytes("val2"), AsciiType.instance); + Mutation.SimpleBuilder builder = Mutation.simpleBuilder(keyspaceName, cfs.metadata().partitioner.decorateKey(ByteBufferUtil.bytes("val2"))); + builder.update(cfName).row("Column1").add("val", "val1").build(); + new RowUpdateBuilder(cfs.metadata(), 0, "key1").clustering("Column1").add("val", "val1").build().applyUnsafe(); new RowUpdateBuilder(cfs.metadata(), 0, "key2").clustering("Column1").add("val", "val1").build().applyUnsafe(); assertRangeCount(cfs, col, val, 2); http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/CounterMutationTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/CounterMutationTest.java b/test/unit/org/apache/cassandra/db/CounterMutationTest.java index f36deea..9be0960 100644 --- a/test/unit/org/apache/cassandra/db/CounterMutationTest.java +++ b/test/unit/org/apache/cassandra/db/CounterMutationTest.java @@ -118,20 +118,20 @@ public class CounterMutationTest cfsTwo.truncateBlocking(); // Do the update (+1, -1), (+2, -2) - Mutation batch = new Mutation(KEYSPACE1, Util.dk("key1")); + Mutation.PartitionUpdateCollector batch = new Mutation.PartitionUpdateCollector(KEYSPACE1, Util.dk("key1")); batch.add(new RowUpdateBuilder(cfsOne.metadata(), 5, "key1") .clustering("cc") .add("val", 1L) .add("val2", -1L) - .build().get(cfsOne.metadata())); + .build().getPartitionUpdate(cfsOne.metadata())); batch.add(new RowUpdateBuilder(cfsTwo.metadata(), 5, "key1") .clustering("cc") .add("val", 2L) .add("val2", -2L) - .build().get(cfsTwo.metadata())); + .build().getPartitionUpdate(cfsTwo.metadata())); - new CounterMutation(batch, ConsistencyLevel.ONE).apply(); + new CounterMutation(batch.build(), ConsistencyLevel.ONE).apply(); ColumnMetadata c1cfs1 = cfsOne.metadata().getColumn(ByteBufferUtil.bytes("val")); ColumnMetadata c2cfs1 = cfsOne.metadata().getColumn(ByteBufferUtil.bytes("val2")); http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/DeletePartitionTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/DeletePartitionTest.java b/test/unit/org/apache/cassandra/db/DeletePartitionTest.java index 95bb5a4..6ed43f7 100644 --- a/test/unit/org/apache/cassandra/db/DeletePartitionTest.java +++ b/test/unit/org/apache/cassandra/db/DeletePartitionTest.java @@ -78,8 +78,9 @@ public class DeletePartitionTest store.forceBlockingFlush(); // delete the partition - new Mutation(KEYSPACE1, key) + new Mutation.PartitionUpdateCollector(KEYSPACE1, key) .add(PartitionUpdate.fullPartitionDelete(store.metadata(), key, 0, FBUtilities.nowInSeconds())) + .build() .applyUnsafe(); if (flushAfterRemove) http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/RowTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/RowTest.java b/test/unit/org/apache/cassandra/db/RowTest.java index 5134857..ca2765d 100644 --- a/test/unit/org/apache/cassandra/db/RowTest.java +++ b/test/unit/org/apache/cassandra/db/RowTest.java @@ -85,13 +85,13 @@ public class RowTest @Test public void testMergeRangeTombstones() throws InterruptedException { - PartitionUpdate update1 = new PartitionUpdate(metadata, dk, metadata.regularAndStaticColumns(), 1); + PartitionUpdate.Builder update1 = new PartitionUpdate.Builder(metadata, dk, metadata.regularAndStaticColumns(), 1); writeRangeTombstone(update1, "1", "11", 123, 123); writeRangeTombstone(update1, "2", "22", 123, 123); writeRangeTombstone(update1, "3", "31", 123, 123); writeRangeTombstone(update1, "4", "41", 123, 123); - PartitionUpdate update2 = new PartitionUpdate(metadata, dk, metadata.regularAndStaticColumns(), 1); + PartitionUpdate.Builder update2 = new PartitionUpdate.Builder(metadata, dk, metadata.regularAndStaticColumns(), 1); writeRangeTombstone(update2, "1", "11", 123, 123); writeRangeTombstone(update2, "111", "112", 1230, 123); writeRangeTombstone(update2, "2", "24", 123, 123); @@ -99,7 +99,7 @@ public class RowTest writeRangeTombstone(update2, "4", "41", 123, 1230); writeRangeTombstone(update2, "5", "51", 123, 1230); - try (UnfilteredRowIterator merged = UnfilteredRowIterators.merge(ImmutableList.of(update1.unfilteredIterator(), update2.unfilteredIterator()), nowInSeconds)) + try (UnfilteredRowIterator merged = UnfilteredRowIterators.merge(ImmutableList.of(update1.build().unfilteredIterator(), update2.build().unfilteredIterator()), nowInSeconds)) { Object[][] expected = new Object[][]{ { "1", "11", 123l, 123 }, { "111", "112", 1230l, 123 }, @@ -204,7 +204,7 @@ public class RowTest assertEquals(expected[3], deletionTime.localDeletionTime()); } - public void writeRangeTombstone(PartitionUpdate update, Object start, Object end, long markedForDeleteAt, int localDeletionTime) + public void writeRangeTombstone(PartitionUpdate.Builder update, Object start, Object end, long markedForDeleteAt, int localDeletionTime) { ClusteringComparator comparator = cfs.getComparator(); update.add(new RangeTombstone(Slice.make(comparator.make(start), comparator.make(end)), new DeletionTime(markedForDeleteAt, localDeletionTime))); http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/RowUpdateBuilder.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/RowUpdateBuilder.java b/test/unit/org/apache/cassandra/db/RowUpdateBuilder.java index f4eafa3..706b274 100644 --- a/test/unit/org/apache/cassandra/db/RowUpdateBuilder.java +++ b/test/unit/org/apache/cassandra/db/RowUpdateBuilder.java @@ -109,26 +109,16 @@ public class RowUpdateBuilder public PartitionUpdate buildUpdate() { - PartitionUpdate update = updateBuilder.build(); for (RangeTombstone rt : rts) - update.add(rt); - return update; + updateBuilder.addRangeTombstone(rt); + return updateBuilder.build(); } - private static void deleteRow(PartitionUpdate update, long timestamp, int localDeletionTime, Object... clusteringValues) + private static void deleteRow(PartitionUpdate.Builder updateBuilder, long timestamp, int localDeletionTime, Object... clusteringValues) { - assert clusteringValues.length == update.metadata().comparator.size() || (clusteringValues.length == 0 && !update.columns().statics.isEmpty()); - - boolean isStatic = clusteringValues.length != update.metadata().comparator.size(); - Row.Builder builder = BTreeRow.sortedBuilder(); - - if (isStatic) - builder.newRow(Clustering.STATIC_CLUSTERING); - else - builder.newRow(clusteringValues.length == 0 ? Clustering.EMPTY : update.metadata().comparator.make(clusteringValues)); - builder.addRowDeletion(Row.Deletion.regular(new DeletionTime(timestamp, localDeletionTime))); - - update.add(builder.build()); + SimpleBuilders.RowBuilder b = new SimpleBuilders.RowBuilder(updateBuilder.metadata(), clusteringValues); + b.nowInSec(localDeletionTime).timestamp(timestamp).delete(); + updateBuilder.add(b.build()); } public static Mutation deleteRow(TableMetadata metadata, long timestamp, Object key, Object... clusteringValues) @@ -138,11 +128,9 @@ public class RowUpdateBuilder public static Mutation deleteRowAt(TableMetadata metadata, long timestamp, int localDeletionTime, Object key, Object... clusteringValues) { - PartitionUpdate update = new PartitionUpdate(metadata, makeKey(metadata, key), metadata.regularAndStaticColumns(), 0); + PartitionUpdate.Builder update = new PartitionUpdate.Builder(metadata, makeKey(metadata, key), metadata.regularAndStaticColumns(), 0); deleteRow(update, timestamp, localDeletionTime, clusteringValues); - // note that the created mutation may get further update later on, so we don't use the ctor that create a singletonMap - // underneath (this class if for convenience, not performance) - return new Mutation(update.metadata().keyspace, update.partitionKey()).add(update); + return new Mutation.PartitionUpdateCollector(update.metadata().keyspace, update.partitionKey()).add(update.build()).build(); } private static DecoratedKey makeKey(TableMetadata metadata, Object... partitionKey) http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java b/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java index 6eaf2c8..ca76e45 100644 --- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java +++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java @@ -170,7 +170,7 @@ public class CommitLogReaderTest extends CQLTester int j = 0; while (i + j < handler.seenMutationCount()) { - PartitionUpdate pu = handler.seenMutations.get(i + j).get(currentTableMetadata()); + PartitionUpdate pu = handler.seenMutations.get(i + j).getPartitionUpdate(currentTableMetadata()); if (pu == null) { j++; @@ -234,7 +234,7 @@ public class CommitLogReaderTest extends CQLTester public void handleMutation(Mutation m, int size, int entryLocation, CommitLogDescriptor desc) { - if ((metadata == null) || (metadata != null && m.get(metadata) != null)) { + if ((metadata == null) || (metadata != null && m.getPartitionUpdate(metadata) != null)) { seenMutations.add(m); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java index 5f0b832..fc193e8 100644 --- a/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java +++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java @@ -193,8 +193,9 @@ public class CompactionsPurgeTest } cfs.forceBlockingFlush(); - new Mutation(KEYSPACE1, dk(key)) + new Mutation.PartitionUpdateCollector(KEYSPACE1, dk(key)) .add(PartitionUpdate.fullPartitionDelete(cfs.metadata(), dk(key), Long.MAX_VALUE, FBUtilities.nowInSeconds())) + .build() .applyUnsafe(); cfs.forceBlockingFlush(); @@ -423,9 +424,9 @@ public class CompactionsPurgeTest } // deletes partition - Mutation rm = new Mutation(KEYSPACE_CACHED, dk(key)); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KEYSPACE_CACHED, dk(key)); rm.add(PartitionUpdate.fullPartitionDelete(cfs.metadata(), dk(key), 1, FBUtilities.nowInSeconds())); - rm.applyUnsafe(); + rm.build().applyUnsafe(); // Adds another unrelated partition so that the sstable is not considered fully expired. We do not // invalidate the row cache in that latter case. @@ -463,9 +464,9 @@ public class CompactionsPurgeTest } // deletes partition with timestamp such that not all columns are deleted - Mutation rm = new Mutation(KEYSPACE1, dk(key)); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KEYSPACE1, dk(key)); rm.add(PartitionUpdate.fullPartitionDelete(cfs.metadata(), dk(key), 4, FBUtilities.nowInSeconds())); - rm.applyUnsafe(); + rm.build().applyUnsafe(); ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build()); assertFalse(partition.partitionLevelDeletion().isLive()); http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java b/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java index 0f83dac..f887ede 100644 --- a/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java +++ b/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java @@ -47,4 +47,19 @@ public class PartitionUpdateTest extends CQLTester builder.newRow(1).add("a", 1); Assert.assertEquals(2, builder.build().operationCount()); } + + @Test + public void testUpdateAllTimestamp() + { + createTable("CREATE TABLE %s (key text, clustering int, a int, b int, c int, s int static, PRIMARY KEY(key, clustering))"); + TableMetadata cfm = currentTableMetadata(); + + long timestamp = FBUtilities.timestampMicros(); + RowUpdateBuilder rub = new RowUpdateBuilder(cfm, timestamp, "key0").clustering(1).add("a", 1); + PartitionUpdate pu = rub.buildUpdate(); + PartitionUpdate pu2 = new PartitionUpdate.Builder(pu, 0).updateAllTimestamp(0).build(); + + Assert.assertTrue(pu.maxTimestamp() > 0); + Assert.assertTrue(pu2.maxTimestamp() == 0); + } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/db/rows/RowAndDeletionMergeIteratorTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/rows/RowAndDeletionMergeIteratorTest.java b/test/unit/org/apache/cassandra/db/rows/RowAndDeletionMergeIteratorTest.java index fb35ead..0d790fc 100644 --- a/test/unit/org/apache/cassandra/db/rows/RowAndDeletionMergeIteratorTest.java +++ b/test/unit/org/apache/cassandra/db/rows/RowAndDeletionMergeIteratorTest.java @@ -366,11 +366,11 @@ public class RowAndDeletionMergeIteratorTest private Iterator<Row> createRowIterator() { - PartitionUpdate update = new PartitionUpdate(cfm, dk, cfm.regularAndStaticColumns(), 1); + PartitionUpdate.Builder update = new PartitionUpdate.Builder(cfm, dk, cfm.regularAndStaticColumns(), 1); for (int i = 0; i < 5; i++) addRow(update, i, i); - return update.iterator(); + return update.build().iterator(); } private UnfilteredRowIterator createMergeIterator(Iterator<Row> rows, Iterator<RangeTombstone> tombstones, boolean reversed) @@ -395,7 +395,7 @@ public class RowAndDeletionMergeIteratorTest true); } - private void addRow(PartitionUpdate update, int col1, int a) + private void addRow(PartitionUpdate.Builder update, int col1, int a) { update.add(BTreeRow.singleCellRow(update.metadata().comparator.make(col1), makeCell(defA, a, 0))); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java b/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java index 406832a..071f84d 100644 --- a/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java +++ b/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java @@ -767,7 +767,7 @@ public class SASIIndexTest { ColumnFamilyStore store = Keyspace.open(KS_NAME).getColumnFamilyStore(CF_NAME); - Mutation rm1 = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose("key1"))); + Mutation.PartitionUpdateCollector rm1 = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose("key1"))); rm1.add(PartitionUpdate.singleRowUpdate(store.metadata(), rm1.key(), buildRow(buildCell(store.metadata(), @@ -775,7 +775,7 @@ public class SASIIndexTest AsciiType.instance.decompose("jason"), System.currentTimeMillis())))); - Mutation rm2 = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose("key2"))); + Mutation.PartitionUpdateCollector rm2 = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose("key2"))); rm2.add(PartitionUpdate.singleRowUpdate(store.metadata(), rm2.key(), buildRow(buildCell(store.metadata(), @@ -783,7 +783,7 @@ public class SASIIndexTest AsciiType.instance.decompose("pavel"), System.currentTimeMillis())))); - Mutation rm3 = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose("key3"))); + Mutation.PartitionUpdateCollector rm3 = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose("key3"))); rm3.add(PartitionUpdate.singleRowUpdate(store.metadata(), rm3.key(), buildRow(buildCell(store.metadata(), @@ -791,9 +791,9 @@ public class SASIIndexTest AsciiType.instance.decompose("Aleksey"), System.currentTimeMillis())))); - rm1.apply(); - rm2.apply(); - rm3.apply(); + rm1.build().apply(); + rm2.build().apply(); + rm3.build().apply(); if (forceFlush) store.forceBlockingFlush(); @@ -1095,13 +1095,13 @@ public class SASIIndexTest final ByteBuffer firstName = UTF8Type.instance.decompose("first_name"); final ByteBuffer age = UTF8Type.instance.decompose("age"); - Mutation rm = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose("key1"))); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose("key1"))); update(rm, new ArrayList<Cell>() {{ add(buildCell(age, LongType.instance.decompose(26L), System.currentTimeMillis())); add(buildCell(firstName, AsciiType.instance.decompose("pavel"), System.currentTimeMillis())); }}); - rm.apply(); + rm.build().apply(); store.forceBlockingFlush(); @@ -1127,25 +1127,25 @@ public class SASIIndexTest final ByteBuffer comment = UTF8Type.instance.decompose("comment"); - Mutation rm = new Mutation(KS_NAME, decoratedKey("key1")); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1")); update(rm, comment, UTF8Type.instance.decompose("ââ âºâ¸â¾â¶ââââ£âââ® and normal ones"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key2")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2")); update(rm, comment, UTF8Type.instance.decompose("é¾é¦é¬±"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key3")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3")); update(rm, comment, UTF8Type.instance.decompose("ã¤ã³ãã£ã¢ã"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key4")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4")); update(rm, comment, UTF8Type.instance.decompose("ã¬ã¹ãã©ã³"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key5")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key5")); update(rm, comment, UTF8Type.instance.decompose("ãã³ã¸ã£ãã³ ã¦ã¨ã¹ã"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); if (forceFlush) store.forceBlockingFlush(); @@ -1203,21 +1203,21 @@ public class SASIIndexTest final ByteBuffer comment = UTF8Type.instance.decompose("comment_suffix_split"); - Mutation rm = new Mutation(KS_NAME, decoratedKey("key1")); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1")); update(rm, comment, UTF8Type.instance.decompose("é¾é¦é¬±"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key2")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2")); update(rm, comment, UTF8Type.instance.decompose("ã¤ã³ãã£ã¢ã"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key3")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3")); update(rm, comment, UTF8Type.instance.decompose("ã¬ã¹ãã©ã³"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key4")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4")); update(rm, comment, UTF8Type.instance.decompose("ãã³ã¸ã£ãã³ ã¦ã¨ã¹ã"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); if (forceFlush) store.forceBlockingFlush(); @@ -1272,9 +1272,9 @@ public class SASIIndexTest final ByteBuffer bigValue = UTF8Type.instance.decompose(new String(randomBytes)); - Mutation rm = new Mutation(KS_NAME, decoratedKey("key1")); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1")); update(rm, comment, bigValue, System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); Set<String> rows; @@ -1352,37 +1352,37 @@ public class SASIIndexTest final ByteBuffer fullName = UTF8Type.instance.decompose("/output/full-name/"); - Mutation rm = new Mutation(KS_NAME, decoratedKey("key1")); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1")); update(rm, fullName, UTF8Type.instance.decompose("ç¾å å «ç°"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key2")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2")); update(rm, fullName, UTF8Type.instance.decompose("ä»ç¾ ç§æ¾¤"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key3")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3")); update(rm, fullName, UTF8Type.instance.decompose("æå® é«é "), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key4")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4")); update(rm, fullName, UTF8Type.instance.decompose("å¼å 大竹"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key5")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key5")); update(rm, fullName, UTF8Type.instance.decompose("æºæ æ¦æ¬"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key6")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key6")); update(rm, fullName, UTF8Type.instance.decompose("é£é³¥ ä¸å"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key7")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key7")); update(rm, fullName, UTF8Type.instance.decompose("å¤§è¼ éç°"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key8")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key8")); update(rm, fullName, UTF8Type.instance.decompose("å©ä¹ 寺å°"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); store.forceBlockingFlush(); @@ -1408,17 +1408,17 @@ public class SASIIndexTest final ByteBuffer comment = UTF8Type.instance.decompose("address"); - Mutation rm = new Mutation(KS_NAME, decoratedKey("key1")); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1")); update(rm, comment, UTF8Type.instance.decompose("577 Rogahn Valleys Apt. 178"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key2")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2")); update(rm, comment, UTF8Type.instance.decompose("89809 Beverly Course Suite 089"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key3")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3")); update(rm, comment, UTF8Type.instance.decompose("165 clydie oval apt. 399"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); if (forceFlush) store.forceBlockingFlush(); @@ -1483,42 +1483,42 @@ public class SASIIndexTest final ByteBuffer name = UTF8Type.instance.decompose("first_name_prefix"); - Mutation rm; + Mutation.PartitionUpdateCollector rm; - rm = new Mutation(KS_NAME, decoratedKey("key1")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1")); update(rm, name, UTF8Type.instance.decompose("Pavel"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key2")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2")); update(rm, name, UTF8Type.instance.decompose("Jordan"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key3")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3")); update(rm, name, UTF8Type.instance.decompose("Mikhail"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key4")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4")); update(rm, name, UTF8Type.instance.decompose("Michael"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key5")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key5")); update(rm, name, UTF8Type.instance.decompose("Johnny"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); // first flush would make interval for name - 'johnny' -> 'pavel' store.forceBlockingFlush(); - rm = new Mutation(KS_NAME, decoratedKey("key6")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key6")); update(rm, name, UTF8Type.instance.decompose("Jason"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key7")); + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key7")); update(rm, name, UTF8Type.instance.decompose("Vijay"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); - rm = new Mutation(KS_NAME, decoratedKey("key8")); // this name is going to be tokenized + rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key8")); // this name is going to be tokenized update(rm, name, UTF8Type.instance.decompose("Jean-Claude"), System.currentTimeMillis()); - rm.apply(); + rm.build().apply(); // this flush is going to produce range - 'jason' -> 'vijay' store.forceBlockingFlush(); @@ -2422,7 +2422,7 @@ public class SASIIndexTest private static Mutation newMutation(String key, String firstName, String lastName, int age, long timestamp) { - Mutation rm = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose(key))); + Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose(key))); List<Cell> cells = new ArrayList<>(3); if (age >= 0) @@ -2433,7 +2433,7 @@ public class SASIIndexTest cells.add(buildCell(ByteBufferUtil.bytes("last_name"), UTF8Type.instance.decompose(lastName), timestamp)); update(rm, cells); - return rm; + return rm.build(); } private static Set<String> getKeys(final UnfilteredPartitionIterator rows) @@ -2526,14 +2526,14 @@ public class SASIIndexTest return new Expression(name, op, value); } - private static void update(Mutation rm, ByteBuffer name, ByteBuffer value, long timestamp) + private static void update(Mutation.PartitionUpdateCollector rm, ByteBuffer name, ByteBuffer value, long timestamp) { TableMetadata metadata = Keyspace.open(KS_NAME).getColumnFamilyStore(CF_NAME).metadata(); rm.add(PartitionUpdate.singleRowUpdate(metadata, rm.key(), buildRow(buildCell(metadata, name, value, timestamp)))); } - private static void update(Mutation rm, List<Cell> cells) + private static void update(Mutation.PartitionUpdateCollector rm, List<Cell> cells) { TableMetadata metadata = Keyspace.open(KS_NAME).getColumnFamilyStore(CF_NAME).metadata(); rm.add(PartitionUpdate.singleRowUpdate(metadata, rm.key(), buildRow(cells))); http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/net/WriteCallbackInfoTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/net/WriteCallbackInfoTest.java b/test/unit/org/apache/cassandra/net/WriteCallbackInfoTest.java index d3257d7..2d12baf 100644 --- a/test/unit/org/apache/cassandra/net/WriteCallbackInfoTest.java +++ b/test/unit/org/apache/cassandra/net/WriteCallbackInfoTest.java @@ -34,6 +34,7 @@ import org.apache.cassandra.db.partitions.PartitionUpdate; import org.apache.cassandra.dht.Murmur3Partitioner; import org.apache.cassandra.net.MessagingService.Verb; import org.apache.cassandra.schema.MockSchema; +import org.apache.cassandra.schema.TableMetadata; import org.apache.cassandra.service.paxos.Commit; import org.apache.cassandra.utils.ByteBufferUtil; @@ -59,9 +60,10 @@ public class WriteCallbackInfoTest private void testShouldHint(Verb verb, ConsistencyLevel cl, boolean allowHints, boolean expectHint) throws Exception { + TableMetadata metadata = MockSchema.newTableMetadata("", ""); Object payload = verb == Verb.PAXOS_COMMIT - ? new Commit(UUID.randomUUID(), new PartitionUpdate(MockSchema.newTableMetadata("", ""), ByteBufferUtil.EMPTY_BYTE_BUFFER, RegularAndStaticColumns.NONE, 1)) - : new Mutation("", new BufferDecoratedKey(new Murmur3Partitioner.LongToken(0), ByteBufferUtil.EMPTY_BYTE_BUFFER)); + ? new Commit(UUID.randomUUID(), new PartitionUpdate.Builder(metadata, ByteBufferUtil.EMPTY_BYTE_BUFFER, RegularAndStaticColumns.NONE, 1).build()) + : new Mutation(PartitionUpdate.simpleBuilder(metadata, "").build()); WriteCallbackInfo wcbi = new WriteCallbackInfo(InetAddress.getByName("192.168.1.1"), null, new MessageOut(verb, payload, null), null, cl, allowHints); Assert.assertEquals(expectHint, wcbi.shouldHint()); http://git-wip-us.apache.org/repos/asf/cassandra/blob/de7c24b3/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java b/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java index aa5ee9b..50183e5 100644 --- a/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java +++ b/test/unit/org/apache/cassandra/triggers/TriggerExecutorTest.java @@ -107,8 +107,8 @@ public class TriggerExecutorTest TableMetadata metadata = makeTableMetadata("ks1", "cf1", TriggerMetadata.create("test", SameKeySameCfTrigger.class.getName())); PartitionUpdate cf1 = makeCf(metadata, "k1", "k1v1", null); PartitionUpdate cf2 = makeCf(metadata, "k2", "k2v1", null); - Mutation rm1 = new Mutation("ks1", cf1.partitionKey()).add(cf1); - Mutation rm2 = new Mutation("ks1", cf2.partitionKey()).add(cf2); + Mutation rm1 = new Mutation.PartitionUpdateCollector("ks1", cf1.partitionKey()).add(cf1).build(); + Mutation rm2 = new Mutation.PartitionUpdateCollector("ks1", cf2.partitionKey()).add(cf2).build(); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm1, rm2))); assertEquals(2, tmutations.size()); @@ -133,8 +133,8 @@ public class TriggerExecutorTest TableMetadata metadata = makeTableMetadata("ks1", "cf1", TriggerMetadata.create("test", SameKeySameCfPartialTrigger.class.getName())); PartitionUpdate cf1 = makeCf(metadata, "k1", "k1v1", null); PartitionUpdate cf2 = makeCf(metadata, "k2", "k2v1", null); - Mutation rm1 = new Mutation("ks1", cf1.partitionKey()).add(cf1); - Mutation rm2 = new Mutation("ks1", cf2.partitionKey()).add(cf2); + Mutation rm1 = new Mutation.PartitionUpdateCollector("ks1", cf1.partitionKey()).add(cf1).build(); + Mutation rm2 = new Mutation.PartitionUpdateCollector("ks1", cf2.partitionKey()).add(cf2).build(); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm1, rm2))); assertEquals(2, tmutations.size()); @@ -159,8 +159,8 @@ public class TriggerExecutorTest TableMetadata metadata = makeTableMetadata("ks1", "cf1", TriggerMetadata.create("test", SameKeyDifferentCfTrigger.class.getName())); PartitionUpdate cf1 = makeCf(metadata, "k1", "k1v1", null); PartitionUpdate cf2 = makeCf(metadata, "k2", "k2v1", null); - Mutation rm1 = new Mutation("ks1", cf1.partitionKey()).add(cf1); - Mutation rm2 = new Mutation("ks1", cf2.partitionKey()).add(cf2); + Mutation rm1 = new Mutation.PartitionUpdateCollector("ks1", cf1.partitionKey()).add(cf1).build(); + Mutation rm2 = new Mutation.PartitionUpdateCollector("ks1", cf2.partitionKey()).add(cf2).build(); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm1, rm2))); assertEquals(2, tmutations.size()); @@ -210,8 +210,8 @@ public class TriggerExecutorTest TableMetadata metadata = makeTableMetadata("ks1", "cf1", TriggerMetadata.create("test", SameKeyDifferentKsTrigger.class.getName())); PartitionUpdate cf1 = makeCf(metadata, "k1", "k1v1", null); PartitionUpdate cf2 = makeCf(metadata, "k2", "k2v1", null); - Mutation rm1 = new Mutation("ks1", cf1.partitionKey()).add(cf1); - Mutation rm2 = new Mutation("ks1", cf2.partitionKey()).add(cf2); + Mutation rm1 = new Mutation.PartitionUpdateCollector("ks1", cf1.partitionKey()).add(cf1).build(); + Mutation rm2 = new Mutation.PartitionUpdateCollector("ks1", cf2.partitionKey()).add(cf2).build(); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm1, rm2))); assertEquals(4, tmutations.size()); @@ -248,7 +248,7 @@ public class TriggerExecutorTest TableMetadata metadata = makeTableMetadata("ks1", "cf1", TriggerMetadata.create("test", DifferentKeyTrigger.class.getName())); PartitionUpdate cf1 = makeCf(metadata, "k1", "v1", null); - Mutation rm = new Mutation("ks1", cf1.partitionKey()).add(cf1); + Mutation rm = new Mutation.PartitionUpdateCollector("ks1", cf1.partitionKey()).add(cf1).build(); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm))); assertEquals(2, tmutations.size()); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org