Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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 compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.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.shaded.org.apache.calcite.interpreter;
import com.hazelcast.shaded.org.apache.calcite.DataContext;
import com.hazelcast.shaded.org.apache.calcite.adapter.enumerable.AggImplementor;
import com.hazelcast.shaded.org.apache.calcite.adapter.enumerable.RexImpTable;
import com.hazelcast.shaded.org.apache.calcite.linq4j.Enumerable;
import com.hazelcast.shaded.org.apache.calcite.plan.Convention;
import com.hazelcast.shaded.org.apache.calcite.plan.RelOptCluster;
import com.hazelcast.shaded.org.apache.calcite.plan.RelOptCost;
import com.hazelcast.shaded.org.apache.calcite.plan.RelOptPlanner;
import com.hazelcast.shaded.org.apache.calcite.plan.RelOptRule;
import com.hazelcast.shaded.org.apache.calcite.plan.RelOptRuleCall;
import com.hazelcast.shaded.org.apache.calcite.plan.RelOptTable;
import com.hazelcast.shaded.org.apache.calcite.plan.RelRule;
import com.hazelcast.shaded.org.apache.calcite.plan.RelTraitSet;
import com.hazelcast.shaded.org.apache.calcite.rel.InvalidRelException;
import com.hazelcast.shaded.org.apache.calcite.rel.RelCollation;
import com.hazelcast.shaded.org.apache.calcite.rel.RelCollationTraitDef;
import com.hazelcast.shaded.org.apache.calcite.rel.RelNode;
import com.hazelcast.shaded.org.apache.calcite.rel.RelWriter;
import com.hazelcast.shaded.org.apache.calcite.rel.convert.ConverterRule;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Aggregate;
import com.hazelcast.shaded.org.apache.calcite.rel.core.AggregateCall;
import com.hazelcast.shaded.org.apache.calcite.rel.core.CorrelationId;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Filter;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Intersect;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Join;
import com.hazelcast.shaded.org.apache.calcite.rel.core.JoinRelType;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Match;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Minus;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Project;
import com.hazelcast.shaded.org.apache.calcite.rel.core.SetOp;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Sort;
import com.hazelcast.shaded.org.apache.calcite.rel.core.TableScan;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Union;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Values;
import com.hazelcast.shaded.org.apache.calcite.rel.core.Window;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalAggregate;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalFilter;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalIntersect;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalJoin;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalMatch;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalProject;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalTableScan;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalUnion;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalValues;
import com.hazelcast.shaded.org.apache.calcite.rel.logical.LogicalWindow;
import com.hazelcast.shaded.org.apache.calcite.rel.metadata.RelMdCollation;
import com.hazelcast.shaded.org.apache.calcite.rel.metadata.RelMetadataQuery;
import com.hazelcast.shaded.org.apache.calcite.rel.type.RelDataType;
import com.hazelcast.shaded.org.apache.calcite.rel.type.RelDataTypeFactory;
import com.hazelcast.shaded.org.apache.calcite.rel.type.RelDataTypeField;
import com.hazelcast.shaded.org.apache.calcite.rex.RexLiteral;
import com.hazelcast.shaded.org.apache.calcite.rex.RexNode;
import com.hazelcast.shaded.org.apache.calcite.schema.FilterableTable;
import com.hazelcast.shaded.org.apache.calcite.schema.ProjectableFilterableTable;
import com.hazelcast.shaded.org.apache.calcite.schema.ScannableTable;
import com.hazelcast.shaded.org.apache.calcite.schema.Table;
import com.hazelcast.shaded.org.apache.calcite.tools.RelBuilderFactory;
import com.hazelcast.shaded.org.apache.calcite.util.ImmutableBitSet;
import com.hazelcast.shaded.org.apache.calcite.util.ImmutableIntList;
import com.hazelcast.shaded.com.google.common.base.Preconditions;
import com.hazelcast.shaded.com.google.common.collect.ImmutableList;
import com.hazelcast.shaded.com.google.common.collect.ImmutableSet;
import com.hazelcast.shaded.org.checkerframework.checker.nullness.qual.Nullable;
import org.immutables.value.Value;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
/**
* Utilities pertaining to {@link BindableRel} and {@link BindableConvention}.
*/
@Value.Enclosing
public class Bindables {
private Bindables() {}
public static final RelOptRule BINDABLE_TABLE_SCAN_RULE =
BindableTableScanRule.Config.DEFAULT.toRule();
public static final RelOptRule BINDABLE_FILTER_RULE =
BindableFilterRule.DEFAULT_CONFIG.toRule(BindableFilterRule.class);
public static final RelOptRule BINDABLE_PROJECT_RULE =
BindableProjectRule.DEFAULT_CONFIG.toRule(BindableProjectRule.class);
public static final RelOptRule BINDABLE_SORT_RULE =
BindableSortRule.DEFAULT_CONFIG.toRule(BindableSortRule.class);
public static final RelOptRule BINDABLE_JOIN_RULE =
BindableJoinRule.DEFAULT_CONFIG.toRule(BindableJoinRule.class);
public static final RelOptRule BINDABLE_SET_OP_RULE =
BindableSetOpRule.DEFAULT_CONFIG.toRule(BindableSetOpRule.class);
// CHECKSTYLE: IGNORE 1
/** @deprecated Use {@link #BINDABLE_SET_OP_RULE}. */
@SuppressWarnings("MissingSummary")
public static final RelOptRule BINDABLE_SETOP_RULE =
BINDABLE_SET_OP_RULE;
public static final RelOptRule BINDABLE_VALUES_RULE =
BindableValuesRule.DEFAULT_CONFIG.toRule(BindableValuesRule.class);
public static final RelOptRule BINDABLE_AGGREGATE_RULE =
BindableAggregateRule.DEFAULT_CONFIG.toRule(BindableAggregateRule.class);
public static final RelOptRule BINDABLE_WINDOW_RULE =
BindableWindowRule.DEFAULT_CONFIG.toRule(BindableWindowRule.class);
public static final RelOptRule BINDABLE_MATCH_RULE =
BindableMatchRule.DEFAULT_CONFIG.toRule(BindableMatchRule.class);
/** Rule that converts a relational expression from
* {@link com.hazelcast.shaded.org.apache.calcite.plan.Convention#NONE}
* to {@link com.hazelcast.shaded.org.apache.calcite.interpreter.BindableConvention}. */
public static final NoneToBindableConverterRule FROM_NONE_RULE =
NoneToBindableConverterRule.DEFAULT_CONFIG
.toRule(NoneToBindableConverterRule.class);
/** All rules that convert logical relational expression to bindable. */
public static final ImmutableList RULES =
ImmutableList.of(FROM_NONE_RULE,
BINDABLE_TABLE_SCAN_RULE,
BINDABLE_FILTER_RULE,
BINDABLE_PROJECT_RULE,
BINDABLE_SORT_RULE,
BINDABLE_JOIN_RULE,
BINDABLE_SET_OP_RULE,
BINDABLE_VALUES_RULE,
BINDABLE_AGGREGATE_RULE,
BINDABLE_WINDOW_RULE,
BINDABLE_MATCH_RULE);
/** Helper method that converts a bindable relational expression into a
* record iterator.
*
*
Any bindable can be compiled; if its input is also bindable, it becomes
* part of the same compilation unit.
*/
private static Enumerable<@Nullable Object[]> help(DataContext dataContext,
BindableRel rel) {
return new Interpreter(dataContext, rel);
}
/** Rule that converts a {@link com.hazelcast.shaded.org.apache.calcite.rel.core.TableScan}
* to bindable convention.
*
* @see #BINDABLE_TABLE_SCAN_RULE */
public static class BindableTableScanRule
extends RelRule {
/** Called from Config. */
protected BindableTableScanRule(Config config) {
super(config);
}
@Deprecated // to be removed before 2.0
public BindableTableScanRule(RelBuilderFactory relBuilderFactory) {
this(Config.DEFAULT.withRelBuilderFactory(relBuilderFactory)
.as(Config.class));
}
@Override public void onMatch(RelOptRuleCall call) {
final LogicalTableScan scan = call.rel(0);
final RelOptTable table = scan.getTable();
if (BindableTableScan.canHandle(table)) {
call.transformTo(
BindableTableScan.create(scan.getCluster(), table));
}
}
/** Rule configuration. */
@Value.Immutable
public interface Config extends RelRule.Config {
Config DEFAULT = ImmutableBindables.Config.of()
.withOperandSupplier(b ->
b.operand(LogicalTableScan.class).noInputs());
@Override default BindableTableScanRule toRule() {
return new BindableTableScanRule(this);
}
}
}
/** Scan of a table that implements {@link ScannableTable} and therefore can
* be converted into an {@link Enumerable}. */
public static class BindableTableScan
extends TableScan implements BindableRel {
public final ImmutableList filters;
public final ImmutableIntList projects;
/** Creates a BindableTableScan.
*
*
Use {@link #create} unless you know what you are doing. */
BindableTableScan(RelOptCluster cluster, RelTraitSet traitSet,
RelOptTable table, ImmutableList filters,
ImmutableIntList projects) {
super(cluster, traitSet, ImmutableList.of(), table);
this.filters = Objects.requireNonNull(filters, "filters");
this.projects = Objects.requireNonNull(projects, "projects");
Preconditions.checkArgument(canHandle(table));
}
/** Creates a BindableTableScan. */
public static BindableTableScan create(RelOptCluster cluster,
RelOptTable relOptTable) {
return create(cluster, relOptTable, ImmutableList.of(),
identity(relOptTable));
}
/** Creates a BindableTableScan. */
public static BindableTableScan create(RelOptCluster cluster,
RelOptTable relOptTable, List filters,
List projects) {
final Table table = relOptTable.unwrap(Table.class);
final RelTraitSet traitSet =
cluster.traitSetOf(BindableConvention.INSTANCE)
.replaceIfs(RelCollationTraitDef.INSTANCE, () -> {
if (table != null) {
return table.getStatistic().getCollations();
}
return ImmutableList.of();
});
return new BindableTableScan(cluster, traitSet, relOptTable,
ImmutableList.copyOf(filters), ImmutableIntList.copyOf(projects));
}
@Override public RelDataType deriveRowType() {
final RelDataTypeFactory.Builder builder =
getCluster().getTypeFactory().builder();
final List fieldList =
table.getRowType().getFieldList();
for (int project : projects) {
builder.add(fieldList.get(project));
}
return builder.build();
}
@Override public Class