cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/3] cassandra git commit: Fix NPE when writetime() or ttl() are nested inside a fn call
Date Fri, 12 Dec 2014 17:01:22 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 2fdd1d59c -> e530f4230


Fix NPE when writetime() or ttl() are nested inside a fn call

Patch by Tyler Hobbs; reviewed by Benjamin Lerer for CASSANDRA-8451


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

Branch: refs/heads/trunk
Commit: 3f3d0edbad6b42f5fc8715ecfa52e2e41bbdcea9
Parents: ac9cfbd
Author: Tyler Hobbs <tyler@datastax.com>
Authored: Fri Dec 12 10:49:32 2014 -0600
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Fri Dec 12 10:49:32 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../cassandra/cql3/statements/Selection.java    | 50 ++++++++++++++++++--
 2 files changed, 47 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3f3d0edb/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c25caf9..cc426bb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.12:
+ * Fix NPE when writetime() or ttl() calls are wrapped by
+   another function call (CASSANDRA-8451)
  * Fix NPE after dropping a keyspace (CASSANDRA-8332)
  * Fix error message on read repair timeouts (CASSANDRA-7947)
  * Default DTCS base_time_seconds changed to 60 (CASSANDRA-8417)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3f3d0edb/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 407f7d9..223f698 100644
--- a/src/java/org/apache/cassandra/cql3/statements/Selection.java
+++ b/src/java/org/apache/cassandra/cql3/statements/Selection.java
@@ -186,11 +186,8 @@ public abstract class Selection
             {
                 Selector selector = makeSelector(cfDef, rawSelector, names, metadata);
                 selectors.add(selector);
-                if (selector instanceof WritetimeOrTTLSelector)
-                {
-                    collectTimestamps |= ((WritetimeOrTTLSelector)selector).isWritetime;
-                    collectTTLs |= !((WritetimeOrTTLSelector)selector).isWritetime;
-                }
+                collectTimestamps |= selector.usesTimestamps();
+                collectTTLs |= selector.usesTTLs();
             }
             return new SelectionWithProcessing(names, metadata, selectors, collectTimestamps,
collectTTLs);
         }
@@ -374,6 +371,12 @@ public abstract class Selection
     private interface Selector extends AssignementTestable
     {
         public ByteBuffer compute(ResultSetBuilder rs) throws InvalidRequestException;
+
+        /** Returns true if the selector acts on a column's timestamp, false otherwise. */
+        public boolean usesTimestamps();
+
+        /** Returns true if the selector acts on a column's TTL, false otherwise. */
+        public boolean usesTTLs();
     }
 
     private static class SimpleSelector implements Selector
@@ -399,6 +402,16 @@ public abstract class Selection
             return receiver.type.isValueCompatibleWith(type);
         }
 
+        public boolean usesTimestamps()
+        {
+            return false;
+        }
+
+        public boolean usesTTLs()
+        {
+            return false;
+        }
+
         @Override
         public String toString()
         {
@@ -431,6 +444,22 @@ public abstract class Selection
             return receiver.type.isValueCompatibleWith(fun.returnType());
         }
 
+        public boolean usesTimestamps()
+        {
+            for (Selector s : argSelectors)
+                if (s.usesTimestamps())
+                    return true;
+            return false;
+        }
+
+        public boolean usesTTLs()
+        {
+            for (Selector s : argSelectors)
+                if (s.usesTTLs())
+                    return true;
+            return false;
+        }
+
         @Override
         public String toString()
         {
@@ -476,6 +505,17 @@ public abstract class Selection
             return receiver.type.isValueCompatibleWith(isWritetime ? LongType.instance :
Int32Type.instance);
         }
 
+
+        public boolean usesTimestamps()
+        {
+            return isWritetime;
+        }
+
+        public boolean usesTTLs()
+        {
+            return !isWritetime;
+        }
+
         @Override
         public String toString()
         {


Mime
View raw message