You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2015/09/03 23:41:57 UTC

[10/12] phoenix git commit: PHOENIX-2160 - Add new files

PHOENIX-2160 - Add new files


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

Branch: refs/heads/calcite
Commit: caaf29e920e517d872cf8adad7fddc09328140fe
Parents: 7d7c217
Author: ramkrishna <ra...@gmail.com>
Authored: Wed Sep 2 17:07:47 2015 +0530
Committer: ramkrishna <ra...@gmail.com>
Committed: Wed Sep 2 17:07:47 2015 +0530

----------------------------------------------------------------------
 .../CloneNonDeterministicExpressionVisitor.java | 30 +++++++++++++
 .../ProjectedColumnExpressionVisitor.java       | 25 +++++++++++
 .../ReplaceArrayFunctionExpressionVisitor.java  | 46 ++++++++++++++++++++
 3 files changed, 101 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/caaf29e9/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneNonDeterministicExpressionVisitor.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneNonDeterministicExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneNonDeterministicExpressionVisitor.java
new file mode 100644
index 0000000..1aeb9a9
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/CloneNonDeterministicExpressionVisitor.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.expression.visitor;
+
+import java.util.List;
+
+import org.apache.phoenix.expression.Determinism;
+import org.apache.phoenix.expression.Expression;
+
+public class CloneNonDeterministicExpressionVisitor extends CloneExpressionVisitor {
+
+    public boolean isCloneNode(Expression node, List<Expression> children) {
+        return Determinism.PER_INVOCATION.compareTo(node.getDeterminism()) <= 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/caaf29e9/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ProjectedColumnExpressionVisitor.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ProjectedColumnExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ProjectedColumnExpressionVisitor.java
new file mode 100644
index 0000000..2380c6b
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ProjectedColumnExpressionVisitor.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.expression.visitor;
+
+import org.apache.phoenix.expression.ProjectedColumnExpression;
+
+public abstract class ProjectedColumnExpressionVisitor extends StatelessTraverseAllExpressionVisitor<Void> {
+    @Override
+    abstract public Void visit(ProjectedColumnExpression node);
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/caaf29e9/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ReplaceArrayFunctionExpressionVisitor.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ReplaceArrayFunctionExpressionVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ReplaceArrayFunctionExpressionVisitor.java
new file mode 100644
index 0000000..2a460a4
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/visitor/ReplaceArrayFunctionExpressionVisitor.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.expression.visitor;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.ScalarFunction;
+
+public class ReplaceArrayFunctionExpressionVisitor extends CloneExpressionVisitor {
+    private Map<Expression, Expression> replacementMap;
+
+    public ReplaceArrayFunctionExpressionVisitor(Map<Expression, Expression> replacementMap) {
+        this.replacementMap = replacementMap;
+    }
+
+    @Override
+    public boolean isCloneNode(Expression node, List<Expression> children) {
+        return !children.equals(node.getChildren());
+    }
+
+    @Override
+    public Expression visitLeave(ScalarFunction node, List<Expression> l) {
+        Expression replacement = replacementMap.get(node);
+        if (replacement != null) {
+            return replacement;
+        }
+        return super.visitLeave(node, l);
+    }
+}