Ali Alsuliman has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/2980
Change subject: [NO ISSUE][COMP] allow optimization rule to inspect other
functions
......................................................................
[NO ISSUE][COMP] allow optimization rule to inspect other functions
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
This change is to allow optimization rule "InjectTypeCastForSwitchCaseRule"
to consider other functions specified by the user in addition to the ones
already considered by the rule.
Change-Id: I65679e934a41e00b04bc3fd479ed404af293eb21
---
M
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
1 file changed, 13 insertions(+), 1 deletion(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/80/2980/1
diff --git
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
index 683d29f..33c48a9 100644
---
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
+++
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
@@ -23,6 +23,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
+import java.util.function.Predicate;
import org.apache.asterix.dataflow.data.common.TypeResolverUtil;
import org.apache.asterix.lang.common.util.FunctionUtil;
@@ -53,8 +54,19 @@
*/
public class InjectTypeCastForSwitchCaseRule implements IAlgebraicRewriteRule {
+ // allows the rule to check other functions in addition to the ones
specified here
+ private final Predicate<FunctionIdentifier> otherFunctionsChecker;
private static final Set<FunctionIdentifier> IF_FUNCTIONS =
ImmutableSet.of(BuiltinFunctions.IF_MISSING,
BuiltinFunctions.IF_NULL, BuiltinFunctions.IF_MISSING_OR_NULL);
+
+ public InjectTypeCastForSwitchCaseRule() {
+ // if no function checker is specified, then the rule checks only the
functions specified here
+ this(function -> false);
+ }
+
+ public InjectTypeCastForSwitchCaseRule(Predicate<FunctionIdentifier>
functionChecker) {
+ this.otherFunctionsChecker = functionChecker;
+ }
@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef,
IOptimizationContext context)
@@ -95,7 +107,7 @@
if (rewriteSwitchCase(op, func, context)) {
rewritten = true;
}
- } else if (IF_FUNCTIONS.contains(funcId)) {
+ } else if (IF_FUNCTIONS.contains(funcId) ||
otherFunctionsChecker.test(funcId)) {
if (rewriteFunction(op, func, context)) {
rewritten = true;
}
--
To view, visit https://asterix-gerrit.ics.uci.edu/2980
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65679e934a41e00b04bc3fd479ed404af293eb21
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Ali Alsuliman <[email protected]>