Repository: cassandra Updated Branches: refs/heads/trunk 019471a56 -> 2b0a8f6bd
Fix flapping PartitionTest patch by slebresne; reviewed by snazy for CASSANDRA-9731 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2b0a8f6b Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2b0a8f6b Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2b0a8f6b Branch: refs/heads/trunk Commit: 2b0a8f6bdac621badabcb9921c077260f2470c26 Parents: 019471a Author: Sylvain Lebresne <[email protected]> Authored: Thu Jul 23 09:00:38 2015 +0200 Committer: Sylvain Lebresne <[email protected]> Committed: Thu Jul 23 09:00:38 2015 +0200 ---------------------------------------------------------------------- src/java/org/apache/cassandra/db/RowUpdateBuilder.java | 13 +++++++++---- test/unit/org/apache/cassandra/db/PartitionTest.java | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2b0a8f6b/src/java/org/apache/cassandra/db/RowUpdateBuilder.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/RowUpdateBuilder.java b/src/java/org/apache/cassandra/db/RowUpdateBuilder.java index 7640512..71b7bd8 100644 --- a/src/java/org/apache/cassandra/db/RowUpdateBuilder.java +++ b/src/java/org/apache/cassandra/db/RowUpdateBuilder.java @@ -181,7 +181,7 @@ public class RowUpdateBuilder return update; } - private static void deleteRow(PartitionUpdate update, long timestamp, Object...clusteringValues) + private static void deleteRow(PartitionUpdate update, long timestamp, int localDeletionTime, Object... clusteringValues) { assert clusteringValues.length == update.metadata().comparator.size() || (clusteringValues.length == 0 && !update.columns().statics.isEmpty()); @@ -192,21 +192,26 @@ public class RowUpdateBuilder builder.newRow(Clustering.STATIC_CLUSTERING); else builder.newRow(clusteringValues.length == 0 ? Clustering.EMPTY : update.metadata().comparator.make(clusteringValues)); - builder.addRowDeletion(new DeletionTime(timestamp, FBUtilities.nowInSeconds())); + builder.addRowDeletion(new DeletionTime(timestamp, localDeletionTime)); update.add(builder.build()); } public static Mutation deleteRow(CFMetaData metadata, long timestamp, Mutation mutation, Object... clusteringValues) { - deleteRow(getOrAdd(metadata, mutation), timestamp, clusteringValues); + deleteRow(getOrAdd(metadata, mutation), timestamp, FBUtilities.nowInSeconds(), clusteringValues); return mutation; } public static Mutation deleteRow(CFMetaData metadata, long timestamp, Object key, Object... clusteringValues) { + return deleteRowAt(metadata, timestamp, FBUtilities.nowInSeconds(), key, clusteringValues); + } + + public static Mutation deleteRowAt(CFMetaData metadata, long timestamp, int localDeletionTime, Object key, Object... clusteringValues) + { PartitionUpdate update = new PartitionUpdate(metadata, makeKey(metadata, key), metadata.partitionColumns(), 0); - deleteRow(update, timestamp, clusteringValues); + 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().ksName, update.partitionKey()).add(update); http://git-wip-us.apache.org/repos/asf/cassandra/blob/2b0a8f6b/test/unit/org/apache/cassandra/db/PartitionTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/PartitionTest.java b/test/unit/org/apache/cassandra/db/PartitionTest.java index 515902b..9e9f68f 100644 --- a/test/unit/org/apache/cassandra/db/PartitionTest.java +++ b/test/unit/org/apache/cassandra/db/PartitionTest.java @@ -164,7 +164,7 @@ public class PartitionTest builder.add("val" + i, "val" + i); builder.build().applyUnsafe(); - RowUpdateBuilder.deleteRow(cfs.metadata, 10, "key1", "c").applyUnsafe(); + RowUpdateBuilder.deleteRowAt(cfs.metadata, 10L, localDeletionTime, "key1", "c").applyUnsafe(); ArrayBackedPartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, "key1").build()); RowStats stats = partition.stats(); assertEquals(localDeletionTime, stats.minLocalDeletionTime);
