use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.linq4j.tree.BlockBuilder in project calcite by apache.
the class EnumerableSemiJoin method implement.
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
BlockBuilder builder = new BlockBuilder();
final Result leftResult = implementor.visitChild(this, 0, (EnumerableRel) left, pref);
Expression leftExpression = builder.append("left", leftResult.block);
final Result rightResult = implementor.visitChild(this, 1, (EnumerableRel) right, pref);
Expression rightExpression = builder.append("right", rightResult.block);
final PhysType physType = leftResult.physType;
return implementor.result(physType, builder.append(Expressions.call(BuiltInMethod.SEMI_JOIN.method, Expressions.list(leftExpression, rightExpression, leftResult.physType.generateAccessor(leftKeys), rightResult.physType.generateAccessor(rightKeys)))).toBlock());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.linq4j.tree.BlockBuilder in project calcite by apache.
the class EnumerableTableFunctionScan method implement.
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
BlockBuilder bb = new BlockBuilder();
// Non-array user-specified types are not supported yet
final JavaRowFormat format;
if (getElementType() == null) {
format = JavaRowFormat.ARRAY;
} else if (rowType.getFieldCount() == 1 && isQueryable()) {
format = JavaRowFormat.SCALAR;
} else if (getElementType() instanceof Class && Object[].class.isAssignableFrom((Class) getElementType())) {
format = JavaRowFormat.ARRAY;
} else {
format = JavaRowFormat.CUSTOM;
}
final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), format, false);
RexToLixTranslator t = RexToLixTranslator.forAggregation((JavaTypeFactory) getCluster().getTypeFactory(), bb, null);
t = t.setCorrelates(implementor.allCorrelateVariables);
bb.add(Expressions.return_(null, t.translate(getCall())));
return implementor.result(physType, bb.toBlock());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.linq4j.tree.BlockBuilder in project calcite by apache.
the class EnumerableInterpreter method implement.
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
final JavaTypeFactory typeFactory = implementor.getTypeFactory();
final BlockBuilder builder = new BlockBuilder();
final PhysType physType = PhysTypeImpl.of(typeFactory, getRowType(), JavaRowFormat.ARRAY);
final Expression interpreter_ = builder.append("interpreter", Expressions.new_(Interpreter.class, implementor.getRootExpression(), implementor.stash(getInput(), RelNode.class)));
final Expression sliced_ = getRowType().getFieldCount() == 1 ? Expressions.call(BuiltInMethod.SLICE0.method, interpreter_) : interpreter_;
builder.add(sliced_);
return implementor.result(physType, builder.toBlock());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.linq4j.tree.BlockBuilder in project calcite by apache.
the class EnumerableIntersect method implement.
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
final BlockBuilder builder = new BlockBuilder();
Expression intersectExp = null;
for (Ord<RelNode> ord : Ord.zip(inputs)) {
EnumerableRel input = (EnumerableRel) ord.e;
final Result result = implementor.visitChild(this, ord.i, input, pref);
Expression childExp = builder.append("child" + ord.i, result.block);
if (intersectExp == null) {
intersectExp = childExp;
} else {
intersectExp = Expressions.call(intersectExp, BuiltInMethod.INTERSECT.method, Expressions.list(childExp).appendIfNotNull(result.physType.comparer()));
}
// Once the first input has chosen its format, ask for the same for
// other inputs.
pref = pref.of(result.format);
}
builder.add(intersectExp);
final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM));
return implementor.result(physType, builder.toBlock());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.linq4j.tree.BlockBuilder in project calcite by apache.
the class EnumerableMinus method implement.
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
final BlockBuilder builder = new BlockBuilder();
Expression minusExp = null;
for (Ord<RelNode> ord : Ord.zip(inputs)) {
EnumerableRel input = (EnumerableRel) ord.e;
final Result result = implementor.visitChild(this, ord.i, input, pref);
Expression childExp = builder.append("child" + ord.i, result.block);
if (minusExp == null) {
minusExp = childExp;
} else {
minusExp = Expressions.call(minusExp, BuiltInMethod.EXCEPT.method, Expressions.list(childExp).appendIfNotNull(result.physType.comparer()));
}
// Once the first input has chosen its format, ask for the same for
// other inputs.
pref = pref.of(result.format);
}
builder.add(minusExp);
final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM));
return implementor.result(physType, builder.toBlock());
}
Aggregations