cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Handle negative timestamps in writetime method
Date Wed, 29 Oct 2014 09:34:59 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 1b332bc1c -> 748b01d1d


Handle negative timestamps in writetime method

patch by slebresne; reviewed by thobbs for CASSANDRA-8139


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

Branch: refs/heads/cassandra-2.0
Commit: 748b01d1d6c6591d0a241ced3f0f729a84ee3ef6
Parents: 1b332bc
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Oct 29 10:34:26 2014 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Oct 29 10:34:26 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 src/java/org/apache/cassandra/cql3/UpdateParameters.java     | 6 ++++++
 src/java/org/apache/cassandra/cql3/statements/Selection.java | 4 ++--
 3 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/748b01d1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 11f6517..d2cb003 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.12:
+ * Handle negative timestamp in writetime method (CASSANDRA-8139)
  * Pig: Remove errant LIMIT clause in CqlNativeStorage (CASSANDRA-8166)
  * Throw ConfigurationException when hsha is used with the default
    rpc_max_threads setting of 'unlimited' (CASSANDRA-8116)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/748b01d1/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 c543d6c..6c71911 100644
--- a/src/java/org/apache/cassandra/cql3/UpdateParameters.java
+++ b/src/java/org/apache/cassandra/cql3/UpdateParameters.java
@@ -43,6 +43,7 @@ public class UpdateParameters
     private final Map<ByteBuffer, ColumnGroupMap> prefetchedLists;
 
     public UpdateParameters(CFMetaData metadata, List<ByteBuffer> variables, long timestamp,
int ttl, Map<ByteBuffer, ColumnGroupMap> prefetchedLists)
+    throws InvalidRequestException
     {
         this.metadata = metadata;
         this.variables = variables;
@@ -50,6 +51,11 @@ public class UpdateParameters
         this.ttl = ttl;
         this.localDeletionTime = (int)(System.currentTimeMillis() / 1000);
         this.prefetchedLists = prefetchedLists;
+
+        // We use MIN_VALUE internally to mean the absence of of timestamp (in Selection,
in sstable stats, ...), so exclude
+        // it to avoid potential confusion.
+        if (timestamp == Long.MIN_VALUE)
+            throw new InvalidRequestException(String.format("Out of bound timestamp, must
be in [%d, %d]", Long.MIN_VALUE + 1, Long.MAX_VALUE));
     }
 
     public Column makeColumn(ByteBuffer name, ByteBuffer value) throws InvalidRequestException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/748b01d1/src/java/org/apache/cassandra/cql3/statements/Selection.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/Selection.java b/src/java/org/apache/cassandra/cql3/statements/Selection.java
index 37ab384..18ca177 100644
--- a/src/java/org/apache/cassandra/cql3/statements/Selection.java
+++ b/src/java/org/apache/cassandra/cql3/statements/Selection.java
@@ -277,7 +277,7 @@ public abstract class Selection
             current.add(isDead(c) ? null : value(c));
             if (timestamps != null)
             {
-                timestamps[current.size() - 1] = isDead(c) ? -1 : c.timestamp();
+                timestamps[current.size() - 1] = isDead(c) ? Long.MIN_VALUE : c.timestamp();
             }
             if (ttls != null)
             {
@@ -437,7 +437,7 @@ public abstract class Selection
             if (isWritetime)
             {
                 long ts = rs.timestamps[idx];
-                return ts >= 0 ? ByteBufferUtil.bytes(ts) : null;
+                return ts != Long.MIN_VALUE ? ByteBufferUtil.bytes(ts) : null;
             }
 
             int ttl = rs.ttls[idx];


Mime
View raw message