Search in sources :

Example 1 with IAlgebraicRewriteRule

use of org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule in project asterixdb by apache.

the class DefaultRuleSetFactory method buildPhysical.

public static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> buildPhysical(ICcApplicationContext appCtx) {
    List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> defaultPhysicalRewrites = new ArrayList<>();
    SequentialOnceRuleController seqOnceCtrl = new SequentialOnceRuleController(true);
    SequentialOnceRuleController seqOnceTopLevel = new SequentialOnceRuleController(false);
    defaultPhysicalRewrites.add(new Pair<>(seqOnceCtrl, RuleCollections.buildPhysicalRewritesAllLevelsRuleCollection()));
    defaultPhysicalRewrites.add(new Pair<>(seqOnceTopLevel, RuleCollections.buildPhysicalRewritesTopLevelRuleCollection(appCtx)));
    defaultPhysicalRewrites.add(new Pair<>(seqOnceCtrl, RuleCollections.prepareForJobGenRuleCollection()));
    return defaultPhysicalRewrites;
}
Also used : SequentialOnceRuleController(org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialOnceRuleController) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) ArrayList(java.util.ArrayList) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 2 with IAlgebraicRewriteRule

use of org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule in project asterixdb by apache.

the class RuleCollections method buildCondPushDownAndJoinInferenceRuleCollection.

public static final List<IAlgebraicRewriteRule> buildCondPushDownAndJoinInferenceRuleCollection() {
    List<IAlgebraicRewriteRule> condPushDownAndJoinInference = new LinkedList<>();
    condPushDownAndJoinInference.add(new PushSelectDownRule());
    condPushDownAndJoinInference.add(new PushSortDownRule());
    condPushDownAndJoinInference.add(new RemoveRedundantListifyRule());
    condPushDownAndJoinInference.add(new CancelUnnestWithNestedListifyRule());
    condPushDownAndJoinInference.add(new SimpleUnnestToProductRule());
    condPushDownAndJoinInference.add(new ComplexUnnestToProductRule());
    condPushDownAndJoinInference.add(new DisjunctivePredicateToJoinRule());
    condPushDownAndJoinInference.add(new PushSelectIntoJoinRule());
    condPushDownAndJoinInference.add(new IntroJoinInsideSubplanRule());
    // Apply RemoveCartesianProductWithEmptyBranchRule before PushMapOperatorDownThroughProductRule
    // to avoid that a constant assignment gets pushed into an empty branch.
    condPushDownAndJoinInference.add(new RemoveCartesianProductWithEmptyBranchRule());
    condPushDownAndJoinInference.add(new PushMapOperatorDownThroughProductRule());
    condPushDownAndJoinInference.add(new PushSubplanWithAggregateDownThroughProductRule());
    condPushDownAndJoinInference.add(new SubplanOutOfGroupRule());
    condPushDownAndJoinInference.add(new AsterixExtractFunctionsFromJoinConditionRule());
    condPushDownAndJoinInference.add(new RemoveRedundantVariablesRule());
    condPushDownAndJoinInference.add(new AsterixInlineVariablesRule());
    condPushDownAndJoinInference.add(new RemoveUnusedAssignAndAggregateRule());
    condPushDownAndJoinInference.add(new FactorRedundantGroupAndDecorVarsRule());
    condPushDownAndJoinInference.add(new PushAggregateIntoNestedSubplanRule());
    condPushDownAndJoinInference.add(new EliminateSubplanRule());
    condPushDownAndJoinInference.add(new PushProperJoinThroughProduct());
    condPushDownAndJoinInference.add(new PushGroupByThroughProduct());
    condPushDownAndJoinInference.add(new NestGroupByRule());
    condPushDownAndJoinInference.add(new EliminateGroupByEmptyKeyRule());
    condPushDownAndJoinInference.add(new PushSubplanIntoGroupByRule());
    condPushDownAndJoinInference.add(new NestedSubplanToJoinRule());
    condPushDownAndJoinInference.add(new EliminateSubplanWithInputCardinalityOneRule());
    // The following rule should be fired after PushAggregateIntoNestedSubplanRule because
    // pulling invariants out of a subplan will make PushAggregateIntoGroupby harder.
    condPushDownAndJoinInference.add(new AsterixMoveFreeVariableOperatorOutOfSubplanRule());
    return condPushDownAndJoinInference;
}
Also used : PushMapOperatorDownThroughProductRule(org.apache.hyracks.algebricks.rewriter.rules.PushMapOperatorDownThroughProductRule) RemoveRedundantListifyRule(org.apache.asterix.optimizer.rules.RemoveRedundantListifyRule) NestedSubplanToJoinRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.NestedSubplanToJoinRule) SimpleUnnestToProductRule(org.apache.hyracks.algebricks.rewriter.rules.SimpleUnnestToProductRule) PushSubplanWithAggregateDownThroughProductRule(org.apache.hyracks.algebricks.rewriter.rules.PushSubplanWithAggregateDownThroughProductRule) PushSortDownRule(org.apache.hyracks.algebricks.rewriter.rules.PushSortDownRule) PushSelectDownRule(org.apache.hyracks.algebricks.rewriter.rules.PushSelectDownRule) EliminateSubplanWithInputCardinalityOneRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanWithInputCardinalityOneRule) PushGroupByThroughProduct(org.apache.asterix.optimizer.rules.PushGroupByThroughProduct) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) PushSubplanIntoGroupByRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.PushSubplanIntoGroupByRule) CancelUnnestWithNestedListifyRule(org.apache.asterix.optimizer.rules.CancelUnnestWithNestedListifyRule) DisjunctivePredicateToJoinRule(org.apache.asterix.optimizer.rules.DisjunctivePredicateToJoinRule) RemoveRedundantVariablesRule(org.apache.hyracks.algebricks.rewriter.rules.RemoveRedundantVariablesRule) IntroJoinInsideSubplanRule(org.apache.hyracks.algebricks.rewriter.rules.IntroJoinInsideSubplanRule) FactorRedundantGroupAndDecorVarsRule(org.apache.hyracks.algebricks.rewriter.rules.FactorRedundantGroupAndDecorVarsRule) PushProperJoinThroughProduct(org.apache.asterix.optimizer.rules.PushProperJoinThroughProduct) ComplexUnnestToProductRule(org.apache.hyracks.algebricks.rewriter.rules.ComplexUnnestToProductRule) PushSelectIntoJoinRule(org.apache.hyracks.algebricks.rewriter.rules.PushSelectIntoJoinRule) AsterixInlineVariablesRule(org.apache.asterix.optimizer.rules.AsterixInlineVariablesRule) PushAggregateIntoNestedSubplanRule(org.apache.asterix.optimizer.rules.PushAggregateIntoNestedSubplanRule) NestGroupByRule(org.apache.asterix.optimizer.rules.NestGroupByRule) LinkedList(java.util.LinkedList) EliminateSubplanRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule) AsterixExtractFunctionsFromJoinConditionRule(org.apache.asterix.optimizer.rules.AsterixExtractFunctionsFromJoinConditionRule) RemoveCartesianProductWithEmptyBranchRule(org.apache.hyracks.algebricks.rewriter.rules.RemoveCartesianProductWithEmptyBranchRule) AsterixMoveFreeVariableOperatorOutOfSubplanRule(org.apache.asterix.optimizer.rules.subplan.AsterixMoveFreeVariableOperatorOutOfSubplanRule) EliminateGroupByEmptyKeyRule(org.apache.hyracks.algebricks.rewriter.rules.EliminateGroupByEmptyKeyRule) SubplanOutOfGroupRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.SubplanOutOfGroupRule) RemoveUnusedAssignAndAggregateRule(org.apache.hyracks.algebricks.rewriter.rules.RemoveUnusedAssignAndAggregateRule)

