Search in sources :

Example 1 with ExtractCommonExpressionsRule

use of org.apache.hyracks.algebricks.rewriter.rules.ExtractCommonExpressionsRule in project asterixdb by apache.

the class RuleCollections method buildPlanCleanupRuleCollection.

public static final List<IAlgebraicRewriteRule> buildPlanCleanupRuleCollection() {
    List<IAlgebraicRewriteRule> planCleanupRules = new LinkedList<>();
    planCleanupRules.add(new SwitchInnerJoinBranchRule());
    planCleanupRules.add(new PushAssignBelowUnionAllRule());
    planCleanupRules.add(new ExtractCommonExpressionsRule());
    planCleanupRules.add(new RemoveRedundantVariablesRule());
    planCleanupRules.add(new PushProjectDownRule());
    planCleanupRules.add(new PushSelectDownRule());
    planCleanupRules.add(new SetClosedRecordConstructorsRule());
    planCleanupRules.add(new IntroduceDynamicTypeCastRule());
    planCleanupRules.add(new IntroduceDynamicTypeCastForExternalFunctionRule());
    planCleanupRules.add(new RemoveUnusedAssignAndAggregateRule());
    planCleanupRules.add(new RemoveCartesianProductWithEmptyBranchRule());
    planCleanupRules.add(new InjectTypeCastForSwitchCaseRule());
    planCleanupRules.add(new InjectTypeCastForUnionRule());
    // Needs to invoke ByNameToByIndexFieldAccessRule as the last logical optimization rule because
    // some rules can push a FieldAccessByName to a place where the name it tries to access is in the closed part.
    // For example, a possible scenario is that a field-access-by-name can be pushed down through UnionAllOperator.
    planCleanupRules.add(new ByNameToByIndexFieldAccessRule());
    return planCleanupRules;
}
Also used : IntroduceDynamicTypeCastRule(org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastRule) ByNameToByIndexFieldAccessRule(org.apache.asterix.optimizer.rules.ByNameToByIndexFieldAccessRule) PushProjectDownRule(org.apache.hyracks.algebricks.rewriter.rules.PushProjectDownRule) SwitchInnerJoinBranchRule(org.apache.hyracks.algebricks.rewriter.rules.SwitchInnerJoinBranchRule) IntroduceDynamicTypeCastForExternalFunctionRule(org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastForExternalFunctionRule) ExtractCommonExpressionsRule(org.apache.hyracks.algebricks.rewriter.rules.ExtractCommonExpressionsRule) PushAssignBelowUnionAllRule(org.apache.hyracks.algebricks.rewriter.rules.PushAssignBelowUnionAllRule) LinkedList(java.util.LinkedList) PushSelectDownRule(org.apache.hyracks.algebricks.rewriter.rules.PushSelectDownRule) RemoveCartesianProductWithEmptyBranchRule(org.apache.hyracks.algebricks.rewriter.rules.RemoveCartesianProductWithEmptyBranchRule) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) InjectTypeCastForUnionRule(org.apache.asterix.optimizer.rules.InjectTypeCastForUnionRule) SetClosedRecordConstructorsRule(org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule) RemoveRedundantVariablesRule(org.apache.hyracks.algebricks.rewriter.rules.RemoveRedundantVariablesRule) RemoveUnusedAssignAndAggregateRule(org.apache.hyracks.algebricks.rewriter.rules.RemoveUnusedAssignAndAggregateRule) InjectTypeCastForSwitchCaseRule(org.apache.asterix.optimizer.rules.InjectTypeCastForSwitchCaseRule)

Example 2 with ExtractCommonExpressionsRule

use of org.apache.hyracks.algebricks.rewriter.rules.ExtractCommonExpressionsRule in project asterixdb by apache.

the class RuleCollections method buildNormalizationRuleCollection.

