phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/2] phoenix git commit: PHOENIX-4294 Allow scalar function to declare that it's not thread safe
Date Wed, 18 Oct 2017 16:30:10 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master bab06d688 -> c594038a1


PHOENIX-4294 Allow scalar function to declare that it's not thread safe


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

Branch: refs/heads/master
Commit: ccc44386e05fd7191cd498c8e35b4bb96df2eef7
Parents: bab06d6
Author: James Taylor <jtaylor@salesforce.com>
Authored: Wed Oct 18 09:28:31 2017 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Wed Oct 18 09:28:31 2017 -0700

----------------------------------------------------------------------
 .../apache/phoenix/expression/function/ScalarFunction.java  | 9 +++++++++
 .../phoenix/expression/visitor/CloneExpressionVisitor.java  | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ccc44386/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java
index 4f44cde..2a5fe44 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ScalarFunction.java
@@ -87,4 +87,13 @@ public abstract class ScalarFunction extends FunctionExpression {
     public KeyPart newKeyPart(KeyPart childPart) {
         return null;
     }
+    
+    /**
+     * Used to determine if the same ScalarFunction instance may be
+     * used by multiple threads. 
+     * @return true if function is thread safe and false otherwise.
+     */
+    public boolean isThreadSafe() {
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ccc44386/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneExpressionVisitor.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneExpressionVisitor.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneExpressionVisitor.java
index e47fb64..c6d7c9e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneExpressionVisitor.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneExpressionVisitor.java
@@ -110,7 +110,7 @@ public abstract class CloneExpressionVisitor extends TraverseAllExpressionVisito
 
     @Override
     public Expression visitLeave(ScalarFunction node, List<Expression> l) {
-        return isCloneNode(node, l) ? node.clone(l) : node;
+        return isCloneNode(node, l) || !node.isThreadSafe() ? node.clone(l) : node;
     }
 
     public Expression visitLeave(UDFExpression node, List<Expression> l) {


Mime
View raw message