cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/2] git commit: Revert "Explicitly use Long.MAX_VALUE timestamp for counter deletions"
Date Thu, 12 Jun 2014 19:12:28 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 1637498a5 -> 34e6bd509


Revert "Explicitly use Long.MAX_VALUE timestamp for counter deletions"

This reverts commit 5fe7557627fac6ace2554a4f8ef552c9d9512490.

Conflicts:
	CHANGES.txt


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

Branch: refs/heads/trunk
Commit: c94caec1b5266af4f20290b9d3d82faff4977aa7
Parents: 68c9265
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Jun 12 14:09:46 2014 -0500
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Jun 12 14:09:46 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 --
 .../cassandra/cql/AbstractModification.java     |  9 ++----
 .../apache/cassandra/cql/DeleteStatement.java   | 27 ++++++++----------
 .../apache/cassandra/cql/UpdateStatement.java   |  7 +++++
 .../apache/cassandra/cql3/UpdateParameters.java | 19 +++----------
 .../cql3/statements/DeleteStatement.java        |  2 +-
 .../apache/cassandra/db/CounterMutation.java    |  3 --
 .../cassandra/thrift/CassandraServer.java       | 29 ++++++++------------
 8 files changed, 39 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 680c2f8..cc968c3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,8 +2,6 @@
  * Fix exception when querying a composite-keyed table with a collection index
    (CASSANDRA-7372)
  * Use node's host id in place of counter ids (CASSANDRA-7366)
- * Explicitly use Long.MAX_VALUE timestamp for counter deletions
-   (CASSANDRA-7346)
  * Fix native protocol CAS batches (CASSANDRA-7337)
  * Reduce likelihood of contention on local paxos locking (CASSANDRA-7359)
  * Upgrade to Pig 0.12.1 (CASSANDRA-6556)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/src/java/org/apache/cassandra/cql/AbstractModification.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/AbstractModification.java b/src/java/org/apache/cassandra/cql/AbstractModification.java
index 9b88b5e..8da2611 100644
--- a/src/java/org/apache/cassandra/cql/AbstractModification.java
+++ b/src/java/org/apache/cassandra/cql/AbstractModification.java
@@ -107,11 +107,8 @@ public abstract class AbstractModification
      *
      * @throws InvalidRequestException on the wrong request
      */
-    public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState,
List<ByteBuffer> variables)
-    throws InvalidRequestException, UnauthorizedException
-    {
-        return prepareRowMutations(keyspace, clientState, null, variables);
-    }
+    public abstract List<IMutation> prepareRowMutations(String keyspace, ThriftClientState
clientState, List<ByteBuffer> variables)
+    throws InvalidRequestException, UnauthorizedException;
 
     /**
      * Convert statement into a list of mutations to apply on the server
@@ -124,6 +121,6 @@ public abstract class AbstractModification
      *
      * @throws InvalidRequestException on the wrong request
      */
-    public abstract List<IMutation> prepareRowMutations(String keyspace, ThriftClientState
clientState, Long batchTimestamp, List<ByteBuffer> variables)
+    public abstract List<IMutation> prepareRowMutations(String keyspace, ThriftClientState
clientState, Long timestamp, List<ByteBuffer> variables)
     throws InvalidRequestException, UnauthorizedException;
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/src/java/org/apache/cassandra/cql/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/DeleteStatement.java b/src/java/org/apache/cassandra/cql/DeleteStatement.java
index e00ffc7..71942e4 100644
--- a/src/java/org/apache/cassandra/cql/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql/DeleteStatement.java
@@ -24,7 +24,6 @@ import java.util.List;
 import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.db.CounterMutation;
 import org.apache.cassandra.db.Mutation;
 import org.apache.cassandra.db.composites.CellName;
 import org.apache.cassandra.db.IMutation;
@@ -63,7 +62,13 @@ public class DeleteStatement extends AbstractModification
         return keys;
     }
 
