/** * Optimizations specific to XQuery. * * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildXQueryNormalizationRuleCollection() { List<IAlgebraicRewriteRule> normalization = new LinkedList<IAlgebraicRewriteRule>(); // Find assign for scalar aggregate function followed by an aggregate operator. normalization.add(new ConsolidateAssignAggregateRule()); normalization.add(new RemoveRedundantVariablesRule()); normalization.add(new RemoveUnusedAssignAndAggregateRule()); // Find assign for scalar aggregate function. // normalization.add(new ConvertAssignToAggregateRule()); // Use two step aggregate operators if possible. normalization.add(new IntroduceTwoStepAggregateRule()); // Used to clean up any missing noops after all the subplans have been altered. normalization.add(new RemoveRedundantVariablesRule()); normalization.add(new RemoveUnusedAssignAndAggregateRule()); return normalization; }
public static final List<IAlgebraicRewriteRule> buildFuzzyJoinRuleCollection() { List<IAlgebraicRewriteRule> fuzzy = new LinkedList<>(); fuzzy.add(new FuzzyJoinRule()); fuzzy.add(new ExtractCommonExpressionsRule()); fuzzy.add(new NestedSubplanToJoinRule()); fuzzy.add(new PushSelectIntoJoinRule()); fuzzy.add(new RemoveUnusedAssignAndAggregateRule()); fuzzy.add(new InlineSubplanInputForNestedTupleSourceRule()); fuzzy.add(new RemoveRedundantVariablesRule()); fuzzy.add(new AsterixInlineVariablesRule()); fuzzy.add(new RemoveUnusedAssignAndAggregateRule()); return fuzzy; }
/** * When a nested data sources exist, convert the plan to use the join operator. * * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildNestedDataSourceRuleCollection() { List<IAlgebraicRewriteRule> xquery = new LinkedList<IAlgebraicRewriteRule>(); xquery.add(new BreakSelectIntoConjunctsRule()); xquery.add(new SimpleUnnestToProductRule()); xquery.add(new PushMapOperatorDownThroughProductRule()); xquery.add(new PushSubplanWithAggregateDownThroughProductRule()); xquery.add(new PushSelectDownRule()); xquery.add(new PushSelectIntoJoinRule()); // Clean up xquery.add(new RemoveRedundantVariablesRule()); xquery.add(new RemoveUnusedAssignAndAggregateRule()); return xquery; }
/** * Remove expressions known to be redundant. * * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildInlineRedundantExpressionNormalizationRuleCollection() { List<IAlgebraicRewriteRule> normalization = new LinkedList<IAlgebraicRewriteRule>(); normalization.add(new InlineNestedVariablesRule()); normalization.add(new RemoveRedundantTreatExpressionsRule()); normalization.add(new RemoveRedundantDataExpressionsRule()); normalization.add(new RemoveRedundantPromoteExpressionsRule()); normalization.add(new RemoveRedundantCastExpressionsRule()); normalization.add(new ConvertToAlgebricksExpressionsRule()); normalization.add(new RemoveRedundantBooleanExpressionsRule()); // Clean up normalization.add(new RemoveRedundantVariablesRule()); normalization.add(new RemoveUnusedAssignAndAggregateRule()); return normalization; }
public static final List<IAlgebraicRewriteRule> buildLoadFieldsRuleCollection(ICcApplicationContext appCtx) { List<IAlgebraicRewriteRule> fieldLoads = new LinkedList<>(); fieldLoads.add(new LoadRecordFieldsRule()); fieldLoads.add(new PushFieldAccessRule()); // fieldLoads.add(new ByNameToByHandleFieldAccessRule()); -- disabled fieldLoads.add(new ReinferAllTypesRule()); fieldLoads.add(new ByNameToByIndexFieldAccessRule()); fieldLoads.add(new RemoveRedundantVariablesRule()); fieldLoads.add(new AsterixInlineVariablesRule()); fieldLoads.add(new RemoveUnusedAssignAndAggregateRule()); fieldLoads.add(new ConstantFoldingRule(appCtx)); fieldLoads.add(new RemoveRedundantSelectRule()); fieldLoads.add(new FeedScanCollectionToUnnest()); fieldLoads.add(new NestedSubplanToJoinRule()); fieldLoads.add(new InlineSubplanInputForNestedTupleSourceRule()); fieldLoads.add(new RemoveLeftOuterUnnestForLeftOuterJoinRule()); return fieldLoads; }
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 InjectTypeCastForFunctionArgumentsRule()); 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; }
public static final List<IAlgebraicRewriteRule> buildConsolidationRuleCollection() { List<IAlgebraicRewriteRule> consolidation = new LinkedList<>(); consolidation.add(new ConsolidateSelectsRule()); consolidation.add(new ConsolidateAssignsRule()); consolidation.add(new InlineAssignIntoAggregateRule()); consolidation.add(new AsterixIntroduceGroupByCombinerRule()); consolidation.add(new IntroduceAggregateCombinerRule()); consolidation.add(new CountVarToCountOneRule()); consolidation.add(new RemoveUnusedAssignAndAggregateRule()); consolidation.add(new RemoveRedundantGroupByDecorVarsRule()); //PushUnnestDownUnion => RemoveRedundantListifyRule cause these rules are correlated consolidation.add(new PushUnnestDownThroughUnionRule()); consolidation.add(new RemoveRedundantListifyRule()); // Window operator consolidation rules consolidation.add(new ConsolidateWindowOperatorsRule()); consolidation.add(new ReuseWindowAggregateRule()); consolidation.add(new RemoveRedundantWindowOperatorsRule()); consolidation.add(new RemoveRedundantVariablesRule()); return consolidation; }
/** * Unnest more complex structures. * * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildUnnestingRuleCollection() { List<IAlgebraicRewriteRule> xquery = new LinkedList<IAlgebraicRewriteRule>(); xquery.add(new PushSelectDownRule()); xquery.add(new SimpleUnnestToProductRule()); xquery.add(new ComplexUnnestToProductRule()); xquery.add(new ComplexJoinInferenceRule()); xquery.add(new PushSelectIntoJoinRule()); xquery.add(new IntroJoinInsideSubplanRule()); xquery.add(new PushMapOperatorDownThroughProductRule()); xquery.add(new PushSubplanWithAggregateDownThroughProductRule()); xquery.add(new IntroduceGroupByForSubplanRule()); xquery.add(new SubplanOutOfGroupRule()); xquery.add(new InsertOuterJoinRule()); xquery.add(new ExtractFunctionsFromJoinConditionRule()); xquery.add(new RemoveRedundantVariablesRule()); xquery.add(new RemoveUnusedAssignAndAggregateRule()); xquery.add(new FactorRedundantGroupAndDecorVarsRule()); xquery.add(new EliminateSubplanRule()); xquery.add(new EliminateGroupByEmptyKeyRule()); xquery.add(new PushSubplanIntoGroupByRule()); xquery.add(new NestedSubplanToJoinRule()); xquery.add(new EliminateSubplanWithInputCardinalityOneRule()); return xquery; }
normalization.add(new RemoveRedundantCastExpressionsRule()); normalization.add(new RemoveRedundantBooleanExpressionsRule()); normalization.add(new RemoveRedundantVariablesRule()); normalization.add(new RemoveUnusedAssignAndAggregateRule()); normalization.add(new RemoveRedundantVariablesRule()); normalization.add(new RemoveUnusedAssignAndAggregateRule()); normalization.add(new RemoveRedundantVariablesRule()); normalization.add(new RemoveUnusedAssignAndAggregateRule());
condPushDownAndJoinInference.add(new AsterixExtractFunctionsFromJoinConditionRule()); condPushDownAndJoinInference.add(new RemoveRedundantVariablesRule()); condPushDownAndJoinInference.add(new AsterixInlineVariablesRule()); condPushDownAndJoinInference.add(new RemoveUnusedAssignAndAggregateRule());