本文整理汇总了Java中org.wso2.siddhi.query.compiler.SiddhiCompiler.parse方法的典型用法代码示例。如果您正苦于以下问题:Java SiddhiCompiler.parse方法的具体用法?Java SiddhiCompiler.parse怎么用?Java SiddhiCompiler.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.siddhi.query.compiler.SiddhiCompiler
的用法示例。
在下文中一共展示了SiddhiCompiler.parse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addExecutionPlan
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
public ExecutionPlanReference addExecutionPlan(String executionPlan) throws SiddhiParserException {
List<ExecutionPlan> executionPlanList = SiddhiCompiler.parse(executionPlan);
ExecutionPlanReference executionPlanReference = new ExecutionPlanReference();
for (ExecutionPlan plan : executionPlanList) {
if (plan instanceof Query) {
executionPlanReference.addQueryReference(addQuery((Query) plan));
} else if (plan instanceof StreamDefinition) {
executionPlanReference.addInputHandler(defineStream((StreamDefinition) plan));
} else if (plan instanceof TableDefinition) {
defineTable((TableDefinition) plan);
} else if (plan instanceof PartitionDefinition) {
definePartition((PartitionDefinition) plan);
} else {
throw new OperationNotSupportedException(plan.getClass().getName() + " is not supported as an execution plan element ");
}
}
return executionPlanReference;
}
示例2: Test1
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test1() throws RecognitionException, SiddhiParserException {
SiddhiCompiler.parse("from (\n" +
"\tfrom cseEventStream[ price >= 20]#window.length(50)\n" +
"select symbol, avg(price) as avgPrice\n" +
"group by symbol\n" +
"return) [symbol==\"IBM\"]\n" +
"select symbol, avgPrice\n" +
"insert into IBMStockQuote ");
}
示例3: Test2
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test2() throws RecognitionException, SiddhiParserException {
SiddhiCompiler.parse("from (\n" +
"from MyStream [price >10]\n" +
"return \n" +
") #window.length(1000)\n" +
"select symbol , avg(price) as avgPrice " +
"insert into StockQuote");
}
示例4: Test2
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test2() throws RecognitionException, SiddhiParserException {
List<ExecutionPlan> executionPlans = SiddhiCompiler.parse("define stream cseStream ( symbol string, price int, volume float );" +
"from cseStream#window.lenghtBatch(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having (price >= 20) " +
"insert into StockQuote for all-events ; "
);
Assert.assertEquals(2, executionPlans.size());
}
示例5: Test3
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test3() throws RecognitionException, SiddhiParserException {
List<ExecutionPlan> executionPlans = SiddhiCompiler.parse("from cseStream#window.lenghtBatch(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having (price >= 20) " +
"insert into StockQuote for all-events ; "
);
Assert.assertEquals(1, executionPlans.size());
}
示例6: Test2
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test2() throws RecognitionException, SiddhiParserException {
SiddhiCompiler.parse("from cseEventStream [price >= 20]#window.length(50) " +
"select symbol, avg(price) as avgPricegroup " +
"group by symbol " +
"having avgPrice>50 " +
"insert into StockQuote; ");
}
示例7: Test3
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test3() throws RecognitionException, SiddhiParserException {
SiddhiCompiler.parse("from allStockQuotes#window.time(600000)\n" +
"select symbol as symbol, price, avg(price) as averagePrice \n" +
"group by symbol \n" +
"having ( price > ( averagePrice*1.02) ) or ( averagePrice > price ) " +
"insert into fastMovingStockQuotes \n;");
// "having ( price > ( averagePrice*1.02) ) or ( averagePrice*0.98 > price ); ");
// "having ( price > (averagePrice +5)) or ( averagePrice > price ); ");
;
}
示例8: Test1
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test1() throws RecognitionException, SiddhiParserException {
List<ExecutionPlan> executionPlans = SiddhiCompiler.parse("define stream cseStream ( symbol string, price int, volume float )");
Assert.assertEquals(1, executionPlans.size());
}
示例9: siddhiArtifactDeployPost
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Override
public Response siddhiArtifactDeployPost(String siddhiApp) throws NotFoundException {
log.info("SiddhiApp = " + siddhiApp);
String jsonString = new Gson().toString();
try {
SiddhiApp parsedSiddhiApp = SiddhiCompiler.parse(siddhiApp);
String siddhiAppName = AnnotationHelper.getAnnotationElement(
SiddhiServiceConstants.ANNOTATION_NAME_NAME, null, parsedSiddhiApp.
getAnnotations()).getValue();
if (!siddhiAppRunTimeMap.containsKey(siddhiApp)) {
SiddhiAppConfiguration siddhiAppConfiguration = new SiddhiAppConfiguration();
siddhiAppConfiguration.setName(siddhiAppName);
siddhiAppConfigurationMap.put(siddhiAppName, siddhiAppConfiguration);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
if (siddhiAppRuntime != null) {
Set<String> streamNames = siddhiAppRuntime.getStreamDefinitionMap().keySet();
Map<String, InputHandler> inputHandlerMap = new ConcurrentHashMap<>(streamNames.size());
for (String streamName : streamNames) {
inputHandlerMap.put(streamName, siddhiAppRuntime.getInputHandler(streamName));
}
siddhiAppSpecificInputHandlerMap.put(siddhiAppName, inputHandlerMap);
siddhiAppRunTimeMap.put(siddhiAppName, siddhiAppRuntime);
siddhiAppRuntime.start();
jsonString = new Gson().toJson(new ApiResponseMessage(ApiResponseMessage.OK,
"Siddhi app is deployed " +
"and runtime is created"));
}
} else {
jsonString = new Gson().toJson(new ApiResponseMessage(ApiResponseMessage.ERROR,
"There is a Siddhi app already " +
"exists with same name"));
}
} catch (Exception e) {
jsonString = new Gson().toJson(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage()));
}
return Response.ok()
.entity(jsonString)
.build();
}