cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject [1/2] cassandra git commit: Aggregate with Initial Condition fails with C* 3.0
Date Tue, 20 Oct 2015 15:47:33 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 881e2da0a -> f8fa3a427


Aggregate with Initial Condition fails with C* 3.0

patch by Robert Stupp; reviewed by Sylvain Lebresne for CASSANDRA-10367


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

Branch: refs/heads/trunk
Commit: 615945d275efe1899634f7db6f240f4c1f90b495
Parents: 1b5e3a9
Author: Robert Stupp <snazy@snazy.de>
Authored: Tue Oct 20 17:45:30 2015 +0200
Committer: Robert Stupp <snazy@snazy.de>
Committed: Tue Oct 20 17:45:30 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 ...ore-3.0.0-alpha3-093a692-SNAPSHOT-shaded.jar | Bin 2281177 -> 0 bytes
 ...assandra-driver-core-3.0.0-alpha4-shaded.jar | Bin 0 -> 2275541 bytes
 .../cassandra/cql3/functions/UDFunction.java    |   4 +--
 .../cassandra/cql3/functions/UDHelper.java      |  15 +++++++----
 .../validation/operations/AggregationTest.java  |  26 +++++++++++++++++++
 6 files changed, 39 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/615945d2/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 616ff47..6c97ffb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0
+ * Aggregate with Initial Condition fails with C* 3.0 (CASSANDRA-10367)
 Merged from 2.2:
  * Expose phi values from failure detector via JMX and tweak debug
    and trace logging (CASSANDRA-9526)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/615945d2/lib/cassandra-driver-core-3.0.0-alpha3-093a692-SNAPSHOT-shaded.jar
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-core-3.0.0-alpha3-093a692-SNAPSHOT-shaded.jar b/lib/cassandra-driver-core-3.0.0-alpha3-093a692-SNAPSHOT-shaded.jar
deleted file mode 100644
index daf7837..0000000
Binary files a/lib/cassandra-driver-core-3.0.0-alpha3-093a692-SNAPSHOT-shaded.jar and /dev/null
differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/615945d2/lib/cassandra-driver-core-3.0.0-alpha4-shaded.jar
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-core-3.0.0-alpha4-shaded.jar b/lib/cassandra-driver-core-3.0.0-alpha4-shaded.jar
new file mode 100644
index 0000000..9a4921e
Binary files /dev/null and b/lib/cassandra-driver-core-3.0.0-alpha4-shaded.jar differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/615945d2/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/UDFunction.java b/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
index 36cdb15..5f7c024 100644
--- a/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
@@ -300,8 +300,8 @@ public abstract class UDFunction extends AbstractFunction implements ScalarFunct
     {
         // Get the TypeCodec stuff in Java Driver initialized.
         // This is to get the classes loaded outside of the restricted sandbox's security
context of a UDF.
-        UDHelper.codecRegistry.codecFor(DataType.inet()).format(InetAddress.getLoopbackAddress());
-        UDHelper.codecRegistry.codecFor(DataType.ascii()).format("");
+        UDHelper.codecFor(DataType.inet()).format(InetAddress.getLoopbackAddress());
+        UDHelper.codecFor(DataType.ascii()).format("");
     }
 
     private static final class ThreadIdAndCpuTime extends CompletableFuture<Object>

http://git-wip-us.apache.org/repos/asf/cassandra/blob/615945d2/src/java/org/apache/cassandra/cql3/functions/UDHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/UDHelper.java b/src/java/org/apache/cassandra/cql3/functions/UDHelper.java
index df6ca1f..d7700c4 100644
--- a/src/java/org/apache/cassandra/cql3/functions/UDHelper.java
+++ b/src/java/org/apache/cassandra/cql3/functions/UDHelper.java
@@ -38,8 +38,8 @@ import org.apache.cassandra.transport.Server;
 public final class UDHelper
 {
     // TODO make these c'tors and methods public in Java-Driver - see https://datastax-oss.atlassian.net/browse/JAVA-502
-    static final MethodHandle methodParseOne;
-    static final CodecRegistry codecRegistry;
+    private static final MethodHandle methodParseOne;
+    private static final CodecRegistry codecRegistry;
     static
     {
         try
@@ -56,6 +56,11 @@ public final class UDHelper
         }
     }
 
+    static TypeCodec<Object> codecFor(DataType dataType)
+    {
+        return codecRegistry.codecFor(dataType);
+    }
+
     /**
      * Construct an array containing the Java classes for the given Java Driver {@link com.datastax.driver.core.DataType}s.
      *
@@ -132,12 +137,12 @@ public final class UDHelper
 
     public static Object deserialize(DataType dataType, int protocolVersion, ByteBuffer value)
     {
-        return codecRegistry.codecFor(dataType).deserialize(value, ProtocolVersion.fromInt(protocolVersion));
+        return codecFor(dataType).deserialize(value, ProtocolVersion.fromInt(protocolVersion));
     }
 
     public static ByteBuffer serialize(DataType dataType, int protocolVersion, Object value)
     {
-        TypeCodec<Object> codec = codecRegistry.codecFor(dataType);
+        TypeCodec<Object> codec = codecFor(dataType);
         if (! codec.getJavaType().getRawType().isAssignableFrom(value.getClass()))
             throw new InvalidTypeException("Invalid value for CQL type " + dataType.getName().toString());
 
@@ -146,7 +151,7 @@ public final class UDHelper
 
     public static Class<?> asJavaClass(DataType dataType)
     {
-        return codecRegistry.codecFor(dataType).getJavaType().getRawType();
+        return codecFor(dataType).getJavaType().getRawType();
     }
 
     public static boolean isNullOrEmpty(AbstractType<?> type, ByteBuffer bb)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/615945d2/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
b/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
index dc47861..4341258 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.cql3.validation.operations;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.TimeZone;
@@ -1635,4 +1636,29 @@ public class AggregationTest extends CQLTester
         assertRows(execute("SELECT " + aRNON + "(b) FROM %s"), row("fin"));
 
     }
+
+    @Test
+    public void testEmptyListInitcond() throws Throwable
+    {
+        String f = createFunction(KEYSPACE,
+                                      "list, int",
+                                      "CREATE FUNCTION %s(s list<text>, i int) " +
+                                      "CALLED ON NULL INPUT " +
+                                      "RETURNS list<text> " +
+                                      "LANGUAGE java " +
+                                      "AS 'if (i != null) s.add(String.valueOf(i)); return
s;'");
+
+        String a = createAggregate(KEYSPACE,
+                                       "int",
+                                       "CREATE AGGREGATE %s(int) " +
+                                       "SFUNC " + shortFunctionName(f) + ' ' +
+                                       "STYPE list<text> " +
+                                       "INITCOND [  ]");
+
+        createTable("CREATE TABLE %s (a int primary key, b int)");
+        execute("INSERT INTO %s (a, b) VALUES (1, 1)");
+        execute("INSERT INTO %s (a, b) VALUES (2, null)");
+        execute("INSERT INTO %s (a, b) VALUES (3, 2)");
+        assertRows(execute("SELECT " + a + "(b) FROM %s"), row(Arrays.asList("1", "2")));
+    }
 }


Mime
View raw message