Example 3 with IAlgebraicRewriteRule

use of org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule in project asterixdb by apache.

the class PigletRewriteRuleset method buildCondPushDownRuleCollection.

public static final List<IAlgebraicRewriteRule> buildCondPushDownRuleCollection() {
    List<IAlgebraicRewriteRule> condPushDown = new LinkedList<IAlgebraicRewriteRule>();
    condPushDown.add(new PushSelectDownRule());
    condPushDown.add(new InlineVariablesRule());
    condPushDown.add(new FactorRedundantGroupAndDecorVarsRule());
    condPushDown.add(new EliminateSubplanRule());
    return condPushDown;
}
Also used : IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) InlineVariablesRule(org.apache.hyracks.algebricks.rewriter.rules.InlineVariablesRule) FactorRedundantGroupAndDecorVarsRule(org.apache.hyracks.algebricks.rewriter.rules.FactorRedundantGroupAndDecorVarsRule) LinkedList(java.util.LinkedList) PushSelectDownRule(org.apache.hyracks.algebricks.rewriter.rules.PushSelectDownRule) EliminateSubplanRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule)

Example 4 with IAlgebraicRewriteRule

use of org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule in project asterixdb by apache.

the class PigletRewriteRuleset method buildPhysicalRewritesAllLevelsRuleCollection.

