cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [6/6] cassandra git commit: Merge branch 'cassandra-3.11' into trunk
Date Wed, 04 Jul 2018 10:11:55 GMT
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/243c371f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/243c371f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/243c371f

Branch: refs/heads/trunk
Commit: 243c371f4881be554439731cb809680a37c875ac
Parents: d500100 49e63c2
Author: Sylvain Lebresne <lebresne@gmail.com>
Authored: Wed Jul 4 12:10:05 2018 +0200
Committer: Sylvain Lebresne <lebresne@gmail.com>
Committed: Wed Jul 4 12:10:05 2018 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/db/context/CounterContext.java    |  3 +++
 .../apache/cassandra/db/CounterCellTest.java    | 24 +++++++++++++++++++-
 3 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/cassandra/blob/243c371f/src/java/org/apache/cassandra/db/context/CounterContext.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/context/CounterContext.java
index 9b34231,b402464..29dc3f0
--- a/src/java/org/apache/cassandra/db/context/CounterContext.java
+++ b/src/java/org/apache/cassandra/db/context/CounterContext.java
@@@ -690,11 -690,14 +690,14 @@@ public class CounterContex
       * nodes. This means in particular that we always have:
       *  updateDigest(ctx) == updateDigest(clearAllLocal(ctx))
       */
 -    public void updateDigest(MessageDigest message, ByteBuffer context)
 +    public void updateDigest(Hasher hasher, ByteBuffer context)
      {
+         // context can be empty due to the optimization from CASSANDRA-10657
+         if (!context.hasRemaining())
+             return;
          ByteBuffer dup = context.duplicate();
          dup.position(context.position() + headerLength(context));
 -        message.update(dup);
 +        HashingUtils.updateBytes(hasher, dup);
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/243c371f/test/unit/org/apache/cassandra/db/CounterCellTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/CounterCellTest.java
index b410427,5208cb2..0ee59e1
--- a/test/unit/org/apache/cassandra/db/CounterCellTest.java
+++ b/test/unit/org/apache/cassandra/db/CounterCellTest.java
@@@ -27,8 -28,8 +27,8 @@@ import org.junit.BeforeClass
  import org.junit.Test;
  
  import org.apache.cassandra.SchemaLoader;
- import org.apache.cassandra.net.MessagingService;
 -import org.apache.cassandra.config.ColumnDefinition;
 +import org.apache.cassandra.schema.ColumnMetadata;
+ import org.apache.cassandra.db.rows.BTreeRow;
  import org.apache.cassandra.db.rows.BufferCell;
  import org.apache.cassandra.db.rows.Cell;
  import org.apache.cassandra.db.rows.Cells;
@@@ -272,12 -275,32 +274,32 @@@ public class CounterCellTes
  
          Cell original = createCounterCellFromContext(cfs, col, state, 5);
  
 -        ColumnDefinition cDef = cfs.metadata.getColumnDefinition(col);
 +        ColumnMetadata cDef = cfs.metadata().getColumn(col);
          Cell cleared = BufferCell.live(cDef, 5, CounterContext.instance().clearAllLocal(state.context));
  
 -        original.digest(digest1);
 -        cleared.digest(digest2);
 +        original.digest(hasher1);
 +        cleared.digest(hasher2);
  
 -        assert Arrays.equals(digest1.digest(), digest2.digest());
 +        Assert.assertEquals(hasher1.hash(), hasher2.hash());
      }
+ 
+     @Test
+     public void testDigestWithEmptyCells() throws Exception
+     {
+         // For DB-1881
+         ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(COUNTER1);
+ 
 -        ColumnDefinition emptyColDef = cfs.metadata.getColumnDefinition(ByteBufferUtil.bytes("val2"));
++        ColumnMetadata emptyColDef = cfs.metadata().getColumn(ByteBufferUtil.bytes("val2"));
+         BufferCell emptyCell = BufferCell.live(emptyColDef, 0, ByteBuffer.allocate(0));
+ 
+         Row.Builder builder = BTreeRow.unsortedBuilder(0);
+         builder.newRow(Clustering.make(AsciiSerializer.instance.serialize("test")));
+         builder.addCell(emptyCell);
+         Row row = builder.build();
+ 
 -        MessageDigest digest = MessageDigest.getInstance("md5");
 -        row.digest(digest);
 -        assertNotNull(digest.digest());
++        Hasher hasher = HashingUtils.CURRENT_HASH_FUNCTION.newHasher();
++        row.digest(hasher);
++        assertNotNull(hasher.hash());
+     }
+ 
  }


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


Mime
View raw message