Search in sources :

Example 6 with AbstractValuesProcessor

use of org.apache.storm.sql.runtime.AbstractValuesProcessor in project storm by apache.

the class PlanCompiler method compile.

public AbstractValuesProcessor compile(RelNode plan) throws Exception {
    String javaCode = generateJavaSource(plan);
    LOG.debug("Compiling... source code {}", javaCode);
    ClassLoader cl = new CompilingClassLoader(getClass().getClassLoader(), PACKAGE_NAME + ".Processor", javaCode, null);
    return (AbstractValuesProcessor) cl.loadClass(PACKAGE_NAME + ".Processor").newInstance();
}
Also used : CompilingClassLoader(org.apache.storm.sql.javac.CompilingClassLoader) CompilingClassLoader(org.apache.storm.sql.javac.CompilingClassLoader) AbstractValuesProcessor(org.apache.storm.sql.runtime.AbstractValuesProcessor)

Example 7 with AbstractValuesProcessor

use of org.apache.storm.sql.runtime.AbstractValuesProcessor in project storm by apache.

the class TestExprSemantic method testExpr.

private Values testExpr(List<String> exprs) throws Exception {
    String sql = "SELECT " + Joiner.on(',').join(exprs) + " FROM FOO" + " WHERE ID > 0 AND ID < 2";
    TestCompilerUtils.CalciteState state = TestCompilerUtils.sqlOverDummyTable(sql);
    PlanCompiler compiler = new PlanCompiler(typeFactory);
    AbstractValuesProcessor proc = compiler.compile(state.tree());
    Map<String, DataSource> data = new HashMap<>();
    data.put("FOO", new TestUtils.MockDataSource());
    List<Values> values = new ArrayList<>();
    ChannelHandler h = new TestUtils.CollectDataChannelHandler(values);
    proc.initialize(data, h);
    return values.get(0);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Values(org.apache.storm.tuple.Values) AbstractValuesProcessor(org.apache.storm.sql.runtime.AbstractValuesProcessor) ChannelHandler(org.apache.storm.sql.runtime.ChannelHandler) DataSource(org.apache.storm.sql.runtime.DataSource) PlanCompiler(org.apache.storm.sql.compiler.backends.standalone.PlanCompiler) TestUtils(org.apache.storm.sql.TestUtils) TestCompilerUtils(org.apache.storm.sql.compiler.backends.standalone.TestCompilerUtils)

Aggregations

AbstractValuesProcessor (org.apache.storm.sql.runtime.AbstractValuesProcessor)7 HashMap (java.util.HashMap)6 DataSource (org.apache.storm.sql.runtime.DataSource)6 ArrayList (java.util.ArrayList)5 TestUtils (org.apache.storm.sql.TestUtils)5 ChannelHandler (org.apache.storm.sql.runtime.ChannelHandler)5 Values (org.apache.storm.tuple.Values)5 Test (org.junit.Test)4 PlanCompiler (org.apache.storm.sql.compiler.backends.standalone.PlanCompiler)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 RelNode (org.apache.calcite.rel.RelNode)1 SqlNode (org.apache.calcite.sql.SqlNode)1 FrameworkConfig (org.apache.calcite.tools.FrameworkConfig)1 Planner (org.apache.calcite.tools.Planner)1 TestCompilerUtils (org.apache.storm.sql.compiler.backends.standalone.TestCompilerUtils)1 CompilingClassLoader (org.apache.storm.sql.javac.CompilingClassLoader)1 SqlCreateFunction (org.apache.storm.sql.parser.SqlCreateFunction)1 SqlCreateTable (org.apache.storm.sql.parser.SqlCreateTable)1 StormParser (org.apache.storm.sql.parser.StormParser)1