public static final List<IAlgebraicRewriteRule> buildPhysicalRewritesAllLevelsRuleCollection() {
    List<IAlgebraicRewriteRule> physicalPlanRewrites = new LinkedList<IAlgebraicRewriteRule>();
    physicalPlanRewrites.add(new PullSelectOutOfEqJoin());
    physicalPlanRewrites.add(new SetAlgebricksPhysicalOperatorsRule());
    physicalPlanRewrites.add(new EnforceStructuralPropertiesRule());
    physicalPlanRewrites.add(new PushProjectDownRule());
    physicalPlanRewrites.add(new CopyLimitDownRule());
    return physicalPlanRewrites;
}
Also used : PushProjectDownRule(org.apache.hyracks.algebricks.rewriter.rules.PushProjectDownRule) CopyLimitDownRule(org.apache.hyracks.algebricks.rewriter.rules.CopyLimitDownRule) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) EnforceStructuralPropertiesRule(org.apache.hyracks.algebricks.rewriter.rules.EnforceStructuralPropertiesRule) LinkedList(java.util.LinkedList) PullSelectOutOfEqJoin(org.apache.hyracks.algebricks.rewriter.rules.PullSelectOutOfEqJoin) SetAlgebricksPhysicalOperatorsRule(org.apache.hyracks.algebricks.rewriter.rules.SetAlgebricksPhysicalOperatorsRule)

Example 5 with IAlgebraicRewriteRule

use of org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule in project asterixdb by apache.

the class PigletRewriteRuleset method prepareForJobGenRuleCollection.

public static final List<IAlgebraicRewriteRule> prepareForJobGenRuleCollection() {
    List<IAlgebraicRewriteRule> prepareForJobGenRewrites = new LinkedList<IAlgebraicRewriteRule>();
    prepareForJobGenRewrites.add(new IsolateHyracksOperatorsRule(HeuristicOptimizer.hyraxOperatorsBelowWhichJobGenIsDisabled));
    prepareForJobGenRewrites.add(new ExtractCommonOperatorsRule());
    // Re-infer all types, so that, e.g., the effect of not-is-null is
    // propagated.
    prepareForJobGenRewrites.add(new PushProjectIntoDataSourceScanRule());
    prepareForJobGenRewrites.add(new ReinferAllTypesRule());
    return prepareForJobGenRewrites;
}
Also used : IsolateHyracksOperatorsRule(org.apache.hyracks.algebricks.rewriter.rules.IsolateHyracksOperatorsRule) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) ExtractCommonOperatorsRule(org.apache.hyracks.algebricks.rewriter.rules.ExtractCommonOperatorsRule) PushProjectIntoDataSourceScanRule(org.apache.hyracks.algebricks.rewriter.rules.PushProjectIntoDataSourceScanRule) ReinferAllTypesRule(org.apache.hyracks.algebricks.rewriter.rules.ReinferAllTypesRule) LinkedList(java.util.LinkedList)

Aggregations

IAlgebraicRewriteRule (org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule)31 LinkedList (java.util.LinkedList)25 RemoveUnusedAssignAndAggregateRule (org.apache.hyracks.algebricks.rewriter.rules.RemoveUnusedAssignAndAggregateRule)7 ArrayList (java.util.ArrayList)5 Pair (org.apache.hyracks.algebricks.common.utils.Pair)4 SequentialOnceRuleController (org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialOnceRuleController)4 PushProjectDownRule (org.apache.hyracks.algebricks.rewriter.rules.PushProjectDownRule)4 PushSelectDownRule (org.apache.hyracks.algebricks.rewriter.rules.PushSelectDownRule)4 SetExecutionModeRule (org.apache.hyracks.algebricks.rewriter.rules.SetExecutionModeRule)4 EliminateSubplanRule (org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule)4 ConstantFoldingRule (org.apache.asterix.optimizer.rules.ConstantFoldingRule)3 ConsolidateAssignsRule (org.apache.hyracks.algebricks.rewriter.rules.ConsolidateAssignsRule)3 CopyLimitDownRule (org.apache.hyracks.algebricks.rewriter.rules.CopyLimitDownRule)3 InferTypesRule (org.apache.hyracks.algebricks.rewriter.rules.InferTypesRule)3 List (java.util.List)2 AsterixInlineVariablesRule (org.apache.asterix.optimizer.rules.AsterixInlineVariablesRule)2 ByNameToByIndexFieldAccessRule (org.apache.asterix.optimizer.rules.ByNameToByIndexFieldAccessRule)2 IntroduceDynamicTypeCastForExternalFunctionRule (org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastForExternalFunctionRule)2 IntroduceDynamicTypeCastRule (org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastRule)2 RemoveRedundantListifyRule (org.apache.asterix.optimizer.rules.RemoveRedundantListifyRule)2