private void defineImplementor( SqlOperator operator, NullPolicy nullPolicy, NotNullImplementor implementor, boolean harmonize) { CallImplementor callImplementor = createImplementor(implementor, nullPolicy, harmonize); map.put(operator, callImplementor); }
private void defineImplementor( SqlOperator operator, NullPolicy nullPolicy, NotNullImplementor implementor, boolean harmonize) { CallImplementor callImplementor = createImplementor(implementor, nullPolicy, harmonize); map.put(operator, callImplementor); }
private static CallImplementor createImplementor(final Method method) { return RexImpTable.createImplementor( new ReflectiveCallNotNullImplementor(method) { public Expression implement(RexToLixTranslator translator, RexCall call, List<Expression> translatedOperands) { Expression expr = super.implement(translator, call, translatedOperands); final Class<?> returnType = method.getReturnType(); if (QueryableTable.class.isAssignableFrom(returnType)) { Expression queryable = Expressions.call( Expressions.convert_(expr, QueryableTable.class), BuiltInMethod.QUERYABLE_TABLE_AS_QUERYABLE.method, Expressions.call(DataContext.ROOT, BuiltInMethod.DATA_CONTEXT_GET_QUERY_PROVIDER.method), Expressions.constant(null, SchemaPlus.class), Expressions.constant(call.getOperator().getName(), String.class)); expr = Expressions.call(queryable, BuiltInMethod.QUERYABLE_AS_ENUMERABLE.method); } else { expr = Expressions.call(expr, BuiltInMethod.SCANNABLE_TABLE_SCAN.method, DataContext.ROOT); } return expr; } }, NullPolicy.ANY, false); }
private static CallImplementor createImplementor(final Method method) { return RexImpTable.createImplementor( new ReflectiveCallNotNullImplementor(method) { public Expression implement(RexToLixTranslator translator, RexCall call, List<Expression> translatedOperands) { Expression expr = super.implement(translator, call, translatedOperands); final Class<?> returnType = method.getReturnType(); if (QueryableTable.class.isAssignableFrom(returnType)) { Expression queryable = Expressions.call( Expressions.convert_(expr, QueryableTable.class), BuiltInMethod.QUERYABLE_TABLE_AS_QUERYABLE.method, Expressions.call(DataContext.ROOT, BuiltInMethod.DATA_CONTEXT_GET_QUERY_PROVIDER.method), Expressions.constant(null, SchemaPlus.class), Expressions.constant(call.getOperator().getName(), String.class)); expr = Expressions.call(queryable, BuiltInMethod.QUERYABLE_AS_ENUMERABLE.method); } else { expr = Expressions.call(expr, BuiltInMethod.SCANNABLE_TABLE_SCAN.method, DataContext.ROOT); } return expr; } }, NullPolicy.ANY, false); }
private CastOptimizedImplementor() { accurate = createImplementor(new CastImplementor(), NullPolicy.STRICT, false); }
private CastOptimizedImplementor() { accurate = createImplementor(new CastImplementor(), NullPolicy.STRICT, false); }
private static CallImplementor createImplementor(final Method method) { final NullPolicy nullPolicy = getNullPolicy(method); return RexImpTable.createImplementor( new ReflectiveCallNotNullImplementor(method), nullPolicy, false); }
private static CallImplementor createImplementor(final Method method) { final NullPolicy nullPolicy = getNullPolicy(method); return RexImpTable.createImplementor( new ReflectiveCallNotNullImplementor(method), nullPolicy, false); }
@Override public CallImplementor getImplementor() { return RexImpTable.createImplementor((translator, call, translatedOperands) -> { final Expression context = Expressions.parameter(SamzaSqlExecutionContext.class, "context"); final Expression getUdfInstance = Expressions.call(ScalarUdf.class, context, getUdfMethod, Expressions.constant(udfMethod.getDeclaringClass().getName()), Expressions.constant(udfName)); final Expression callExpression = Expressions.convert_(Expressions.call(Expressions.convert_(getUdfInstance, udfMethod.getDeclaringClass()), udfMethod, translatedOperands), Object.class); // The Janino compiler which is used to compile the expressions doesn't seem to understand the Type of the ScalarUdf.execute // because it is a generic. To work around that we are explicitly casting it to the return type. return Expressions.convert_(callExpression, udfMethod.getReturnType()); }, NullPolicy.NONE, false); }
@Override public CallImplementor getImplementor() { return RexImpTable.createImplementor((translator, call, translatedOperands) -> { final Expression context = Expressions.parameter(SamzaSqlExecutionContext.class, "context"); final Expression getUdfInstance = Expressions.call(ScalarUdf.class, context, getUdfMethod, Expressions.constant(udfMethod.getDeclaringClass().getName()), Expressions.constant(udfName)); final Expression callExpression = Expressions.convert_(Expressions.call(Expressions.convert_(getUdfInstance, udfMethod.getDeclaringClass()), udfMethod, translatedOperands), Object.class); // The Janino compiler which is used to compile the expressions doesn't seem to understand the Type of the ScalarUdf.execute // because it is a generic. To work around that we are explicitly casting it to the return type. return Expressions.convert_(callExpression, udfMethod.getReturnType()); }, NullPolicy.NONE, false); }