Search in sources :

Example 21 with IAlgebraicRewriteRule

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

the class DefaultRuleSetFactory method buildLogical.

public static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> buildLogical(ICcApplicationContext appCtx) {
    List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> defaultLogicalRewrites = new ArrayList<>();
    SequentialFixpointRuleController seqCtrlNoDfs = new SequentialFixpointRuleController(false);
    SequentialFixpointRuleController seqCtrlFullDfs = new SequentialFixpointRuleController(true);
    SequentialOnceRuleController seqOnceCtrl = new SequentialOnceRuleController(true);
    defaultLogicalRewrites.add(new Pair<>(seqOnceCtrl, RuleCollections.buildInitialTranslationRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqOnceCtrl, RuleCollections.buildTypeInferenceRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqOnceCtrl, RuleCollections.buildAutogenerateIDRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlFullDfs, RuleCollections.buildNormalizationRuleCollection(appCtx)));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlNoDfs, RuleCollections.buildCondPushDownAndJoinInferenceRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlFullDfs, RuleCollections.buildLoadFieldsRuleCollection(appCtx)));
    // fj
    defaultLogicalRewrites.add(new Pair<>(seqCtrlFullDfs, RuleCollections.buildFuzzyJoinRuleCollection()));
    //
    defaultLogicalRewrites.add(new Pair<>(seqCtrlFullDfs, RuleCollections.buildNormalizationRuleCollection(appCtx)));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlNoDfs, RuleCollections.buildCondPushDownAndJoinInferenceRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlFullDfs, RuleCollections.buildLoadFieldsRuleCollection(appCtx)));
    defaultLogicalRewrites.add(new Pair<>(seqOnceCtrl, RuleCollections.buildDataExchangeRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlNoDfs, RuleCollections.buildConsolidationRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqOnceCtrl, RuleCollections.buildFulltextContainsRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlNoDfs, RuleCollections.buildAccessMethodRuleCollection()));
    defaultLogicalRewrites.add(new Pair<>(seqCtrlNoDfs, RuleCollections.buildPlanCleanupRuleCollection()));
    //put TXnRuleCollection!
    return defaultLogicalRewrites;
}
Also used : SequentialOnceRuleController(org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialOnceRuleController) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) SequentialFixpointRuleController(org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialFixpointRuleController) ArrayList(java.util.ArrayList) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 22 with IAlgebraicRewriteRule

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

the class RuleCollections method buildAutogenerateIDRuleCollection.

public static final List<IAlgebraicRewriteRule> buildAutogenerateIDRuleCollection() {
    List<IAlgebraicRewriteRule> autogen = new LinkedList<>();
    autogen.add(new IntroduceAutogenerateIDRule());
    return autogen;
}
Also used : IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) LinkedList(java.util.LinkedList) IntroduceAutogenerateIDRule(org.apache.asterix.optimizer.rules.IntroduceAutogenerateIDRule)

Example 23 with IAlgebraicRewriteRule

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

the class RuleCollections method buildAccessMethodRuleCollection.

public static final List<IAlgebraicRewriteRule> buildAccessMethodRuleCollection() {
    List<IAlgebraicRewriteRule> accessMethod = new LinkedList<>();
    accessMethod.add(new IntroduceSelectAccessMethodRule());
    accessMethod.add(new IntroduceJoinAccessMethodRule());
    accessMethod.add(new IntroduceLSMComponentFilterRule());
    accessMethod.add(new IntroduceSecondaryIndexInsertDeleteRule());
    accessMethod.add(new RemoveUnusedOneToOneEquiJoinRule());
    accessMethod.add(new PushSimilarityFunctionsBelowJoin());
    accessMethod.add(new RemoveUnusedAssignAndAggregateRule());
    return accessMethod;
}
Also used : PushSimilarityFunctionsBelowJoin(org.apache.asterix.optimizer.rules.PushSimilarityFunctionsBelowJoin) IntroduceSelectAccessMethodRule(org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) IntroduceJoinAccessMethodRule(org.apache.asterix.optimizer.rules.am.IntroduceJoinAccessMethodRule) RemoveUnusedOneToOneEquiJoinRule(org.apache.asterix.optimizer.rules.RemoveUnusedOneToOneEquiJoinRule) IntroduceSecondaryIndexInsertDeleteRule(org.apache.asterix.optimizer.rules.IntroduceSecondaryIndexInsertDeleteRule) RemoveUnusedAssignAndAggregateRule(org.apache.hyracks.algebricks.rewriter.rules.RemoveUnusedAssignAndAggregateRule) IntroduceLSMComponentFilterRule(org.apache.asterix.optimizer.rules.am.IntroduceLSMComponentFilterRule) LinkedList(java.util.LinkedList)

Example 24 with IAlgebraicRewriteRule

use of org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule 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 25 with IAlgebraicRewriteRule

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

the class RuleCollections method buildTypeInferenceRuleCollection.

public static final List<IAlgebraicRewriteRule> buildTypeInferenceRuleCollection() {
    List<IAlgebraicRewriteRule> typeInfer = new LinkedList<>();
    typeInfer.add(new InlineUnnestFunctionRule());
    typeInfer.add(new InferTypesRule());
    typeInfer.add(new CheckFilterExpressionTypeRule());
    return typeInfer;
}
Also used : InlineUnnestFunctionRule(org.apache.asterix.optimizer.rules.InlineUnnestFunctionRule) InferTypesRule(org.apache.hyracks.algebricks.rewriter.rules.InferTypesRule) IAlgebraicRewriteRule(org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule) CheckFilterExpressionTypeRule(org.apache.asterix.optimizer.rules.CheckFilterExpressionTypeRule) 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