You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bd...@apache.org on 2017/08/10 22:52:18 UTC
[1/2] cassandra git commit: Fix digest calculation for counter cells
Repository: cassandra
Updated Branches:
refs/heads/cassandra-3.11 303dba650 -> e018bec8a
Fix digest calculation for counter cells
Patch by Blake Eggleston; reviewed by Aleksey Yeschenko for CASSANDRA-13750
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/eb6f03c8
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/eb6f03c8
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/eb6f03c8
Branch: refs/heads/cassandra-3.11
Commit: eb6f03c8928e913cb6f9eaa7c9ea9f4501039112
Parents: 1a70ded
Author: Blake Eggleston <bd...@gmail.com>
Authored: Tue Aug 8 13:45:41 2017 -0700
Committer: Blake Eggleston <bd...@gmail.com>
Committed: Thu Aug 10 15:42:31 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
src/java/org/apache/cassandra/db/rows/AbstractCell.java | 10 +++++++++-
test/unit/org/apache/cassandra/db/CounterCellTest.java | 4 ++--
3 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb6f03c8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1f42c70..0b92a7e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.15
+ * Fix digest calculation for counter cells (CASSANDRA-13750)
* Fix ColumnDefinition.cellValueType() for non-frozen collection and change SSTabledump to use type.toJSONString() (CASSANDRA-13573)
* Skip materialized view addition if the base table doesn't exist (CASSANDRA-13737)
* Drop table should remove corresponding entries in dropped_columns table (CASSANDRA-13730)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb6f03c8/src/java/org/apache/cassandra/db/rows/AbstractCell.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/rows/AbstractCell.java b/src/java/org/apache/cassandra/db/rows/AbstractCell.java
index 7e93c2e..576351e 100644
--- a/src/java/org/apache/cassandra/db/rows/AbstractCell.java
+++ b/src/java/org/apache/cassandra/db/rows/AbstractCell.java
@@ -42,7 +42,15 @@ public abstract class AbstractCell extends Cell
public void digest(MessageDigest digest)
{
- digest.update(value().duplicate());
+ if (isCounterCell())
+ {
+ CounterContext.instance().updateDigest(digest, value());
+ }
+ else
+ {
+ digest.update(value().duplicate());
+ }
+
FBUtilities.updateWithLong(digest, timestamp());
FBUtilities.updateWithInt(digest, ttl());
FBUtilities.updateWithBoolean(digest, isCounterCell());
http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb6f03c8/test/unit/org/apache/cassandra/db/CounterCellTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CounterCellTest.java b/test/unit/org/apache/cassandra/db/CounterCellTest.java
index 08e0b25..a8ddfcc 100644
--- a/test/unit/org/apache/cassandra/db/CounterCellTest.java
+++ b/test/unit/org/apache/cassandra/db/CounterCellTest.java
@@ -276,8 +276,8 @@ public class CounterCellTest
ColumnDefinition cDef = cfs.metadata.getColumnDefinition(col);
Cell cleared = BufferCell.live(cfs.metadata, cDef, 5, CounterContext.instance().clearAllLocal(state.context));
- CounterContext.instance().updateDigest(digest1, original.value());
- CounterContext.instance().updateDigest(digest2, cleared.value());
+ original.digest(digest1);
+ cleared.digest(digest2);
assert Arrays.equals(digest1.digest(), digest2.digest());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[2/2] cassandra git commit: Merge branch 'cassandra-3.0' into
cassandra-3.11
Posted by bd...@apache.org.
Merge branch 'cassandra-3.0' into cassandra-3.11
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e018bec8
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e018bec8
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e018bec8
Branch: refs/heads/cassandra-3.11
Commit: e018bec8ad482a1892b97b5f829ff5fa5801190a
Parents: 303dba6 eb6f03c
Author: Blake Eggleston <bd...@gmail.com>
Authored: Thu Aug 10 15:43:45 2017 -0700
Committer: Blake Eggleston <bd...@gmail.com>
Committed: Thu Aug 10 15:47:22 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
src/java/org/apache/cassandra/db/rows/AbstractCell.java | 10 +++++++++-
test/unit/org/apache/cassandra/db/CounterCellTest.java | 4 ++--
3 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e018bec8/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 145a746,0b92a7e..3308287
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,9 -1,5 +1,10 @@@
-3.0.15
+3.11.1
+ * "ignore" option is ignored in sstableloader (CASSANDRA-13721)
+ * Deadlock in AbstractCommitLogSegmentManager (CASSANDRA-13652)
+ * Duplicate the buffer before passing it to analyser in SASI operation (CASSANDRA-13512)
+ * Properly evict pstmts from prepared statements cache (CASSANDRA-13641)
+Merged from 3.0:
+ * Fix digest calculation for counter cells (CASSANDRA-13750)
* Fix ColumnDefinition.cellValueType() for non-frozen collection and change SSTabledump to use type.toJSONString() (CASSANDRA-13573)
* Skip materialized view addition if the base table doesn't exist (CASSANDRA-13737)
* Drop table should remove corresponding entries in dropped_columns table (CASSANDRA-13730)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e018bec8/src/java/org/apache/cassandra/db/rows/AbstractCell.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/rows/AbstractCell.java
index 54c8f24,576351e..744d113
--- a/src/java/org/apache/cassandra/db/rows/AbstractCell.java
+++ b/src/java/org/apache/cassandra/db/rows/AbstractCell.java
@@@ -44,84 -40,17 +44,92 @@@ public abstract class AbstractCell exte
super(column);
}
+ public boolean isCounterCell()
+ {
+ return !isTombstone() && column.isCounterColumn();
+ }
+
+ public boolean isLive(int nowInSec)
+ {
+ return localDeletionTime() == NO_DELETION_TIME || (ttl() != NO_TTL && nowInSec < localDeletionTime());
+ }
+
+ public boolean isTombstone()
+ {
+ return localDeletionTime() != NO_DELETION_TIME && ttl() == NO_TTL;
+ }
+
+ public boolean isExpiring()
+ {
+ return ttl() != NO_TTL;
+ }
+
+ public Cell markCounterLocalToBeCleared()
+ {
+ if (!isCounterCell())
+ return this;
+
+ ByteBuffer value = value();
+ ByteBuffer marked = CounterContext.instance().markLocalToBeCleared(value);
+ return marked == value ? this : new BufferCell(column, timestamp(), ttl(), localDeletionTime(), marked, path());
+ }
+
+ public Cell purge(DeletionPurger purger, int nowInSec)
+ {
+ if (!isLive(nowInSec))
+ {
+ if (purger.shouldPurge(timestamp(), localDeletionTime()))
+ return null;
+
+ // We slightly hijack purging to convert expired but not purgeable columns to tombstones. The reason we do that is
+ // that once a column has expired it is equivalent to a tombstone but actually using a tombstone is more compact since
+ // we don't keep the column value. The reason we do it here is that 1) it's somewhat related to dealing with tombstones
+ // so hopefully not too surprising and 2) we want to this and purging at the same places, so it's simpler/more efficient
+ // to do both here.
+ if (isExpiring())
+ {
+ // Note that as long as the expiring column and the tombstone put together live longer than GC grace seconds,
+ // we'll fulfil our responsibility to repair. See discussion at
+ // http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/repair-compaction-and-tombstone-rows-td7583481.html
+ return BufferCell.tombstone(column, timestamp(), localDeletionTime() - ttl(), path()).purge(purger, nowInSec);
+ }
+ }
+ return this;
+ }
+
+ public Cell copy(AbstractAllocator allocator)
+ {
+ CellPath path = path();
+ return new BufferCell(column, timestamp(), ttl(), localDeletionTime(), allocator.clone(value()), path == null ? null : path.copy(allocator));
+ }
+
+ // note: while the cell returned may be different, the value is the same, so if the value is offheap it must be referenced inside a guarded context (or copied)
+ public Cell updateAllTimestamp(long newTimestamp)
+ {
+ return new BufferCell(column, isTombstone() ? newTimestamp - 1 : newTimestamp, ttl(), localDeletionTime(), value(), path());
+ }
+
+ public int dataSize()
+ {
+ CellPath path = path();
+ return TypeSizes.sizeof(timestamp())
+ + TypeSizes.sizeof(ttl())
+ + TypeSizes.sizeof(localDeletionTime())
+ + value().remaining()
+ + (path == null ? 0 : path.dataSize());
+ }
+
public void digest(MessageDigest digest)
{
- digest.update(value().duplicate());
+ if (isCounterCell())
+ {
+ CounterContext.instance().updateDigest(digest, value());
+ }
+ else
+ {
+ digest.update(value().duplicate());
+ }
+
FBUtilities.updateWithLong(digest, timestamp());
FBUtilities.updateWithInt(digest, ttl());
FBUtilities.updateWithBoolean(digest, isCounterCell());
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e018bec8/test/unit/org/apache/cassandra/db/CounterCellTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/CounterCellTest.java
index a043b1b,a8ddfcc..74599c3
--- a/test/unit/org/apache/cassandra/db/CounterCellTest.java
+++ b/test/unit/org/apache/cassandra/db/CounterCellTest.java
@@@ -273,10 -274,10 +273,10 @@@ public class CounterCellTes
Cell original = createCounterCellFromContext(cfs, col, state, 5);
ColumnDefinition cDef = cfs.metadata.getColumnDefinition(col);
- Cell cleared = BufferCell.live(cfs.metadata, cDef, 5, CounterContext.instance().clearAllLocal(state.context));
+ Cell cleared = BufferCell.live(cDef, 5, CounterContext.instance().clearAllLocal(state.context));
- CounterContext.instance().updateDigest(digest1, original.value());
- CounterContext.instance().updateDigest(digest2, cleared.value());
+ original.digest(digest1);
+ cleared.digest(digest2);
assert Arrays.equals(digest1.digest(), digest2.digest());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org