You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2013/09/11 08:32:28 UTC

[1/2] git commit: Allow empty CQL3 batches as no-op

Updated Branches:
  refs/heads/cassandra-1.2 fd129664c -> 8bedb5720


Allow empty CQL3 batches as no-op

patch by slebresne; reviewed by iamaleksey for CASSANDRA-5994


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

Branch: refs/heads/cassandra-1.2
Commit: 9b545caab5376e7f6e43aba49888df662a5d6e0d
Parents: fd12966
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Wed Sep 11 08:29:25 2013 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Wed Sep 11 08:29:25 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                              | 1 +
 src/java/org/apache/cassandra/cql3/Cql.g | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b545caa/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 12e2017..cfcb364 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,7 @@
  * Correctly handle limits in CompositesSearcher (CASSANDRA-5975)
  * Pig: handle CQL collections (CASSANDRA-5867)
  * Pass the updated cf to the PRSI index() method (CASSANDRA-5999)
+ * Allow empty CQL3 batches (as no-op) (CASSANDRA-5994)
 
 
 1.2.9

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b545caa/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Cql.g b/src/java/org/apache/cassandra/cql3/Cql.g
index f59be51..2445bf2 100644
--- a/src/java/org/apache/cassandra/cql3/Cql.g
+++ b/src/java/org/apache/cassandra/cql3/Cql.g
@@ -386,7 +386,7 @@ batchStatement returns [BatchStatement expr]
     : K_BEGIN
       ( K_UNLOGGED { type = BatchStatement.Type.UNLOGGED; } | K_COUNTER { type = BatchStatement.Type.COUNTER; } )?
       K_BATCH ( usingClause[attrs] )?
-          ( s=batchStatementObjective ';'? { statements.add(s); } )+
+          ( s=batchStatementObjective ';'? { statements.add(s); } )*
       K_APPLY K_BATCH
       {
           return new BatchStatement(type, statements, attrs);


[2/2] git commit: Support null in CQL3 functions

Posted by sl...@apache.org.
Support null in CQL3 functions

patch by slebresne; reviewed by iamaleksey for CASSANDRA-5910


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

Branch: refs/heads/cassandra-1.2
Commit: 8bedb57207d54c4e88a762221d20d814fc351b1f
Parents: 9b545ca
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Wed Sep 11 08:31:05 2013 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Wed Sep 11 08:31:05 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/cql3/functions/TimeuuidFcts.java  | 24 ++++++++++++++++----
 .../cassandra/cql3/functions/TokenFct.java      |  7 +++++-
 3 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8bedb572/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index cfcb364..e420a7b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -12,6 +12,7 @@
  * Pig: handle CQL collections (CASSANDRA-5867)
  * Pass the updated cf to the PRSI index() method (CASSANDRA-5999)
  * Allow empty CQL3 batches (as no-op) (CASSANDRA-5994)
+ * Support null in CQL3 functions (CASSANDRA-5910)
 
 
 1.2.9

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8bedb572/src/java/org/apache/cassandra/cql3/functions/TimeuuidFcts.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/TimeuuidFcts.java b/src/java/org/apache/cassandra/cql3/functions/TimeuuidFcts.java
index e325e8f..52eca54 100644
--- a/src/java/org/apache/cassandra/cql3/functions/TimeuuidFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/TimeuuidFcts.java
@@ -47,7 +47,11 @@ public abstract class TimeuuidFcts
     {
         public ByteBuffer execute(List<ByteBuffer> parameters)
         {
-            return ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.minTimeUUID(DateType.instance.compose(parameters.get(0)).getTime())));
+            ByteBuffer bb = parameters.get(0);
+            if (bb == null)
+                return null;
+
+            return ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.minTimeUUID(DateType.instance.compose(bb).getTime())));
         }
     };
 
@@ -55,7 +59,11 @@ public abstract class TimeuuidFcts
     {
         public ByteBuffer execute(List<ByteBuffer> parameters)
         {
-            return ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.maxTimeUUID(DateType.instance.compose(parameters.get(0)).getTime())));
+            ByteBuffer bb = parameters.get(0);
+            if (bb == null)
+                return null;
+
+            return ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.maxTimeUUID(DateType.instance.compose(bb).getTime())));
         }
     };
 
@@ -63,7 +71,11 @@ public abstract class TimeuuidFcts
     {
         public ByteBuffer execute(List<ByteBuffer> parameters)
         {
-            return DateType.instance.decompose(new Date(UUIDGen.unixTimestamp(UUIDGen.getUUID(parameters.get(0)))));
+            ByteBuffer bb = parameters.get(0);
+            if (bb == null)
+                return null;
+
+            return DateType.instance.decompose(new Date(UUIDGen.unixTimestamp(UUIDGen.getUUID(bb))));
         }
     };
 
@@ -71,7 +83,11 @@ public abstract class TimeuuidFcts
     {
         public ByteBuffer execute(List<ByteBuffer> parameters)
         {
-            return ByteBufferUtil.bytes(UUIDGen.unixTimestamp(UUIDGen.getUUID(parameters.get(0))));
+            ByteBuffer bb = parameters.get(0);
+            if (bb == null)
+                return null;
+
+            return ByteBufferUtil.bytes(UUIDGen.unixTimestamp(UUIDGen.getUUID(bb)));
         }
     };
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8bedb572/src/java/org/apache/cassandra/cql3/functions/TokenFct.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/TokenFct.java b/src/java/org/apache/cassandra/cql3/functions/TokenFct.java
index 21695ca..28da87a 100644
--- a/src/java/org/apache/cassandra/cql3/functions/TokenFct.java
+++ b/src/java/org/apache/cassandra/cql3/functions/TokenFct.java
@@ -62,8 +62,13 @@ public class TokenFct extends AbstractFunction
     public ByteBuffer execute(List<ByteBuffer> parameters) throws InvalidRequestException
     {
         ColumnNameBuilder builder = cfDef.getKeyNameBuilder();
-        for (ByteBuffer bb : parameters)
+        for (int i = 0; i < parameters.size(); i++)
+        {
+            ByteBuffer bb = parameters.get(i);
+            if (bb == null)
+                return null;
             builder.add(bb);
+        }
         return partitioner.getTokenFactory().toByteArray(partitioner.getToken(builder.build()));
     }
 }