public static final List<IAlgebraicRewriteRule> buildNormalizationRuleCollection(ICcApplicationContext appCtx) {
    List<IAlgebraicRewriteRule> normalization = new LinkedList<>();
    normalization.add(new ResolveVariableRule());
    normalization.add(new CheckInsertUpsertReturningRule());
    normalization.add(new IntroduceUnnestForCollectionToSequenceRule());
    normalization.add(new EliminateSubplanRule());
    normalization.add(new EnforceOrderByAfterSubplan());
    normalization.add(new BreakSelectIntoConjunctsRule());
    normalization.add(new ExtractGbyExpressionsRule());
    normalization.add(new ExtractDistinctByExpressionsRule());
    normalization.add(new ExtractOrderExpressionsRule());
    // IntroduceStaticTypeCastRule should go before
    // IntroduceDynamicTypeCastRule to
    // avoid unnecessary dynamic casting
    normalization.add(new IntroduceStaticTypeCastForInsertRule());
    normalization.add(new IntroduceDynamicTypeCastRule());
    normalization.add(new IntroduceDynamicTypeCastForExternalFunctionRule());
    normalization.add(new IntroduceEnforcedListTypeRule());
    normalization.add(new ExtractCommonExpressionsRule());
    // Let PushAggFuncIntoStandaloneAggregateRule run after ExtractCommonExpressionsRule
    // so that PushAggFunc can happen in fewer places.
    normalization.add(new PushAggFuncIntoStandaloneAggregateRule());
    normalization.add(new ListifyUnnestingFunctionRule());
    normalization.add(new ConstantFoldingRule(appCtx));
    normalization.add(new RemoveRedundantSelectRule());
    normalization.add(new UnnestToDataScanRule());
    normalization.add(new MetaFunctionToMetaVariableRule());
    normalization.add(new FuzzyEqRule());
    normalization.add(new SimilarityCheckRule());
    return normalization;
}
Also used : IntroduceDynamicTypeCastRule(org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastRule) EnforceOrderByAfterSubplan(org.apache.hyracks.algebricks.rewriter.rules.EnforceOrderByAfterSubplan) IntroduceEnforcedListTypeRule(org.apache.asterix.optimizer.rules.IntroduceEnforcedListTypeRule) ExtractGbyExpressionsRule(org.apache.hyracks.algebricks.rewriter.rules.ExtractGbyExpressionsRule) ExtractOrderExpressionsRule(org.apache.asterix.optimizer.rules.ExtractOrderExpressionsRule) IntroduceDynamicTypeCastForExternalFunctionRule(org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastForExternalFunctionRule) IntroduceUnnestForCollectionToSequenceRule(org.apache.asterix.optimizer.rules.IntroduceUnnestForCollectionToSequenceRule) ExtractDistinctByExpressionsRule(org.apache.asterix.optimizer.rules.ExtractDistinctByExpressionsRule) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) IntroduceStaticTypeCastForInsertRule(org.apache.asterix.optimizer.rules.IntroduceStaticTypeCastForInsertRule) ListifyUnnestingFunctionRule(org.apache.asterix.optimizer.rules.ListifyUnnestingFunctionRule) FuzzyEqRule(org.apache.asterix.optimizer.rules.FuzzyEqRule) ExtractCommonExpressionsRule(org.apache.hyracks.algebricks.rewriter.rules.ExtractCommonExpressionsRule) LinkedList(java.util.LinkedList) UnnestToDataScanRule(org.apache.asterix.optimizer.rules.UnnestToDataScanRule) EliminateSubplanRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule) ConstantFoldingRule(org.apache.asterix.optimizer.rules.ConstantFoldingRule) SimilarityCheckRule(org.apache.asterix.optimizer.rules.SimilarityCheckRule) BreakSelectIntoConjunctsRule(org.apache.hyracks.algebricks.rewriter.rules.BreakSelectIntoConjunctsRule) RemoveRedundantSelectRule(org.apache.asterix.optimizer.rules.RemoveRedundantSelectRule) MetaFunctionToMetaVariableRule(org.apache.asterix.optimizer.rules.MetaFunctionToMetaVariableRule) ResolveVariableRule(org.apache.asterix.optimizer.rules.ResolveVariableRule) PushAggFuncIntoStandaloneAggregateRule(org.apache.asterix.optimizer.rules.PushAggFuncIntoStandaloneAggregateRule) CheckInsertUpsertReturningRule(org.apache.asterix.optimizer.rules.CheckInsertUpsertReturningRule)

Aggregations

LinkedList (java.util.LinkedList)2 IntroduceDynamicTypeCastForExternalFunctionRule (org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastForExternalFunctionRule)2 IntroduceDynamicTypeCastRule (org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastRule)2 IAlgebraicRewriteRule (org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule)2 ExtractCommonExpressionsRule (org.apache.hyracks.algebricks.rewriter.rules.ExtractCommonExpressionsRule)2 ByNameToByIndexFieldAccessRule (org.apache.asterix.optimizer.rules.ByNameToByIndexFieldAccessRule)1 CheckInsertUpsertReturningRule (org.apache.asterix.optimizer.rules.CheckInsertUpsertReturningRule)1 ConstantFoldingRule (org.apache.asterix.optimizer.rules.ConstantFoldingRule)1 ExtractDistinctByExpressionsRule (org.apache.asterix.optimizer.rules.ExtractDistinctByExpressionsRule)1 ExtractOrderExpressionsRule (org.apache.asterix.optimizer.rules.ExtractOrderExpressionsRule)1 FuzzyEqRule (org.apache.asterix.optimizer.rules.FuzzyEqRule)1 InjectTypeCastForSwitchCaseRule (org.apache.asterix.optimizer.rules.InjectTypeCastForSwitchCaseRule)1 InjectTypeCastForUnionRule (org.apache.asterix.optimizer.rules.InjectTypeCastForUnionRule)1 IntroduceEnforcedListTypeRule (org.apache.asterix.optimizer.rules.IntroduceEnforcedListTypeRule)1 IntroduceStaticTypeCastForInsertRule (org.apache.asterix.optimizer.rules.IntroduceStaticTypeCastForInsertRule)1 IntroduceUnnestForCollectionToSequenceRule (org.apache.asterix.optimizer.rules.IntroduceUnnestForCollectionToSequenceRule)1 ListifyUnnestingFunctionRule (org.apache.asterix.optimizer.rules.ListifyUnnestingFunctionRule)1 MetaFunctionToMetaVariableRule (org.apache.asterix.optimizer.rules.MetaFunctionToMetaVariableRule)1 PushAggFuncIntoStandaloneAggregateRule (org.apache.asterix.optimizer.rules.PushAggFuncIntoStandaloneAggregateRule)1 RemoveRedundantSelectRule (org.apache.asterix.optimizer.rules.RemoveRedundantSelectRule)1