本文整理了Java中org.apache.calcite.rel.core.Project.copy()
方法的一些代码示例,展示了Project.copy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.copy()
方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Project
类名称:Project
方法名:copy
[英]Copies a project.
[中]复制一个项目。
代码示例来源:origin: apache/hive
public RelNode align(Project rel, List<RelFieldCollation> collations) {
// 1) We extract the collations indices
boolean containsWindowing = false;
for (RexNode childExp : rel.getChildExps()) {
if (childExp instanceof RexOver) {
// TODO: support propagation for partitioning/ordering in windowing
containsWindowing = true;
break;
}
}
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (!containsWindowing) {
for (RelFieldCollation c : collations) {
RexNode rexNode = rel.getChildExps().get(c.getFieldIndex());
if (rexNode instanceof RexInputRef) {
int newIdx = ((RexInputRef) rexNode).getIndex();
propagateCollations.add(c.copy((newIdx)));
}
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) Return new Project
return rel.copy(rel.getTraitSet(), ImmutableList.of(child));
}
代码示例来源:origin: apache/hive
@Override
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
boolean changed = false;
final RexBuilder rexBuilder = project.getCluster().getRexBuilder();
List<RexNode> newProjects = new ArrayList<>();
for (RexNode oldNode : project.getProjects()) {
RexNode newNode = analyzeRexNode(rexBuilder, oldNode);
if (!newNode.toString().equals(oldNode.toString())) {
changed = true;
newProjects.add(newNode);
} else {
newProjects.add(oldNode);
}
}
if (!changed) {
return;
}
Project newProject = project.copy(project.getTraitSet(), project.getInput(), newProjects,
project.getRowType(), project.getFlags());
call.transformTo(newProject);
}
代码示例来源:origin: apache/drill
protected void apply(RelOptRuleCall call, Project project, Filter filter, TableScan scan) {
RelOptPlanner planner = call.getPlanner();
List<RelOptMaterialization> materializations =
(planner instanceof VolcanoPlanner)
? ((VolcanoPlanner) planner).getMaterializations()
: ImmutableList.<RelOptMaterialization>of();
if (!materializations.isEmpty()) {
RelNode root = project.copy(project.getTraitSet(), Collections.singletonList(
filter.copy(filter.getTraitSet(), Collections.singletonList(
(RelNode) scan))));
// Costing is done in transformTo(), so we call it repeatedly with all applicable
// materialized views and cheapest one will be picked
List<RelOptMaterialization> applicableMaterializations =
VolcanoPlanner.getApplicableMaterializations(root, materializations);
for (RelOptMaterialization materialization : applicableMaterializations) {
List<RelNode> subs = new MaterializedViewSubstitutionVisitor(
materialization.queryRel, root, relBuilderFactory).go(materialization.tableRel);
for (RelNode s : subs) {
call.transformTo(s);
}
}
}
}
代码示例来源:origin: apache/drill
public RelNode align(Project rel, List<RelFieldCollation> collations) {
// 1) We extract the collations indices
boolean containsWindowing = false;
for (RexNode childExp : rel.getChildExps()) {
if (childExp instanceof RexOver) {
// TODO: support propagation for partitioning/ordering in windowing
containsWindowing = true;
break;
}
}
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (!containsWindowing) {
for (RelFieldCollation c : collations) {
RexNode rexNode = rel.getChildExps().get(c.getFieldIndex());
if (rexNode instanceof RexInputRef) {
int newIdx = ((RexInputRef) rexNode).getIndex();
propagateCollations.add(c.copy((newIdx)));
}
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) Return new Project
return rel.copy(rel.getTraitSet(), ImmutableList.of(child));
}
代码示例来源:origin: apache/drill
public void onMatch(RelOptRuleCall call) {
final Filter filter = call.rel(0);
final Project project = call.rel(1);
final List<RexNode> newProjects = new ArrayList<>(project.getProjects());
newProjects.add(filter.getCondition());
final RelOptCluster cluster = filter.getCluster();
RelDataType newRowType =
cluster.getTypeFactory().builder()
.addAll(project.getRowType().getFieldList())
.add("condition", Util.last(newProjects).getType())
.build();
final RelNode newProject =
project.copy(project.getTraitSet(),
project.getInput(),
newProjects,
newRowType);
final RexInputRef newCondition =
cluster.getRexBuilder().makeInputRef(newProject,
newProjects.size() - 1);
call.transformTo(filter.copy(filter.getTraitSet(), newProject, newCondition));
}
}
代码示例来源:origin: apache/hive
newCondition);
RelNode newProjRel = projectFactory == null ? project.copy(project.getTraitSet(), newFilterRel,
project.getProjects(), project.getRowType()) : projectFactory.createProject(newFilterRel,
project.getProjects(), project.getRowType().getFieldNames());
代码示例来源:origin: apache/drill
newCondition);
RelNode newProjRel = projectFactory == null ? project.copy(project.getTraitSet(), newFilterRel,
project.getProjects(), project.getRowType()) : projectFactory.createProject(newFilterRel,
project.getProjects(), project.getRowType().getFieldNames());
代码示例来源:origin: Qihoo360/Quicksql
@Deprecated // to be removed before 2.0
public Project copy(RelTraitSet traitSet, RelNode input,
List<RexNode> projects, RelDataType rowType, int flags) {
Util.discard(flags);
return copy(traitSet, input, projects, rowType);
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Override public final RelNode copy(RelTraitSet traitSet,
List<RelNode> inputs) {
return copy(traitSet, sole(inputs), exps, rowType);
}
代码示例来源:origin: Qihoo360/Quicksql
@Override public final RelNode copy(RelTraitSet traitSet,
List<RelNode> inputs) {
return copy(traitSet, sole(inputs), exps, rowType);
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Deprecated // to be removed before 2.0
public Project copy(RelTraitSet traitSet, RelNode input,
List<RexNode> projects, RelDataType rowType, int flags) {
Util.discard(flags);
return copy(traitSet, input, projects, rowType);
}
代码示例来源:origin: Qihoo360/Quicksql
public RelNode accept(RexShuttle shuttle) {
List<RexNode> exps = shuttle.apply(this.exps);
if (this.exps == exps) {
return this;
}
return copy(traitSet, getInput(), exps, rowType);
}
代码示例来源:origin: org.apache.calcite/calcite-core
public RelNode accept(RexShuttle shuttle) {
List<RexNode> exps = shuttle.apply(this.exps);
if (this.exps == exps) {
return this;
}
return copy(traitSet, getInput(), exps, rowType);
}
代码示例来源:origin: Qihoo360/Quicksql
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
final Sort sort = call.rel(1);
if (sort.getClass() != Sort.class) {
return;
}
RelNode newProject =
project.copy(
project.getTraitSet(), ImmutableList.of(sort.getInput()));
final Sort newSort =
sort.copy(
sort.getTraitSet(),
newProject,
sort.getCollation(),
sort.offset,
sort.fetch);
call.transformTo(newSort);
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
final Sort sort = call.rel(1);
if (sort.getClass() != Sort.class) {
return;
}
RelNode newProject =
project.copy(
project.getTraitSet(), ImmutableList.of(sort.getInput()));
final Sort newSort =
sort.copy(
sort.getTraitSet(),
newProject,
sort.getCollation(),
sort.offset,
sort.fetch);
call.transformTo(newSort);
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
public void onMatch(RelOptRuleCall call) {
Project project = call.rel(0);
assert isTrivial(project);
RelNode stripped = project.getInput();
if (stripped instanceof Project) {
// Rename columns of child projection if desired field names are given.
Project childProject = (Project) stripped;
stripped = childProject.copy(childProject.getTraitSet(),
childProject.getInput(), childProject.getProjects(),
project.getRowType());
}
RelNode child = call.getPlanner().register(stripped, project);
call.transformTo(child);
}
代码示例来源:origin: Qihoo360/Quicksql
public void onMatch(RelOptRuleCall call) {
Project project = call.rel(0);
assert isTrivial(project);
RelNode stripped = project.getInput();
if (stripped instanceof Project) {
// Rename columns of child projection if desired field names are given.
Project childProject = (Project) stripped;
stripped = childProject.copy(childProject.getTraitSet(),
childProject.getInput(), childProject.getProjects(),
project.getRowType());
}
RelNode child = call.getPlanner().register(stripped, project);
call.transformTo(child);
}
代码示例来源:origin: Qihoo360/Quicksql
final RelNode newProject = project.copy(project.getTraitSet(),
ImmutableList.of(Util.last(query.rels)));
RelNode newNode = DruidQuery.extendQuery(query, newProject);
final RelNode newProject = project.copy(project.getTraitSet(), input, below, builder.build());
final DruidQuery newQuery = DruidQuery.extendQuery(query, newProject);
final RelNode newProject2 = project.copy(project.getTraitSet(), newQuery, above,
project.getRowType());
call.transformTo(newProject2);
代码示例来源:origin: Qihoo360/Quicksql
public void onMatch(RelOptRuleCall call) {
Project project = call.rel(0);
DruidQuery query = call.rel(1);
final RelOptCluster cluster = project.getCluster();
final RexBuilder rexBuilder = cluster.getRexBuilder();
if (!DruidQuery.isValidSignature(query.signature() + 'o')) {
return;
}
Pair<ImmutableMap<String, String>, Boolean> scanned = scanProject(query, project);
// Only try to push down Project when there will be Post aggregators in result DruidQuery
if (scanned.right) {
Pair<Project, Project> splitProjectAggregate = splitProject(rexBuilder, query,
project, scanned.left, cluster);
Project inner = splitProjectAggregate.left;
Project outer = splitProjectAggregate.right;
DruidQuery newQuery = DruidQuery.extendQuery(query, inner);
// When all project get pushed into DruidQuery, the project can be replaced by DruidQuery.
if (outer != null) {
Project newProject = outer.copy(outer.getTraitSet(), newQuery, outer.getProjects(),
outer.getRowType());
call.transformTo(newProject);
} else {
call.transformTo(newQuery);
}
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
? project.copy(project.getTraitSet(), newFilterRel,
project.getProjects(), project.getRowType())
: relBuilder.push(newFilterRel)
内容来源于网络,如有侵权,请联系作者删除!