All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.org.apache.calcite.plan.RelOptRules Maven / Gradle / Ivy

There is a newer version: 5.4.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to you under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in com.hazelcast.com.liance with
 * the License.  You may obtain a copy of the License at
 *
 * http://www.apache.com.hazelcast.org.licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hazelcast.org.apache.calcite.plan;

import com.hazelcast.org.apache.calcite.adapter.enumerable.EnumerableRules;
import com.hazelcast.org.apache.calcite.config.CalciteSystemProperty;
import com.hazelcast.org.apache.calcite.interpreter.NoneToBindableConverterRule;
import com.hazelcast.org.apache.calcite.linq4j.function.Experimental;
import com.hazelcast.org.apache.calcite.plan.volcano.AbstractConverter;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateCaseToFilterRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateExpandDistinctAggregatesRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateJoinTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateProjectMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateProjectPullUpConstantsRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateReduceFunctionsRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateRemoveRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateStarTableRule;
import com.hazelcast.org.apache.calcite.rel.rules.AggregateValuesRule;
import com.hazelcast.org.apache.calcite.rel.rules.CalcMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.CalcRemoveRule;
import com.hazelcast.org.apache.calcite.rel.rules.DateRangeRules;
import com.hazelcast.org.apache.calcite.rel.rules.ExchangeRemoveConstantKeysRule;
import com.hazelcast.org.apache.calcite.rel.rules.FilterAggregateTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.FilterCalcMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.FilterJoinRule;
import com.hazelcast.org.apache.calcite.rel.rules.FilterMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.FilterProjectTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.FilterTableScanRule;
import com.hazelcast.org.apache.calcite.rel.rules.FilterToCalcRule;
import com.hazelcast.org.apache.calcite.rel.rules.IntersectToDistinctRule;
import com.hazelcast.org.apache.calcite.rel.rules.JoinAssociateRule;
import com.hazelcast.org.apache.calcite.rel.rules.JoinCommuteRule;
import com.hazelcast.org.apache.calcite.rel.rules.JoinPushExpressionsRule;
import com.hazelcast.org.apache.calcite.rel.rules.JoinPushThroughJoinRule;
import com.hazelcast.org.apache.calcite.rel.rules.MatchRule;
import com.hazelcast.org.apache.calcite.rel.rules.MaterializedViewFilterScanRule;
import com.hazelcast.org.apache.calcite.rel.rules.ProjectCalcMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.ProjectFilterTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.ProjectMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.ProjectRemoveRule;
import com.hazelcast.org.apache.calcite.rel.rules.ProjectToCalcRule;
import com.hazelcast.org.apache.calcite.rel.rules.ProjectToWindowRule;
import com.hazelcast.org.apache.calcite.rel.rules.ProjectWindowTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.PruneEmptyRules;
import com.hazelcast.org.apache.calcite.rel.rules.ReduceExpressionsRule;
import com.hazelcast.org.apache.calcite.rel.rules.SemiJoinRule;
import com.hazelcast.org.apache.calcite.rel.rules.SortJoinTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.SortProjectTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.SortRemoveConstantKeysRule;
import com.hazelcast.org.apache.calcite.rel.rules.SortRemoveRule;
import com.hazelcast.org.apache.calcite.rel.rules.SortUnionTransposeRule;
import com.hazelcast.org.apache.calcite.rel.rules.UnionMergeRule;
import com.hazelcast.org.apache.calcite.rel.rules.UnionPullUpConstantsRule;
import com.hazelcast.org.apache.calcite.rel.rules.UnionToDistinctRule;
import com.hazelcast.org.apache.calcite.rel.rules.ValuesReduceRule;
import com.hazelcast.org.apache.calcite.rel.rules.materialize.MaterializedViewOnlyAggregateRule;
import com.hazelcast.org.apache.calcite.rel.rules.materialize.MaterializedViewOnlyFilterRule;
import com.hazelcast.org.apache.calcite.rel.rules.materialize.MaterializedViewOnlyJoinRule;
import com.hazelcast.org.apache.calcite.rel.rules.materialize.MaterializedViewProjectAggregateRule;
import com.hazelcast.org.apache.calcite.rel.rules.materialize.MaterializedViewProjectFilterRule;
import com.hazelcast.org.apache.calcite.rel.rules.materialize.MaterializedViewProjectJoinRule;

import com.hazelcast.com.google.com.hazelcast.com.on.collect.ImmutableList;

import java.util.List;

/**
 * A utility class for com.hazelcast.org.nizing built-in rules and rule related
 * methods. Currently some rule sets are package private for serving core Calcite.
 *
 * @see RelOptRule
 * @see RelOptUtil
 */
@Experimental
public class RelOptRules {

  private RelOptRules() {
  }