-    public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState,
Long batchTimestamp, List<ByteBuffer> variables)
+    public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState,
List<ByteBuffer> variables)
+    throws InvalidRequestException, UnauthorizedException
+    {
+        return prepareRowMutations(keyspace, clientState, null, variables);
+    }
+
+    public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState,
Long timestamp, List<ByteBuffer> variables)
     throws InvalidRequestException, UnauthorizedException
     {
         CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);
@@ -74,22 +79,22 @@ public class DeleteStatement extends AbstractModification
         List<IMutation> mutations = new ArrayList<IMutation>(keys.size());
 
         for (Term key : keys)
-            mutations.add(mutationForKey(key.getByteBuffer(keyType, variables), keyspace,
batchTimestamp, clientState, variables, metadata));
+            mutations.add(mutationForKey(key.getByteBuffer(keyType, variables), keyspace,
timestamp, clientState, variables, metadata));
 
         return mutations;
     }
 
-    public Mutation mutationForKey(ByteBuffer key, String keyspace, Long batchTimestamp,
ThriftClientState clientState, List<ByteBuffer> variables, CFMetaData metadata)
+    public Mutation mutationForKey(ByteBuffer key, String keyspace, Long timestamp, ThriftClientState
clientState, List<ByteBuffer> variables, CFMetaData metadata)
     throws InvalidRequestException
     {
         Mutation mutation = new Mutation(keyspace, key);
 
         QueryProcessor.validateKeyAlias(metadata, keyName);
 
-        if (columns.isEmpty())
+        if (columns.size() < 1)
         {
             // No columns, delete the partition
-            mutation.delete(columnFamily, batchTimestamp == null ? getTimestamp(clientState)
: batchTimestamp);
+            mutation.delete(columnFamily, (timestamp == null) ? getTimestamp(clientState)
: timestamp);
         }
         else
         {
@@ -99,21 +104,13 @@ public class DeleteStatement extends AbstractModification
             {
                 CellName columnName = metadata.comparator.cellFromByteBuffer(column.getByteBuffer(at,
variables));
                 validateColumnName(columnName);
-                mutation.delete(columnFamily, columnName, batchTimestamp == null ? getTimestamp(clientState)
: batchTimestamp);
+                mutation.delete(columnFamily, columnName, (timestamp == null) ? getTimestamp(clientState)
: timestamp);
             }
         }
 
         return mutation;
     }
 
-    @Override
-    public long getTimestamp(ThriftClientState clientState)
-    {
-        return Schema.instance.getCFMetaData(keyspace, columnFamily).isCounter()
-             ? CounterMutation.TOMBSTONE_TIMESTAMP
-             : super.getTimestamp(clientState);
-    }
-
     public String toString()
     {
         return String.format("DeleteStatement(columns=%s, keyspace=%s, columnFamily=%s, consistency=%s
keys=%s)",

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/src/java/org/apache/cassandra/cql/UpdateStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/UpdateStatement.java b/src/java/org/apache/cassandra/cql/UpdateStatement.java
index 8a995d2..16a0d76 100644
--- a/src/java/org/apache/cassandra/cql/UpdateStatement.java
+++ b/src/java/org/apache/cassandra/cql/UpdateStatement.java
@@ -119,6 +119,13 @@ public class UpdateStatement extends AbstractModification
     }
 
     /** {@inheritDoc} */
+    public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState,
List<ByteBuffer> variables)
+    throws InvalidRequestException, UnauthorizedException
+    {
+        return prepareRowMutations(keyspace, clientState, null, variables);
+    }
+
+    /** {@inheritDoc} */
     public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState,
