use of org.apache.storm.sql.javac.CompilingClassLoader in project storm by apache.
the class QueryPlanner method compile.
public AbstractTridentProcessor compile(Map<String, ISqlTridentDataSource> sources, String query) throws Exception {
TridentRel relNode = getPlan(query);
TridentPlanCreator tridentPlanCreator = new TridentPlanCreator(sources, new RexBuilder(typeFactory));
relNode.tridentPlan(tridentPlanCreator);
final TridentTopology topology = tridentPlanCreator.getTopology();
final IAggregatableStream lastStream = tridentPlanCreator.pop();
final DataContext dc = tridentPlanCreator.getDataContext();
final List<CompilingClassLoader> cls = tridentPlanCreator.getClassLoaders();
return new AbstractTridentProcessor() {
@Override
public TridentTopology build() {
return topology;
}
@Override
public Stream outputStream() {
return lastStream.toStream();
}
@Override
public DataContext getDataContext() {
return dc;
}
@Override
public List<CompilingClassLoader> getClassLoaders() {
return cls;
}
};
}
use of org.apache.storm.sql.javac.CompilingClassLoader in project storm by apache.
the class TridentPlanCreator method createScalarInstance.
public ExecutableExpression createScalarInstance(List<RexNode> nodes, RelDataType inputRowType, String className) throws CompilingClassLoader.CompilerException, ClassNotFoundException, IllegalAccessException, InstantiationException {
String expr = rexCompiler.compile(nodes, inputRowType, className);
CompilingClassLoader classLoader = new CompilingClassLoader(getLastClassLoader(), className, expr, null);
ExecutableExpression instance = (ExecutableExpression) classLoader.loadClass(className).newInstance();
addClassLoader(classLoader);
return new DebuggableExecutableExpression(instance, expr);
}
use of org.apache.storm.sql.javac.CompilingClassLoader in project storm by apache.
the class TestPlanCompiler method runTridentTopology.
private void runTridentTopology(final int expectedValueSize, AbstractTridentProcessor proc, TridentTopology topo) throws Exception {
final Config conf = new Config();
conf.setMaxSpoutPending(20);
if (proc.getClassLoaders() != null && proc.getClassLoaders().size() > 0) {
CompilingClassLoader lastClassloader = proc.getClassLoaders().get(proc.getClassLoaders().size() - 1);
Utils.setClassLoaderForJavaDeSerialize(lastClassloader);
}
try (LocalTopology stormTopo = cluster.submitTopology("storm-sql", conf, topo.build())) {
waitForCompletion(1000 * 1000, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return getCollectedValues().size() < expectedValueSize;
}
});
} finally {
while (cluster.getClusterInfo().get_topologies_size() > 0) {
Thread.sleep(10);
}
Utils.resetClassLoaderForJavaDeSerialize();
}
}
use of org.apache.storm.sql.javac.CompilingClassLoader in project storm by apache.
the class SqlTestUtil method runStormTopology.
public static void runStormTopology(LocalCluster cluster, final List<?> watchedList, final int expectedValueSize, AbstractStreamsProcessor proc, StormTopology topo) throws Exception {
final Config conf = new Config();
conf.setMaxSpoutPending(20);
conf.setDebug(true);
if (proc.getClassLoaders() != null && proc.getClassLoaders().size() > 0) {
CompilingClassLoader lastClassloader = proc.getClassLoaders().get(proc.getClassLoaders().size() - 1);
Utils.setClassLoaderForJavaDeSerialize(lastClassloader);
}
try (LocalCluster.LocalTopology stormTopo = cluster.submitTopology("storm-sql", conf, topo)) {
waitForCompletion(1000 * 1000, () -> watchedList.size() < expectedValueSize);
} finally {
while (cluster.getTopologySummaries().size() > 0) {
Thread.sleep(10);
}
Utils.resetClassLoaderForJavaDeSerialize();
}
}
use of org.apache.storm.sql.javac.CompilingClassLoader in project storm by apache.
the class StreamsPlanCreator method createScalarInstance.
public ExecutableExpression createScalarInstance(List<RexNode> nodes, RelDataType inputRowType, String className) throws CompilingClassLoader.CompilerException, ClassNotFoundException, IllegalAccessException, InstantiationException {
String expr = rexCompiler.compile(nodes, inputRowType, className);
CompilingClassLoader classLoader = new CompilingClassLoader(getLastClassLoader(), className, expr, null);
ExecutableExpression instance = (ExecutableExpression) classLoader.loadClass(className).newInstance();
addClassLoader(classLoader);
return new DebuggableExecutableExpression(instance, expr);
}
Aggregations