You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2017/08/01 14:41:27 UTC

[6/6] cassandra git commit: Merge branch 'cassandra-3.11' into trunk

Merge branch 'cassandra-3.11' into trunk


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

Branch: refs/heads/trunk
Commit: fbcec0cc465dddc81134a15c42b292c35d3316b2
Parents: de60cf0 92d1cfe
Author: Aleksey Yeschenko <al...@yeschenko.com>
Authored: Tue Aug 1 15:40:23 2017 +0100
Committer: Aleksey Yeschenko <al...@yeschenko.com>
Committed: Tue Aug 1 15:40:23 2017 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../apache/cassandra/cql3/UpdateParameters.java |  7 ++-
 .../cassandra/db/context/CounterContext.java    | 52 ++++++++++++++------
 .../org/apache/cassandra/utils/CounterId.java   |  3 +-
 .../db/context/CounterContextTest.java          | 29 ++++++++++-
 5 files changed, 75 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fbcec0cc/src/java/org/apache/cassandra/cql3/UpdateParameters.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/UpdateParameters.java
index 7f6ba22,25f04fb..8faf1c6
--- a/src/java/org/apache/cassandra/cql3/UpdateParameters.java
+++ b/src/java/org/apache/cassandra/cql3/UpdateParameters.java
@@@ -165,10 -167,13 +165,13 @@@ public class UpdateParameter
          // shard is due to the merging rules: if a user includes multiple updates to the same counter in a batch, those
          // multiple updates will be merged in the PartitionUpdate *before* they even reach CounterMutation. So we need
          // such update to be added together, and that's what a local shard gives us.
-         builder.addCell(BufferCell.live(column, timestamp, CounterContext.instance().createLocal(increment)));
+         //
+         // We set counterid to a special value to differentiate between regular pre-2.0 local shards from pre-2.1 era
+         // and "counter update" temporary state cells. Please see CounterContext.createUpdate() for further details.
+         builder.addCell(BufferCell.live(column, timestamp, CounterContext.instance().createUpdate(increment)));
      }
  
 -    public void setComplexDeletionTime(ColumnDefinition column)
 +    public void setComplexDeletionTime(ColumnMetadata column)
      {
          builder.addComplexDeletion(column, deletionTime);
      }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fbcec0cc/test/unit/org/apache/cassandra/db/context/CounterContextTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/context/CounterContextTest.java
index 72e9548,6994046..4600137
--- a/test/unit/org/apache/cassandra/db/context/CounterContextTest.java
+++ b/test/unit/org/apache/cassandra/db/context/CounterContextTest.java
@@@ -542,4 -544,34 +543,30 @@@ public class CounterContextTes
          assertEquals(ClockAndCount.create(0L, 0L), cc.getClockAndCountOf(state.context, CounterId.fromInt(15)));
          assertEquals(ClockAndCount.create(0L, 0L), cc.getClockAndCountOf(state.context, CounterId.fromInt(20)));
      }
+ 
+     @Test // see CASSANDRA-13691
+     public void testCounterUpdate()
+     {
+         /*
+          * a context with just one 'update' shard - a local shard with a hardcoded value of CounterContext.UPDATE_CLOCK_ID
+          */
+ 
+         ByteBuffer updateContext = CounterContext.instance().createUpdate(10L);
+ 
+         assertEquals(ClockAndCount.create(1L, 10L), cc.getClockAndCountOf(updateContext, CounterContext.UPDATE_CLOCK_ID));
+         assertTrue(cc.isUpdate(updateContext));
 -        LegacyCell updateCell = LegacyCell.counter(null, updateContext);
 -        assertTrue(updateCell.isCounterUpdate());
+ 
+ 
+         /*
+          * a context with a regular local shard sorting first and a couple others in it - should *not* be identified as an update
+          */
+ 
+         ContextState notUpdateContextState = ContextState.allocate(1, 1, 1);
+         notUpdateContextState.writeLocal( CounterId.fromInt(1), 1L, 10L);
+         notUpdateContextState.writeRemote(CounterId.fromInt(2), 1L, 10L);
+         notUpdateContextState.writeGlobal(CounterId.fromInt(3), 1L, 10L);
+         ByteBuffer notUpdateContext = notUpdateContextState.context;
+ 
+         assertFalse(cc.isUpdate(notUpdateContext));
 -        LegacyCell notUpdateCell = LegacyCell.counter(null, notUpdateContext);
 -        assertFalse(notUpdateCell.isCounterUpdate());
+     }
  }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org