Long timestamp, List<ByteBuffer> variables)
     throws InvalidRequestException, UnauthorizedException
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/src/java/org/apache/cassandra/cql3/UpdateParameters.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/UpdateParameters.java b/src/java/org/apache/cassandra/cql3/UpdateParameters.java
index 3f0c2b9..8a47536 100644
--- a/src/java/org/apache/cassandra/cql3/UpdateParameters.java
+++ b/src/java/org/apache/cassandra/cql3/UpdateParameters.java
@@ -29,7 +29,7 @@ import org.apache.cassandra.db.filter.ColumnSlice;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 
 /**
- * A simple container that simplifies passing parameters for (mostly) collections methods.
+ * A simple container that simplify passing parameters for collections methods.
  */
 public class UpdateParameters
 {
@@ -61,27 +61,21 @@ public class UpdateParameters
     public Cell makeTombstone(CellName name) throws InvalidRequestException
     {
         QueryProcessor.validateCellName(name, metadata.comparator);
-        return new BufferDeletedCell(name, localDeletionTime, tombstoneTimestamp());
+        return new BufferDeletedCell(name, localDeletionTime, timestamp);
     }
 
     public RangeTombstone makeRangeTombstone(ColumnSlice slice) throws InvalidRequestException
     {
         QueryProcessor.validateComposite(slice.start, metadata.comparator);
         QueryProcessor.validateComposite(slice.finish, metadata.comparator);
-        return new RangeTombstone(slice.start, slice.finish, tombstoneTimestamp(), localDeletionTime);
+        return new RangeTombstone(slice.start, slice.finish, timestamp, localDeletionTime);
     }
 
     public RangeTombstone makeTombstoneForOverwrite(ColumnSlice slice) throws InvalidRequestException
     {
         QueryProcessor.validateComposite(slice.start, metadata.comparator);
         QueryProcessor.validateComposite(slice.finish, metadata.comparator);
-        // As of 2.1, will never be called for a counter table. However, in 3.0, CASSANDRA-6506
might change that, so play safe.
-        return new RangeTombstone(slice.start, slice.finish, tombstoneTimestamp() - 1, localDeletionTime);
-    }
-
-    public DeletionInfo makeDeletionInfo()
-    {
-        return new DeletionInfo(tombstoneTimestamp(), localDeletionTime);
+        return new RangeTombstone(slice.start, slice.finish, timestamp - 1, localDeletionTime);
     }
 
     public List<Cell> getPrefetchedList(ByteBuffer rowKey, ColumnIdentifier cql3ColumnName)
@@ -92,9 +86,4 @@ public class UpdateParameters
         CQL3Row row = prefetchedLists.get(rowKey);
         return row == null ? Collections.<Cell>emptyList() : row.getCollection(cql3ColumnName);
     }
