我正在尝试在Siddhi实施一个示例项目。存在具有一个属性height
的输入事件流。我想写一个sequence
查询,当有三个具有相同高度的连续事件时,它会给出一个回调。
我已经提到了this和this博客,但我无法正确使用语法。我在尝试运行序列查询时得到SiddhiParserException
。
这是相应的模式查询,可以正常工作。
executionPlan = "" +
"define stream cseEventStream (height int); " +
"" +
"@info(name = 'query1') " +
"from every e1 = cseEventStream " +
"-> e2 = cseEventStream[e1.height == e2.height]" +
"-> e3 = cseEventStream[e2.height == e3.height] "+
"select e1.height as height1, e2.height as height2, e3.height as height3 " +
"insert into outputStream ;";
下面是我如何编写序列查询以获得两个连续的相等高度,但我无法做到正确。
executionPlan = "" +
"define stream cseEventStream (height int); " +
"" +
"@info(name = 'query1') " +
"from every e1 = cseEventStream, e2 = cseEventStream[e1.height == height]" +
"select e1.height as height1, e2.height as height2" +
"insert into outputStream ;";
添加错误日志:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.wso2.siddhi.query.compiler.exception.SiddhiParserException: You have an error in your SiddhiQL at line 1:195, extraneous input 'into' expecting {',', GROUP, HAVING, INSERT, DELETE, UPDATE, RETURN, OUTPUT}
at org.wso2.siddhi.query.compiler.internal.SiddhiErrorListener.syntaxError(SiddhiErrorListener.java:36)
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:65)
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:566)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportUnwantedToken(DefaultErrorStrategy.java:375)
at org.antlr.v4.runtime.DefaultErrorStrategy.sync(DefaultErrorStrategy.java:273)
at org.wso2.siddhi.query.compiler.SiddhiQLParser.query_section(SiddhiQLParser.java:3702)
at org.wso2.siddhi.query.compiler.SiddhiQLParser.query(SiddhiQLParser.java:1903)
at org.wso2.siddhi.query.compiler.SiddhiQLParser.execution_element(SiddhiQLParser.java:619)
at org.wso2.siddhi.query.compiler.SiddhiQLParser.execution_plan(SiddhiQLParser.java:550)
at org.wso2.siddhi.query.compiler.SiddhiQLParser.parse(SiddhiQLParser.java:152)
at org.wso2.siddhi.query.compiler.SiddhiCompiler.parse(SiddhiCompiler.java:63)
at org.wso2.siddhi.core.SiddhiManager.createExecutionPlanRuntime(SiddhiManager.java:61)
at mainpkg.DriverClass.initiateExecutionPlan(DriverClass.java:54)
at mainpkg.DriverClass.main(DriverClass.java:37)
感谢任何帮助。
答案 0 :(得分:1)
我设法解决了这个问题。这是字符串段末尾的缺失空间。注意"]"之后第5和第6行末尾的空格。和" height2"
executionPlan = "" +
"define stream cseEventStream (height int); " +
"" +
"@info(name = 'query1') " +
"from every e1 = cseEventStream, e2 = cseEventStream[e1.height == height] " +
"select e1.height as height1, e2.height as height2 " +
"insert into outputStream ;";