  /**
   * The calc rule set is public for use from {@link com.hazelcast.org.apache.calcite.tools.Programs}
   */
  public static final ImmutableList CALC_RULES =
      ImmutableList.of(
          NoneToBindableConverterRule.INSTANCE,
          EnumerableRules.ENUMERABLE_CALC_RULE,
          EnumerableRules.ENUMERABLE_FILTER_TO_CALC_RULE,
          EnumerableRules.ENUMERABLE_PROJECT_TO_CALC_RULE,
          CalcMergeRule.INSTANCE,
          FilterCalcMergeRule.INSTANCE,
          ProjectCalcMergeRule.INSTANCE,
          FilterToCalcRule.INSTANCE,
          ProjectToCalcRule.INSTANCE,
          CalcMergeRule.INSTANCE,

          // REVIEW jvs 9-Apr-2006: Do we still need these two?  Doesn't the
          // com.hazelcast.com.ination of CalcMergeRule, FilterToCalcRule, and
          // ProjectToCalcRule have the same effect?
          FilterCalcMergeRule.INSTANCE,
          ProjectCalcMergeRule.INSTANCE);

  static final List BASE_RULES = ImmutableList.of(
      AggregateStarTableRule.INSTANCE,
      AggregateStarTableRule.INSTANCE2,
      CalciteSystemProperty.COMMUTE.value()
          ? JoinAssociateRule.INSTANCE
          : ProjectMergeRule.INSTANCE,
      FilterTableScanRule.INSTANCE,
      ProjectFilterTransposeRule.INSTANCE,
      FilterProjectTransposeRule.INSTANCE,
      FilterJoinRule.FILTER_ON_JOIN,
      JoinPushExpressionsRule.INSTANCE,
      AggregateExpandDistinctAggregatesRule.INSTANCE,
      AggregateCaseToFilterRule.INSTANCE,
      AggregateReduceFunctionsRule.INSTANCE,
      FilterAggregateTransposeRule.INSTANCE,
      ProjectWindowTransposeRule.INSTANCE,
      MatchRule.INSTANCE,
      JoinCommuteRule.INSTANCE,
      JoinPushThroughJoinRule.RIGHT,
      JoinPushThroughJoinRule.LEFT,
      SortProjectTransposeRule.INSTANCE,
      SortJoinTransposeRule.INSTANCE,
      SortRemoveConstantKeysRule.INSTANCE,
      SortUnionTransposeRule.INSTANCE,
      ExchangeRemoveConstantKeysRule.EXCHANGE_INSTANCE,
      ExchangeRemoveConstantKeysRule.SORT_EXCHANGE_INSTANCE);

  static final List ABSTRACT_RULES = ImmutableList.of(
      AggregateProjectPullUpConstantsRule.INSTANCE2,
      UnionPullUpConstantsRule.INSTANCE,
      PruneEmptyRules.UNION_INSTANCE,
      PruneEmptyRules.INTERSECT_INSTANCE,
      PruneEmptyRules.MINUS_INSTANCE,
      PruneEmptyRules.PROJECT_INSTANCE,
      PruneEmptyRules.FILTER_INSTANCE,
      PruneEmptyRules.SORT_INSTANCE,
      PruneEmptyRules.AGGREGATE_INSTANCE,
      PruneEmptyRules.JOIN_LEFT_INSTANCE,
      PruneEmptyRules.JOIN_RIGHT_INSTANCE,
      PruneEmptyRules.SORT_FETCH_ZERO_INSTANCE,
      UnionMergeRule.INSTANCE,
      UnionMergeRule.INTERSECT_INSTANCE,
      UnionMergeRule.MINUS_INSTANCE,
      ProjectToWindowRule.PROJECT,
      FilterMergeRule.INSTANCE,
      DateRangeRules.FILTER_INSTANCE,
      IntersectToDistinctRule.INSTANCE);

  static final List ABSTRACT_RELATIONAL_RULES = ImmutableList.of(
      FilterJoinRule.FILTER_ON_JOIN,
      FilterJoinRule.JOIN,
      AbstractConverter.ExpandConversionRule.INSTANCE,
      JoinCommuteRule.INSTANCE,
      SemiJoinRule.PROJECT,
      SemiJoinRule.JOIN,
      AggregateRemoveRule.INSTANCE,
      UnionToDistinctRule.INSTANCE,
      ProjectRemoveRule.INSTANCE,
      AggregateJoinTransposeRule.INSTANCE,
      AggregateMergeRule.INSTANCE,
      AggregateProjectMergeRule.INSTANCE,
      CalcRemoveRule.INSTANCE,
      SortRemoveRule.INSTANCE);

  static final List CONSTANT_REDUCTION_RULES = ImmutableList.of(
      ReduceExpressionsRule.PROJECT_INSTANCE,
      ReduceExpressionsRule.FILTER_INSTANCE,
      ReduceExpressionsRule.CALC_INSTANCE,
      ReduceExpressionsRule.WINDOW_INSTANCE,
      ReduceExpressionsRule.JOIN_INSTANCE,
      ValuesReduceRule.FILTER_INSTANCE,
      ValuesReduceRule.PROJECT_FILTER_INSTANCE,
      ValuesReduceRule.PROJECT_INSTANCE,
      AggregateValuesRule.INSTANCE);

  public static final List MATERIALIZATION_RULES = ImmutableList.of(
      MaterializedViewFilterScanRule.INSTANCE,
      MaterializedViewProjectFilterRule.INSTANCE,
      MaterializedViewOnlyFilterRule.INSTANCE,
      MaterializedViewProjectJoinRule.INSTANCE,
      MaterializedViewOnlyJoinRule.INSTANCE,
      MaterializedViewProjectAggregateRule.INSTANCE,
      MaterializedViewOnlyAggregateRule.INSTANCE);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy