本文整理了Java中org.apache.calcite.rel.core.Project.getProjects()
方法的一些代码示例,展示了Project.getProjects()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getProjects()
方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Project
类名称:Project
方法名:getProjects
[英]Returns the project expressions.
[中]返回项目表达式。
代码示例来源:origin: apache/hive
/** Returns a literal output field, or null if it is not literal. */
private static RexLiteral projectedLiteral(RelNode rel, int i) {
if (rel instanceof Project) {
final Project project = (Project) rel;
final RexNode node = project.getProjects().get(i);
if (node instanceof RexLiteral) {
return (RexLiteral) node;
}
}
return null;
}
代码示例来源:origin: apache/drill
/** Returns a literal output field, or null if it is not literal. */
private static RexLiteral projectedLiteral(RelNode rel, int i) {
if (rel instanceof Project) {
final Project project = (Project) rel;
final RexNode node = project.getProjects().get(i);
if (node instanceof RexLiteral) {
return (RexLiteral) node;
}
}
return null;
}
代码示例来源:origin: apache/drill
private boolean isSimple(Project project) {
RexNode r = project.getProjects().get(joinKey);
if (r instanceof RexInputRef) {
joinKey = ((RexInputRef) r).getIndex();
return true;
}
return false;
}
代码示例来源:origin: apache/hive
private static boolean isTrivial(Project project, Intersect intersect) {
return RexUtil.isIdentity(project.getProjects(), intersect.getRowType());
}
代码示例来源:origin: apache/drill
private static boolean isTrivial(Project project, Intersect intersect) {
return RexUtil.isIdentity(project.getProjects(), intersect.getRowType());
}
代码示例来源:origin: apache/hive
private boolean isSimple(Project project) {
ImmutableBitSet.Builder b = ImmutableBitSet.builder();
for (int pos : joinKey) {
RexNode r = project.getProjects().get(pos);
if (!(r instanceof RexInputRef)) {
return false;
}
b.set(((RexInputRef) r).getIndex());
}
joinKey = b.build();
return true;
}
代码示例来源:origin: apache/hive
public boolean apply(RelNode relNode) {
if (relNode instanceof Project) {
Project project = (Project)relNode;
for (RexNode node : project.getProjects()) {
try {
node.accept(INSTANCE);
} catch (Util.FoundOne e) {
return true;
}
}
return false;
} else if (relNode instanceof Filter) {
try {
((Filter)relNode).getCondition().accept(INSTANCE);
return false;
} catch (Util.FoundOne e) {
return true;
}
}
return false;
}
};
代码示例来源:origin: apache/hive
/**
* Variant of {@link #trimFields(RelNode, ImmutableBitSet, Set)} for
* {@link org.apache.calcite.rel.logical.LogicalProject}.
*/
public TrimResult trimFields(Project project, ImmutableBitSet fieldsUsed,
Set<RelDataTypeField> extraFields) {
// set columnAccessInfo for ViewColumnAuthorization
for (Ord<RexNode> ord : Ord.zip(project.getProjects())) {
if (fieldsUsed.get(ord.i)) {
if (this.columnAccessInfo != null && this.viewProjectToTableSchema != null
&& this.viewProjectToTableSchema.containsKey(project)) {
Table tab = this.viewProjectToTableSchema.get(project);
this.columnAccessInfo.add(tab.getCompleteName(), tab.getAllCols().get(ord.i).getName());
}
}
}
return super.trimFields(project, fieldsUsed, extraFields);
}
代码示例来源:origin: apache/drill
/**
* Variant of {@link #trimFields(RelNode, ImmutableBitSet, Set)} for
* {@link org.apache.calcite.rel.logical.LogicalProject}.
*/
public TrimResult trimFields(Project project, ImmutableBitSet fieldsUsed,
Set<RelDataTypeField> extraFields) {
// set columnAccessInfo for ViewColumnAuthorization
for (Ord<RexNode> ord : Ord.zip(project.getProjects())) {
if (fieldsUsed.get(ord.i)) {
if (this.columnAccessInfo != null && this.viewProjectToTableSchema != null
&& this.viewProjectToTableSchema.containsKey(project)) {
Table tab = this.viewProjectToTableSchema.get(project);
this.columnAccessInfo.add(tab.getCompleteName(), tab.getCols().get(ord.i).getName());
}
}
}
return super.trimFields(project, fieldsUsed, extraFields);
}
代码示例来源: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/storm
@Override
public RelNode convert(RelNode rel) {
final Project project = (Project) rel;
final RelNode input = project.getInput();
return new StreamsProjectRel(project.getCluster(),
project.getTraitSet().replace(StreamsLogicalConvention.INSTANCE),
convert(input, input.getTraitSet().replace(StreamsLogicalConvention.INSTANCE)), project.getProjects(),
project.getRowType());
}
}
代码示例来源:origin: apache/hive
List<RexNode> projExprs = project.getProjects();
if (projExprs.size() != 1) {
return;
代码示例来源:origin: apache/drill
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
//TODO: replace HiveSubQRemoveRelBuilder with calcite's once calcite 1.11.0 is released
final HiveSubQRemoveRelBuilder builder = new HiveSubQRemoveRelBuilder(null, call.rel(0).getCluster(), null);
final RexSubQuery e =
RexUtil.SubQueryFinder.find(project.getProjects());
assert e != null;
final RelOptUtil.Logic logic =
LogicVisitor.find(RelOptUtil.Logic.TRUE_FALSE_UNKNOWN,
project.getProjects(), e);
builder.push(project.getInput());
final int fieldCount = builder.peek().getRowType().getFieldCount();
final RexNode target = apply(e, HiveFilter.getVariablesSet(e),
logic, builder, 1, fieldCount, false);
final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
builder.project(shuttle.apply(project.getProjects()),
project.getRowType().getFieldNames());
call.transformTo(builder.build());
}
};
代码示例来源:origin: apache/hive
final Project project = call.rel(1);
if (RexOver.containsOver(project.getProjects(), null)) {
project.getProjects(), project.getRowType()) : projectFactory.createProject(newFilterRel,
project.getProjects(), project.getRowType().getFieldNames());
代码示例来源:origin: apache/incubator-druid
} else {
final List<RexNode> newProjectRexNodes = RelOptUtil.pushPastProject(
newSelectProject.getProjects(),
selectProject
);
代码示例来源:origin: apache/hive
private static RelNode getNewProject(RexNode filterCondToPushBelowProj, RexNode unPushedFilCondAboveProj, Project oldProj,
RelDataTypeFactory typeFactory, RelBuilder relBuilder) {
// convert the filter to one that references the child of the project
RexNode newPushedCondition = RelOptUtil.pushPastProject(filterCondToPushBelowProj, oldProj);
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
newPushedCondition = ((RexCall) newPushedCondition).getOperands().get(0);
}
RelNode newPushedFilterRel = relBuilder.push(oldProj.getInput()).filter(newPushedCondition).build();
RelNode newProjRel = relBuilder.push(newPushedFilterRel)
.project(oldProj.getProjects(), oldProj.getRowType().getFieldNames()).build();
if (unPushedFilCondAboveProj != null) {
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
unPushedFilCondAboveProj = ((RexCall) unPushedFilCondAboveProj).getOperands().get(0);
}
newProjRel = relBuilder.push(newProjRel).filter(unPushedFilCondAboveProj).build();
}
return newProjRel;
}
代码示例来源: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/drill
private static RelNode getNewProject(RexNode filterCondToPushBelowProj, RexNode unPushedFilCondAboveProj, Project oldProj,
RelDataTypeFactory typeFactory, RelBuilder relBuilder) {
// convert the filter to one that references the child of the project
RexNode newPushedCondition = RelOptUtil.pushPastProject(filterCondToPushBelowProj, oldProj);
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
newPushedCondition = ((RexCall) newPushedCondition).getOperands().get(0);
}
RelNode newPushedFilterRel = relBuilder.push(oldProj.getInput()).filter(newPushedCondition).build();
RelNode newProjRel = relBuilder.push(newPushedFilterRel)
.project(oldProj.getProjects(), oldProj.getRowType().getFieldNames()).build();
if (unPushedFilCondAboveProj != null) {
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
unPushedFilCondAboveProj = ((RexCall) unPushedFilCondAboveProj).getOperands().get(0);
}
newProjRel = relBuilder.push(newProjRel).filter(unPushedFilCondAboveProj).build();
}
return newProjRel;
}
代码示例来源:origin: apache/hive
for(RexNode project:topProject.getProjects()) {
RexNode newProject = project.accept(new RelOptUtil.RexInputConverter(rexBuilder, swappedJoinFeilds,
swappedJoinFeilds, condAdjustments));
代码示例来源:origin: apache/incubator-druid
RelOptUtil.InputFinder.bits(project.getProjects(), null);
final ImmutableBitSet rightBits =
ImmutableBitSet.range(
.project(project.getProjects(), project.getRowType().getFieldNames())
.build()
);
内容来源于网络,如有侵权,请联系作者删除!