StormBuiltInMethod.EXPR_EXECUTE2.method, context, values_))); builder.add( Expressions.return_(null, Expressions.arrayIndex(values_, Expressions.constant(0)))); declarations.add(
/** * Creates a GotoExpression representing a return statement. */ public static GotoStatement return_(LabelTarget labelTarget) { return return_(labelTarget, (Expression) null); }
public void add(Expression expression) { add(Expressions.return_(null, expression)); }
private static BlockStatement toFunctionBlock(Node body, boolean function) { if (body instanceof BlockStatement) { return (BlockStatement) body; } Statement statement; if (body instanceof Statement) { statement = (Statement) body; } else if (body instanceof Expression) { if (((Expression) body).getType() == Void.TYPE && function) { statement = Expressions.statement((Expression) body); } else { statement = Expressions.return_(null, (Expression) body); } } else { throw new AssertionError("block cannot contain node that is neither " + "statement nor expression: " + body); } return Expressions.block(statement); }
StreamlineBuiltInMethod.EXPR_EXECUTE2.method, context_, values_))); builder.add( Expressions.return_(null, Expressions.arrayIndex(values_, Expressions.constant(0)))); declarations.add(
private static Object coerce(Object o, RelDataType type) { if (o == null) { return null; } if (!(type instanceof RelDataTypeFactoryImpl.JavaType)) { return null; } final RelDataTypeFactoryImpl.JavaType javaType = (RelDataTypeFactoryImpl.JavaType) type; final Class clazz = javaType.getJavaClass(); //noinspection unchecked if (clazz.isAssignableFrom(o.getClass())) { return o; } if (clazz == String.class && o instanceof NlsString) { return ((NlsString) o).getValue(); } // We need optimization here for constant folding. // Not all the expressions can be interpreted (e.g. ternary), so // we rely on optimization capabilities to fold non-interpretable // expressions. BlockBuilder bb = new BlockBuilder(); final Expression expr = RexToLixTranslator.convert(Expressions.constant(o), clazz); bb.add(Expressions.return_(null, expr)); final FunctionExpression convert = Expressions.lambda(bb.toBlock(), Collections.emptyList()); return convert.compile().dynamicInvoke(); }
private static Object coerce(Object o, RelDataType type) { if (o == null) { return null; } if (!(type instanceof RelDataTypeFactoryImpl.JavaType)) { return null; } final RelDataTypeFactoryImpl.JavaType javaType = (RelDataTypeFactoryImpl.JavaType) type; final Class clazz = javaType.getJavaClass(); //noinspection unchecked if (clazz.isAssignableFrom(o.getClass())) { return o; } if (clazz == String.class && o instanceof NlsString) { return ((NlsString) o).getValue(); } // We need optimization here for constant folding. // Not all the expressions can be interpreted (e.g. ternary), so // we rely on optimization capabilities to fold non-interpretable // expressions. BlockBuilder bb = new BlockBuilder(); final Expression expr = RexToLixTranslator.convert(Expressions.constant(o), clazz); bb.add(Expressions.return_(null, expr)); final FunctionExpression convert = Expressions.lambda(bb.toBlock(), Collections.emptyList()); return convert.compile().dynamicInvoke(); }
Expressions.return_( null, Expressions.call(
conformance, blockBuilder, null, root_, getter, null); blockBuilder.add( Expressions.return_(null, Expressions.newArrayInit(Object[].class, expressions))); final MethodDeclaration methodDecl =
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, implementor.getConformance()); t = t.setCorrelates(implementor.allCorrelateVariables); bb.add(Expressions.return_(null, t.translate(getCall()))); return implementor.result(physType, bb.toBlock()); }
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, implementor.getConformance()); t = t.setCorrelates(implementor.allCorrelateVariables); bb.add(Expressions.return_(null, t.translate(getCall()))); return implementor.result(physType, bb.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 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()); } }
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()); } }
Expressions.return_( null, v));
Expressions.return_( null, v));
Expression predicate(EnumerableRelImplementor implementor, BlockBuilder builder, PhysType leftPhysType, PhysType rightPhysType, RexNode condition) { final ParameterExpression left_ = Expressions.parameter(leftPhysType.getJavaRowType(), "left"); final ParameterExpression right_ = Expressions.parameter(rightPhysType.getJavaRowType(), "right"); final RexProgramBuilder program = new RexProgramBuilder( implementor.getTypeFactory().builder() .addAll(left.getRowType().getFieldList()) .addAll(right.getRowType().getFieldList()) .build(), getCluster().getRexBuilder()); program.addCondition(condition); builder.add( Expressions.return_(null, RexToLixTranslator.translateCondition(program.getProgram(), implementor.getTypeFactory(), builder, new RexToLixTranslator.InputGetterImpl( ImmutableList.of(Pair.of((Expression) left_, leftPhysType), Pair.of((Expression) right_, rightPhysType))), implementor.allCorrelateVariables, implementor.getConformance()))); return Expressions.lambda(Predicate2.class, builder.toBlock(), left_, right_); } }
Expression predicate(EnumerableRelImplementor implementor, BlockBuilder builder, PhysType leftPhysType, PhysType rightPhysType, RexNode condition) { final ParameterExpression left_ = Expressions.parameter(leftPhysType.getJavaRowType(), "left"); final ParameterExpression right_ = Expressions.parameter(rightPhysType.getJavaRowType(), "right"); final RexProgramBuilder program = new RexProgramBuilder( implementor.getTypeFactory().builder() .addAll(left.getRowType().getFieldList()) .addAll(right.getRowType().getFieldList()) .build(), getCluster().getRexBuilder()); program.addCondition(condition); builder.add( Expressions.return_(null, RexToLixTranslator.translateCondition(program.getProgram(), implementor.getTypeFactory(), builder, new RexToLixTranslator.InputGetterImpl( ImmutableList.of(Pair.of((Expression) left_, leftPhysType), Pair.of((Expression) right_, rightPhysType))), implementor.allCorrelateVariables, implementor.getConformance()))); return Expressions.lambda(Predicate2.class, builder.toBlock(), left_, right_); } }
Expressions.call(table, ElasticsearchMethod.ELASTICSEARCH_QUERYABLE_FIND.method, ops, fields, sort, groupBy, aggregations, offset, fetch)); block.add(Expressions.return_(null, enumerable)); return relImplementor.result(physType, block.toBlock());