-
-    private long tombstoneTimestamp()
-    {
-        return metadata.isCounter() ? CounterMutation.TOMBSTONE_TIMESTAMP : timestamp;
-    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
index 1569ae4..49fdfc2 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
@@ -66,7 +66,7 @@ public class DeleteStatement extends ModificationStatement
             if (prefix.isEmpty())
             {
                 // No columns specified, delete the row
-                cf.delete(params.makeDeletionInfo());
+                cf.delete(new DeletionInfo(params.timestamp, params.localDeletionTime));
             }
             else if (cfm.comparator.isDense() && prefix.size() == cfm.clusteringColumns().size())
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/src/java/org/apache/cassandra/db/CounterMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CounterMutation.java b/src/java/org/apache/cassandra/db/CounterMutation.java
index 848e4db..2bfdd4e 100644
--- a/src/java/org/apache/cassandra/db/CounterMutation.java
+++ b/src/java/org/apache/cassandra/db/CounterMutation.java
@@ -44,9 +44,6 @@ import org.apache.cassandra.utils.*;
 
 public class CounterMutation implements IMutation
 {
-    // Counter deletions are final in C*, because there is no way to provide reliable deletion
otherwise.
-    public static final long TOMBSTONE_TIMESTAMP = Long.MAX_VALUE;
-
     public static final CounterMutationSerializer serializer = new CounterMutationSerializer();
 
     private static final Striped<Lock> LOCKS = Striped.lazyWeakLock(DatabaseDescriptor.getConcurrentCounterWriters()
* 1024);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c94caec1/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index 49466bd..1a77ffa 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -907,18 +907,16 @@ public class CassandraServer implements Cassandra.Iface
 
     private void deleteColumnOrSuperColumn(org.apache.cassandra.db.Mutation mutation, CFMetaData
cfm, Deletion del)
     {
-        long timestamp = cfm.isCounter() ? CounterMutation.TOMBSTONE_TIMESTAMP : del.timestamp;
-
         if (del.predicate != null && del.predicate.column_names != null)
         {
             for (ByteBuffer c : del.predicate.column_names)
             {
                 if (del.super_column == null && cfm.isSuper())
-                    mutation.deleteRange(cfm.cfName, SuperColumns.startOf(c), SuperColumns.endOf(c),
timestamp);
+                    mutation.deleteRange(cfm.cfName, SuperColumns.startOf(c), SuperColumns.endOf(c),
del.timestamp);
                 else if (del.super_column != null)
-                    mutation.delete(cfm.cfName, cfm.comparator.makeCellName(del.super_column,
c), timestamp);
+                    mutation.delete(cfm.cfName, cfm.comparator.makeCellName(del.super_column,
c), del.timestamp);
                 else
-                    mutation.delete(cfm.cfName, cfm.comparator.cellFromByteBuffer(c), timestamp);
+                    mutation.delete(cfm.cfName, cfm.comparator.cellFromByteBuffer(c), del.timestamp);
             }
         }
         else if (del.predicate != null && del.predicate.slice_range != null)
@@ -927,27 +925,24 @@ public class CassandraServer implements Cassandra.Iface
                 mutation.deleteRange(cfm.cfName,
                                      SuperColumns.startOf(del.predicate.getSlice_range().start),
                                      SuperColumns.startOf(del.predicate.getSlice_range().finish),
-                                     timestamp);
+                                     del.timestamp);
             else if (del.super_column != null)
-                    mutation.deleteRange(cfm.cfName,
-                                         cfm.comparator.makeCellName(del.super_column, del.predicate.getSlice_range().start),
-                                         cfm.comparator.makeCellName(del.super_column, del.predicate.getSlice_range().finish),
-                                         timestamp);
+                mutation.deleteRange(cfm.cfName,
+                                     cfm.comparator.makeCellName(del.super_column, del.predicate.getSlice_range().start),
+                                     cfm.comparator.makeCellName(del.super_column, del.predicate.getSlice_range().finish),
+                                     del.timestamp);
             else
                 mutation.deleteRange(cfm.cfName,
                                      cfm.comparator.cellFromByteBuffer(del.predicate.getSlice_range().start),
                                      cfm.comparator.cellFromByteBuffer(del.predicate.getSlice_range().finish),
-                                     timestamp);
+                                     del.timestamp);
         }
         else
         {
             if (del.super_column != null)
-                mutation.deleteRange(cfm.cfName,
-                                     SuperColumns.startOf(del.super_column),
-                                     SuperColumns.endOf(del.super_column),
-                                     timestamp);
+                mutation.deleteRange(cfm.cfName, SuperColumns.startOf(del.super_column),
SuperColumns.endOf(del.super_column), del.timestamp);
             else
-                mutation.delete(cfm.cfName, timestamp);
+                mutation.delete(cfm.cfName, del.timestamp);
         }
     }
 
@@ -1835,7 +1830,7 @@ public class CassandraServer implements Cassandra.Iface
 
         try
         {
-            internal_remove(key, path, CounterMutation.TOMBSTONE_TIMESTAMP, consistency_level,
true);
+            internal_remove(key, path, System.currentTimeMillis(), consistency_level, true);
         }
         catch (RequestValidationException e)
         {


Mime
View raw message