Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C7845105ED for ; Wed, 11 Sep 2013 06:36:38 +0000 (UTC) Received: (qmail 89558 invoked by uid 500); 11 Sep 2013 06:36:36 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 89466 invoked by uid 500); 11 Sep 2013 06:36:34 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 89414 invoked by uid 99); 11 Sep 2013 06:36:31 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Sep 2013 06:36:31 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7B1108BD61A; Wed, 11 Sep 2013 06:36:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: slebresne@apache.org To: commits@cassandra.apache.org Date: Wed, 11 Sep 2013 06:36:32 -0000 Message-Id: <102b82a3c59b4e3294f7f8551c98284a@git.apache.org> In-Reply-To: <9066265925b145ec99eeed4e3d7be8f9@git.apache.org> References: <9066265925b145ec99eeed4e3d7be8f9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] git commit: Support null in CQL3 functions 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/trunk Commit: 8bedb57207d54c4e88a762221d20d814fc351b1f Parents: 9b545ca Author: Sylvain Lebresne Authored: Wed Sep 11 08:31:05 2013 +0200 Committer: Sylvain Lebresne 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 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 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 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 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 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())); } }