final Expression values_ = builder.append("values", Expressions.newArrayBounds(Object.class, 1, Expressions.constant(1)));
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, pref); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), result.format); Expression childExp = builder.append("child", result.block); PhysType inputPhysType = result.physType; final Pair<Expression, Expression> pair = inputPhysType.generateCollationKey( collation.getFieldCollations()); builder.add( Expressions.return_(null, Expressions.call(childExp, BuiltInMethod.ORDER_BY.method, Expressions.list( builder.append("keySelector", pair.left)) .appendIfNotNull( builder.appendIfNotNull("comparator", pair.right))))); return implementor.result(physType, builder.toBlock()); } }
@Override public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); Expression unionExp = 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 (unionExp == null) { unionExp = childExp; } else { unionExp = createUnionExpression(unionExp, childExp, result.format == JavaRowFormat.ARRAY); } } builder.add(unionExp); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock()); } }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, pref); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), result.format); Expression childExp = builder.append("child", result.block); PhysType inputPhysType = result.physType; final Pair<Expression, Expression> pair = inputPhysType.generateCollationKey( collation.getFieldCollations()); builder.add( Expressions.return_(null, Expressions.call(childExp, BuiltInMethod.ORDER_BY.method, Expressions.list( builder.append("keySelector", pair.left)) .appendIfNotNull( builder.appendIfNotNull("comparator", pair.right))))); return implementor.result(physType, builder.toBlock()); } }
/** * Appends a block to a list of statements and returns an expression * (possibly a variable) that represents the result of the newly added * block. */ public Expression append(String name, BlockStatement block) { return append(name, block, true); }
/** * Appends an expression to a list of statements, and returns an expression * (possibly a variable) that represents the result of the newly added * block. */ public Expression append(String name, Expression expression) { return append(name, expression, true); }
/** * Appends an expression to a list of statements, if it is not null. */ public Expression appendIfNotNull(String name, Expression expression) { if (expression == null) { return null; } return append(name, expression, true); }
public Expression field(BlockBuilder list, int index, Type storageType) { if (index < actualInputFieldCount) { Expression current = list.append("current", row); return rowPhysType.fieldReference(current, index, storageType); } return constants.get(index - actualInputFieldCount); } }
public Expression field(BlockBuilder list, int index, Type storageType) { if (index < actualInputFieldCount) { Expression current = list.append("current", row); return rowPhysType.fieldReference(current, index, storageType); } return constants.get(index - actualInputFieldCount); } }
Expression translate(RexNode expr, RexImpTable.NullAs nullAs, Type storageType) { Expression expression = translate0(expr, nullAs, storageType); expression = EnumUtils.enforce(storageType, expression); assert expression != null; return list.append("v", expression); }
Expression translate(RexNode expr, RexImpTable.NullAs nullAs, Type storageType) { Expression expression = translate0(expr, nullAs, storageType); expression = EnumUtils.enforce(storageType, expression); assert expression != null; return list.append("v", expression); }
public Expression field(BlockBuilder list, int index, Type storageType) { int offset = 0; for (Pair<Expression, PhysType> input : inputs) { final PhysType physType = input.right; int fieldCount = physType.getRowType().getFieldCount(); if (index >= offset + fieldCount) { offset += fieldCount; continue; } final Expression left = list.append("current", input.left); return physType.fieldReference(left, index - offset, storageType); } throw new IllegalArgumentException("Unable to find field #" + index); } }
public Expression field(BlockBuilder list, int index, Type storageType) { int offset = 0; for (Pair<Expression, PhysType> input : inputs) { final PhysType physType = input.right; int fieldCount = physType.getRowType().getFieldCount(); if (index >= offset + fieldCount) { offset += fieldCount; continue; } final Expression left = list.append("current", input.left); return physType.fieldReference(left, index - offset, storageType); } throw new IllegalArgumentException("Unable to find field #" + index); } }
private Pair<Expression, Expression> getRowCollationKey( BlockBuilder builder, PhysType inputPhysType, Group group, int windowIdx) { if (!(group.isRows || (group.upperBound.isUnbounded() && group.lowerBound.isUnbounded()))) { Pair<Expression, Expression> pair = inputPhysType.generateCollationKey( group.collation().getFieldCollations()); // optimize=false to prevent inlining of object create into for-loops return Pair.of( builder.append("keySelector" + windowIdx, pair.left, false), builder.append("keyComparator" + windowIdx, pair.right, false)); } else { return Pair.of(null, null); } }
private Pair<Expression, Expression> getRowCollationKey( BlockBuilder builder, PhysType inputPhysType, Group group, int windowIdx) { if (!(group.isRows || (group.upperBound.isUnbounded() && group.lowerBound.isUnbounded()))) { Pair<Expression, Expression> pair = inputPhysType.generateCollationKey( group.collation().getFieldCollations()); // optimize=false to prevent inlining of object create into for-loops return Pair.of( builder.append("keySelector" + windowIdx, pair.left, false), builder.append("keyComparator" + windowIdx, pair.right, false)); } else { return Pair.of(null, null); } }
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()); } }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, Prefer.ARRAY); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), JavaRowFormat.LIST); // final Enumerable<Employee> child = <<child adapter>>; // final List<Employee> list = child.toList(); Expression child_ = builder.append( "child", result.block); Expression list_ = builder.append("list", Expressions.call(child_, BuiltInMethod.ENUMERABLE_TO_LIST.method)); builder.add( Expressions.return_(null, Expressions.call( BuiltInMethod.SINGLETON_ENUMERABLE.method, list_))); return implementor.result(physType, builder.toBlock()); } }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, Prefer.ARRAY); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), JavaRowFormat.LIST); // final Enumerable<Employee> child = <<child adapter>>; // final List<Employee> list = child.toList(); Expression child_ = builder.append( "child", result.block); Expression list_ = builder.append("list", Expressions.call(child_, BuiltInMethod.ENUMERABLE_TO_LIST.method)); builder.add( Expressions.return_(null, Expressions.call( BuiltInMethod.SINGLETON_ENUMERABLE.method, list_))); return implementor.result(physType, builder.toBlock()); } }
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()); } }
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()); } }