use of org.apache.calcite.runtime.ArrayBindable in project calcite by apache.
the class SparkHandlerImpl method compile.
public ArrayBindable compile(ClassDeclaration expr, String s) {
final String className = "CalciteProgram" + classId.getAndIncrement();
final File file = new File(SRC_DIR, className + ".java");
try (Writer w = Util.printWriter(file)) {
String source = "public class " + className + "\n" + " implements " + ArrayBindable.class.getName() + ", " + Serializable.class.getName() + " {\n" + s + "\n" + "}\n";
System.out.println("======================");
System.out.println(source);
System.out.println("======================");
w.write(source);
w.close();
JaninoCompiler compiler = new JaninoCompiler();
compiler.getArgs().setDestdir(CLASS_DIR.getAbsolutePath());
compiler.getArgs().setSource(source, file.getAbsolutePath());
compiler.getArgs().setFullClassName(className);
compiler.compile();
@SuppressWarnings("unchecked") final Class<ArrayBindable> clazz = (Class<ArrayBindable>) Class.forName(className);
final Constructor<ArrayBindable> constructor = clazz.getConstructor();
return constructor.newInstance();
} catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
use of org.apache.calcite.runtime.ArrayBindable in project calcite by apache.
the class EnumerableBindable method bind.
public Enumerable<Object[]> bind(DataContext dataContext) {
final ImmutableMap<String, Object> map = ImmutableMap.of();
final Bindable bindable = EnumerableInterpretable.toBindable(map, null, (EnumerableRel) getInput(), EnumerableRel.Prefer.ARRAY);
final ArrayBindable arrayBindable = EnumerableInterpretable.box(bindable);
return arrayBindable.bind(dataContext);
}
use of org.apache.calcite.runtime.ArrayBindable in project calcite by apache.
the class EnumerableInterpretable method implement.
public Node implement(final InterpreterImplementor implementor) {
final Bindable bindable = toBindable(implementor.internalParameters, implementor.spark, (EnumerableRel) getInput(), EnumerableRel.Prefer.ARRAY);
final ArrayBindable arrayBindable = box(bindable);
final Enumerable<Object[]> enumerable = arrayBindable.bind(implementor.dataContext);
return new EnumerableNode(enumerable, implementor.compiler, this);
}
Aggregations