Search in sources :

Example 1 with EliminateSubplanRule

use of org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule 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 2 with EliminateSubplanRule

use of org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule 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 3 with EliminateSubplanRule

use of org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule 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)

Example 4 with EliminateSubplanRule

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

the class PigletRewriteRuleset method buildNormalizationRuleCollection.

public static final List<IAlgebraicRewriteRule> buildNormalizationRuleCollection() {
    List<IAlgebraicRewriteRule> normalization = new LinkedList<IAlgebraicRewriteRule>();
    normalization.add(new EliminateSubplanRule());
    // TODO: This rule is incorrect and has been removed. Its replacement in
    // Asterix (PushAggFuncIntoStandaloneAggregateRule)
    // is language-specific.
    // normalization.add(new IntroduceGroupByForStandaloneAggregRule());
    normalization.add(new BreakSelectIntoConjunctsRule());
    normalization.add(new PushSelectIntoJoinRule());
    normalization.add(new ExtractGbyExpressionsRule());
    return normalization;
}
Also used : IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) BreakSelectIntoConjunctsRule(org.apache.hyracks.algebricks.rewriter.rules.BreakSelectIntoConjunctsRule) PushSelectIntoJoinRule(org.apache.hyracks.algebricks.rewriter.rules.PushSelectIntoJoinRule) ExtractGbyExpressionsRule(org.apache.hyracks.algebricks.rewriter.rules.ExtractGbyExpressionsRule) LinkedList(java.util.LinkedList) EliminateSubplanRule(org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule)

Aggregations

LinkedList (java.util.LinkedList)4 IAlgebraicRewriteRule (org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule)4 EliminateSubplanRule (org.apache.hyracks.algebricks.rewriter.rules.subplan.EliminateSubplanRule)4 BreakSelectIntoConjunctsRule (org.apache.hyracks.algebricks.rewriter.rules.BreakSelectIntoConjunctsRule)2 ExtractGbyExpressionsRule (org.apache.hyracks.algebricks.rewriter.rules.ExtractGbyExpressionsRule)2 FactorRedundantGroupAndDecorVarsRule (org.apache.hyracks.algebricks.rewriter.rules.FactorRedundantGroupAndDecorVarsRule)2 PushSelectDownRule (org.apache.hyracks.algebricks.rewriter.rules.PushSelectDownRule)2 PushSelectIntoJoinRule (org.apache.hyracks.algebricks.rewriter.rules.PushSelectIntoJoinRule)2 AsterixExtractFunctionsFromJoinConditionRule (org.apache.asterix.optimizer.rules.AsterixExtractFunctionsFromJoinConditionRule)1 AsterixInlineVariablesRule (org.apache.asterix.optimizer.rules.AsterixInlineVariablesRule)1 CancelUnnestWithNestedListifyRule (org.apache.asterix.optimizer.rules.CancelUnnestWithNestedListifyRule)1 CheckInsertUpsertReturningRule (org.apache.asterix.optimizer.rules.CheckInsertUpsertReturningRule)1 ConstantFoldingRule (org.apache.asterix.optimizer.rules.ConstantFoldingRule)1 DisjunctivePredicateToJoinRule (org.apache.asterix.optimizer.rules.DisjunctivePredicateToJoinRule)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 IntroduceDynamicTypeCastForExternalFunctionRule (org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastForExternalFunctionRule)1 IntroduceDynamicTypeCastRule (org.apache.asterix.optimizer.rules.IntroduceDynamicTypeCastRule)1 IntroduceEnforcedListTypeRule (org.apache.asterix.optimizer.rules.IntroduceEnforcedListTypeRule)1