本文整理汇总了Java中org.apache.calcite.rex.RexCorrelVariable类的典型用法代码示例。如果您正苦于以下问题:Java RexCorrelVariable类的具体用法?Java RexCorrelVariable怎么用?Java RexCorrelVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RexCorrelVariable类属于org.apache.calcite.rex包,在下文中一共展示了RexCorrelVariable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: rexVisitor
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) {
return new RexVisitorImpl<Void>(true) {
@Override
public Void visitFieldAccess(RexFieldAccess fieldAccess) {
final RexNode ref = fieldAccess.getReferenceExpr();
if (ref instanceof RexCorrelVariable) {
final RexCorrelVariable var = (RexCorrelVariable) ref;
final Correlation correlation = new Correlation(var.id, fieldAccess.getField().getIndex(), corrIdGenerator++);
mapFieldAccessToCorVar.put(fieldAccess, correlation);
mapRefRelToCorVar.put(rel, correlation);
}
return super.visitFieldAccess(fieldAccess);
}
@Override
public Void visitSubQuery(RexSubQuery subQuery) {
subQuery.rel.accept(FlinkRelDecorrelator.CorelMapBuilder.this);
return super.visitSubQuery(subQuery);
}
};
}
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:FlinkRelDecorrelator.java
示例2: references
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
private boolean references(RexNode e, CorRef correlation) {
switch (e.getKind()) {
case CAST:
final RexNode operand = ((RexCall) e).getOperands().get(0);
if (isWidening(e.getType(), operand.getType())) {
return references(operand, correlation);
}
return false;
case FIELD_ACCESS:
final RexFieldAccess f = (RexFieldAccess) e;
if (f.getField().getIndex() == correlation.field
&& f.getReferenceExpr() instanceof RexCorrelVariable) {
if (((RexCorrelVariable) f.getReferenceExpr()).id == correlation.corr) {
return true;
}
}
// fall through
default:
return false;
}
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RelDecorrelator.java
示例3: testCorrelationFails
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Test public void testCorrelationFails() {
final RelBuilder builder = RelBuilder.create(config().build());
final Holder<RexCorrelVariable> v = Holder.of(null);
try {
builder.scan("EMP")
.variable(v)
.filter(builder.equals(builder.field(0), v.get()))
.scan("DEPT")
.join(JoinRelType.INNER, builder.literal(true),
ImmutableSet.of(v.get().id));
fail("expected error");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(),
containsString("variable $cor0 must not be used by left input to correlation"));
}
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelBuilderTest.java
示例4: testCorrelationWithCondition
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Test public void testCorrelationWithCondition() {
final RelBuilder builder = RelBuilder.create(config().build());
final Holder<RexCorrelVariable> v = Holder.of(null);
RelNode root = builder.scan("EMP")
.variable(v)
.scan("DEPT")
.filter(
builder.equals(builder.field(0),
builder.field(v.get(), "DEPTNO")))
.join(JoinRelType.LEFT,
builder.equals(builder.field(2, 0, "SAL"),
builder.literal(1000)),
ImmutableSet.of(v.get().id))
.build();
// Note that the join filter gets pushed to the right-hand input of
// LogicalCorrelate
final String expected = ""
+ "LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])\n"
+ " LogicalTableScan(table=[[scott, EMP]])\n"
+ " LogicalFilter(condition=[=($cor0.SAL, 1000)])\n"
+ " LogicalFilter(condition=[=($0, $cor0.DEPTNO)])\n"
+ " LogicalTableScan(table=[[scott, DEPT]])\n";
assertThat(str(root), is(expected));
}
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RelBuilderTest.java
示例5: rexVisitor
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) {
return new RexVisitorImpl<Void>(true) {
@Override public Void visitFieldAccess(RexFieldAccess fieldAccess) {
final RexNode ref = fieldAccess.getReferenceExpr();
if (ref instanceof RexCorrelVariable) {
final RexCorrelVariable var = (RexCorrelVariable) ref;
if (mapFieldAccessToCorVar.containsKey(fieldAccess)) {
// for cases where different Rel nodes are referring to
// same correlation var (e.g. in case of NOT IN)
// avoid generating another correlation var
// and record the 'rel' is using the same correlation
mapRefRelToCorRef.put(rel,
mapFieldAccessToCorVar.get(fieldAccess));
} else {
final CorRef correlation =
new CorRef(var.id, fieldAccess.getField().getIndex(),
corrIdGenerator++);
mapFieldAccessToCorVar.put(fieldAccess, correlation);
mapRefRelToCorRef.put(rel, correlation);
}
}
return super.visitFieldAccess(fieldAccess);
}
@Override public Void visitSubQuery(RexSubQuery subQuery) {
subQuery.rel.accept(CorelMapBuilder.this);
return super.visitSubQuery(subQuery);
}
};
}
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:RelDecorrelator.java
示例6: trimChild
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
/**
* Trims the fields of an input relational expression.
*
* @param rel Relational expression
* @param input Input relational expression, whose fields to trim
* @param fieldsUsed Bitmap of fields needed by the consumer
* @return New relational expression and its field mapping
*/
protected TrimResult trimChild(
RelNode rel,
RelNode input,
final ImmutableBitSet fieldsUsed,
Set<RelDataTypeField> extraFields) {
final ImmutableBitSet.Builder fieldsUsedBuilder = fieldsUsed.rebuild();
// Fields that define the collation cannot be discarded.
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final ImmutableList<RelCollation> collations = mq.collations(input);
for (RelCollation collation : collations) {
for (RelFieldCollation fieldCollation : collation.getFieldCollations()) {
fieldsUsedBuilder.set(fieldCollation.getFieldIndex());
}
}
// Correlating variables are a means for other relational expressions to use
// fields.
for (final CorrelationId correlation : rel.getVariablesSet()) {
rel.accept(
new CorrelationReferenceFinder() {
protected RexNode handle(RexFieldAccess fieldAccess) {
final RexCorrelVariable v =
(RexCorrelVariable) fieldAccess.getReferenceExpr();
if (v.id.equals(correlation)) {
fieldsUsedBuilder.set(fieldAccess.getField().getIndex());
}
return fieldAccess;
}
});
}
return dispatchTrimFields(input, fieldsUsedBuilder.build(), extraFields);
}
开发者ID:apache,项目名称:calcite,代码行数:43,代码来源:RelFieldTrimmer.java
示例7: result
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
protected TrimResult result(RelNode r, final Mapping mapping) {
final RexBuilder rexBuilder = relBuilder.getRexBuilder();
for (final CorrelationId correlation : r.getVariablesSet()) {
r = r.accept(
new CorrelationReferenceFinder() {
protected RexNode handle(RexFieldAccess fieldAccess) {
final RexCorrelVariable v =
(RexCorrelVariable) fieldAccess.getReferenceExpr();
if (v.id.equals(correlation)
&& v.getType().getFieldCount() == mapping.getSourceCount()) {
final int old = fieldAccess.getField().getIndex();
final int new_ = mapping.getTarget(old);
final RelDataTypeFactory.Builder typeBuilder =
relBuilder.getTypeFactory().builder();
for (int target : Util.range(mapping.getTargetCount())) {
typeBuilder.add(
v.getType().getFieldList().get(mapping.getSource(target)));
}
final RexNode newV =
rexBuilder.makeCorrel(typeBuilder.build(), v.id);
if (old != new_) {
return rexBuilder.makeFieldAccess(newV, new_);
}
}
return fieldAccess;
}
});
}
return new TrimResult(r, mapping);
}
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:RelFieldTrimmer.java
示例8: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override public RexNode visitCorrelVariable(RexCorrelVariable variable) {
if (!alternateIds.contains(variable.id)) {
return variable;
}
return builder.makeCorrel(variable.getType(), canonicalId);
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:DeduplicateCorrelateVariables.java
示例9: variable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
/** Creates a correlation variable for the current input, and writes it into
* a Holder. */
public RelBuilder variable(Holder<RexCorrelVariable> v) {
v.set((RexCorrelVariable)
getRexBuilder().makeCorrel(peek().getRowType(),
cluster.createCorrel()));
return this;
}
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:RelBuilder.java
示例10: visitFieldAccess
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) {
if (fieldAccess.getReferenceExpr() instanceof RexCorrelVariable) {
final RexCorrelVariable v =
(RexCorrelVariable) fieldAccess.getReferenceExpr();
variableFields.put(v.id, fieldAccess.getField().getIndex());
}
return super.visitFieldAccess(fieldAccess);
}
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:RelOptUtil.java
示例11: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
public Void visitCorrelVariable(RexCorrelVariable correlVariable) {
return pushVariable();
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:FindPartitionConditions.java
示例12: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public RexNode visitCorrelVariable(RexCorrelVariable correlVariable) {
return correlVariable;
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:RewriteAsBinaryOperators.java
示例13: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public LogicalExpression visitCorrelVariable(RexCorrelVariable correlVariable) {
return doUnknown(correlVariable);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:DrillOptiq.java
示例14: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public Boolean visitCorrelVariable(RexCorrelVariable correlVariable) {
return doUnknown(correlVariable);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:DrillProjectRelBase.java
示例15: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public Boolean visitCorrelVariable(RexCorrelVariable paramRexCorrelVariable) {
return true;
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:JdbcExpressionCheck.java
示例16: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public Boolean visitCorrelVariable(RexCorrelVariable correlVariable) {
return true;
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:RewriteProjectToFlattenRule.java
示例17: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public StateHolder visitCorrelVariable(RexCorrelVariable correlVariable) {
return new StateHolder(Type.OTHER, correlVariable);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:FindSimpleFilters.java
示例18: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public RexNode visitCorrelVariable(RexCorrelVariable variable) {
foundCorrelVariable = true;
return super.visitCorrelVariable(variable);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:6,代码来源:RexSubQueryUtils.java
示例19: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public Boolean visitCorrelVariable(RexCorrelVariable correlVariable) {
return false;
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:MoreRelOptUtil.java
示例20: visitCorrelVariable
import org.apache.calcite.rex.RexCorrelVariable; //导入依赖的package包/类
@Override
public Expression visitCorrelVariable(RexCorrelVariable correlVariable) {
return super.visitCorrelVariable(correlVariable);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:PredicateAnalyzer.java
注:本文中的org.apache.calcite.rex.RexCorrelVariable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论