cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject [1/3] cassandra git commit: Duplicate compilation of UDFs on coordinator
Date Tue, 26 May 2015 16:47:10 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 2385dc2d9 -> 248ea0b34
  refs/heads/trunk 13409fdf0 -> f5f8806c4


Duplicate compilation of UDFs on coordinator

patch by Robert Stupp; reviewed by Tyler Hobbs for CASSANDRA-9475


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

Branch: refs/heads/cassandra-2.2
Commit: 248ea0b3459eed6283418c63c467f5bf4e487206
Parents: 2385dc2
Author: Robert Stupp <snazy@snazy.de>
Authored: Tue May 26 18:45:54 2015 +0200
Committer: Robert Stupp <snazy@snazy.de>
Committed: Tue May 26 18:45:54 2015 +0200

----------------------------------------------------------------------
 .../cassandra/schema/LegacySchemaTables.java    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/248ea0b3/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/LegacySchemaTables.java b/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
index 720f309..a825972 100644
--- a/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
+++ b/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
@@ -1337,6 +1337,26 @@ public class LegacySchemaTables
         String body = row.getString("body");
         boolean calledOnNullInput = row.getBoolean("called_on_null_input");
 
+        org.apache.cassandra.cql3.functions.Function existing = org.apache.cassandra.cql3.functions.Functions.find(name,
argTypes);
+        if (existing instanceof UDFunction)
+        {
+            // This check prevents duplicate compilation of effectively the same UDF.
+            // Duplicate compilation attempts can occur on the coordinator node handling
the CREATE FUNCTION
+            // statement, since CreateFunctionStatement needs to execute UDFunction.create
but schema migration
+            // also needs that (since it needs to handle its own change).
+            UDFunction udf = (UDFunction) existing;
+            if (udf.argNames().equals(argNames) && // arg types checked in Functions.find
call
+                udf.returnType().equals(returnType) &&
+                !udf.isAggregate() &&
+                udf.language().equals(language) &&
+                udf.body().equals(body) &&
+                udf.isCalledOnNullInput() == calledOnNullInput)
+            {
+                logger.debug("Skipping duplicate compilation of already existing UDF {}",
name);
+                return udf;
+            }
+        }
+
         try
         {
             return UDFunction.create(name, argNames, argTypes, returnType, calledOnNullInput,
language, body);


Mime
View raw message