Search in sources :

Example 1 with Bindable

use of org.apache.calcite.runtime.Bindable in project calcite by apache.

the class EnumerableInterpretable method getBindable.

static Bindable getBindable(ClassDeclaration expr, String s, int fieldCount) throws CompileException, IOException {
    ICompilerFactory compilerFactory;
    try {
        compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
    } catch (Exception e) {
        throw new IllegalStateException("Unable to instantiate java compiler", e);
    }
    IClassBodyEvaluator cbe = compilerFactory.newClassBodyEvaluator();
    cbe.setClassName(expr.name);
    cbe.setExtendedClass(Utilities.class);
    cbe.setImplementedInterfaces(fieldCount == 1 ? new Class[] { Bindable.class, Typed.class } : new Class[] { ArrayBindable.class });
    cbe.setParentClassLoader(EnumerableInterpretable.class.getClassLoader());
    if (CalcitePrepareImpl.DEBUG) {
        // Add line numbers to the generated janino class
        cbe.setDebuggingInformation(true, true, true);
    }
    return (Bindable) cbe.createInstance(new StringReader(s));
}
Also used : Typed(org.apache.calcite.runtime.Typed) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) ICompilerFactory(org.codehaus.commons.compiler.ICompilerFactory) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) Bindable(org.apache.calcite.runtime.Bindable) StringReader(java.io.StringReader) IClassBodyEvaluator(org.codehaus.commons.compiler.IClassBodyEvaluator) CompileException(org.codehaus.commons.compiler.CompileException) IOException(java.io.IOException)

Example 2 with Bindable

use of org.apache.calcite.runtime.Bindable 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);
}
Also used : ArrayBindable(org.apache.calcite.runtime.ArrayBindable) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) Bindable(org.apache.calcite.runtime.Bindable)

Example 3 with Bindable

use of org.apache.calcite.runtime.Bindable 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);
}
Also used : ArrayBindable(org.apache.calcite.runtime.ArrayBindable) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) Bindable(org.apache.calcite.runtime.Bindable)

Aggregations

ArrayBindable (org.apache.calcite.runtime.ArrayBindable)3 Bindable (org.apache.calcite.runtime.Bindable)3 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 Typed (org.apache.calcite.runtime.Typed)1 CompileException (org.codehaus.commons.compiler.CompileException)1 IClassBodyEvaluator (org.codehaus.commons.compiler.IClassBodyEvaluator)1 ICompilerFactory (org.codehaus.commons.compiler.ICompilerFactory)1