本文整理汇总了Java中org.wso2.siddhi.query.compiler.SiddhiCompiler.parseQuery方法的典型用法代码示例。如果您正苦于以下问题:Java SiddhiCompiler.parseQuery方法的具体用法?Java SiddhiCompiler.parseQuery怎么用?Java SiddhiCompiler.parseQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.siddhi.query.compiler.SiddhiCompiler
的用法示例。
在下文中一共展示了SiddhiCompiler.parseQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test1
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void test1() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from StockStream[price>3]#window.length(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having (price >= 20) " +
"insert all events into StockQuote; "
);
AssertJUnit.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("StockStream").
filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression
.value(3))).
window("length", Expression.value(50))).
select(Selector.selector().select(Expression.variable("symbol")).
select("avgPrice", Expression.function("avg", Expression.variable("price"))).
groupBy(Expression.variable("symbol")).
having(Expression.compare(
Expression.variable("price"),
Compare.Operator.GREATER_THAN_EQUAL,
Expression.value(20)))).
insertInto("StockQuote", OutputStream.OutputEventType.ALL_EVENTS);
AssertJUnit.assertEquals(api, query);
}
示例2: test2
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void test2() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from StockStream [price >= 20]#window.lengthBatch(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having avgPrice>50 " +
"insert into StockQuote; "
);
AssertJUnit.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("StockStream").
filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL,
Expression.value(20))).
window("lengthBatch", Expression.value(50))).
select(Selector.selector().
select(Expression.variable("symbol")).
select("avgPrice", Expression.function("avg", Expression.variable("price"))).
groupBy(Expression.variable("symbol")).
having(Expression.compare(
Expression.variable("avgPrice"),
Compare.Operator.GREATER_THAN,
Expression.value(50)))).
insertInto("StockQuote");
AssertJUnit.assertEquals(api, query);
}
示例3: test4
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void test4() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from AllStockQuotes#window.lenghtBatch(50) " +
"select symbol, avg(price) as avgPrice " +
"return ;"
);
AssertJUnit.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("AllStockQuotes").
window("lenghtBatch", Expression.value(50))).
select(Selector.selector().
select("symbol", Expression.variable("symbol")).
select("avgPrice", Expression.function("avg", Expression.variable("price")))).
returns();
AssertJUnit.assertEquals(api, query);
}
示例4: test5
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void test5() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from AllStockQuotes[price==Foo.price and Foo.try<5] " +
"select symbol, avg(price) as avgPrice " +
"return ;"
);
AssertJUnit.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("AllStockQuotes").
filter(Expression.and(Expression.compare(Expression.variable("price"), Compare.Operator.EQUAL,
Expression.variable("price").ofStream("Foo")), Expression.compare(Expression.variable("try")
.ofStream("Foo"), Compare.Operator.LESS_THAN, Expression.value(5))))).
select(Selector.selector().
select("symbol", Expression.variable("symbol")).
select("avgPrice", Expression.function("avg", Expression.variable("price"))));
AssertJUnit.assertEquals(api, query);
}
示例5: test2
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void test2() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from StockStream [price >= 20]#window.lengthBatch(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having avgPrice>50 " +
"insert into StockQuote; "
);
Assert.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("StockStream").
filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(20))).
window("lengthBatch", Expression.value(50))).
select(Selector.selector().
select(Expression.variable("symbol")).
select("avgPrice", Expression.function("avg", Expression.variable("price"))).
groupBy(Expression.variable("symbol")).
having(Expression.compare(
Expression.variable("avgPrice"),
Compare.Operator.GREATER_THAN,
Expression.value(50)))).
insertInto("StockQuote");
Assert.assertEquals(api, query);
}
示例6: test4
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void test4() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from e1=Stream1[price>20] -> not Stream2[price>e1.price] for 2 sec " +
"select e1.symbol as symbol1 " +
"insert into OutputStream ;");
AssertJUnit.assertNotNull(query);
Query api = Query.query();
api.from(
InputStream.patternStream(State.next(
State.stream(InputStream.stream("e1", "Stream1")
.filter(Expression.compare(Expression.variable("price"),
Compare.Operator.GREATER_THAN,
Expression.value(20)))),
State.logicalNot(State.stream(InputStream.stream("Stream2")
.filter(Expression.compare(Expression.variable("price"),
Compare.Operator.GREATER_THAN,
Expression.variable("price").ofStream("e1")))))
.waitingTime(new TimeConstant(2000)))
))
.select(Selector.selector().select("symbol1", Expression.variable("symbol").ofStream("e1")))
.insertInto("OutputStream");
AssertJUnit.assertEquals(api, query);
}
示例7: test1
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void test1() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from StockStream[price>3]#window.length(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having (price >= 20) " +
"insert all events into StockQuote; "
);
Assert.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("StockStream").
filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(3))).
window("length", Expression.value(50))).
select(Selector.selector().select(Expression.variable("symbol")).
select("avgPrice", Expression.function("avg", Expression.variable("price"))).
groupBy(Expression.variable("symbol")).
having(Expression.compare(
Expression.variable("price"),
Compare.Operator.GREATER_THAN_EQUAL,
Expression.value(20)))).
insertInto("StockQuote", OutputStream.OutputEventType.ALL_EVENTS);
Assert.assertEquals(api, query);
}
示例8: Test
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from cseEventStream#transform.avgStream(price) " +
"insert into StockQuote ;"
);
Assert.assertNotNull(query);
}
示例9: Test1
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test1() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from cseEventStream#transform.exthj:avgStream(price) " +
"insert into StockQuote ;"
);
Assert.assertNotNull(query);
}
示例10: Test1
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test1() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from a1 = infoStock[action == \"buy\"]*,\n" +
" b1 = cseEventStream[price > 70]?,\n" +
" b2 = cseEventStream[price > 75]\n" +
"select a1[0].action as action, b1.price as priceA, b2.price as priceBJoin " +
"insert into StockQuote");
Assert.assertNotNull(query);
}
示例11: Test7
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test7() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from cseEventStream[(price==foo.price and foo.try>5) in foo] " +
"select symbol, avg(price) as avgPrice "
);
Assert.assertNotNull(query);
}
示例12: Test4
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test4() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from TickEvent as t left outer join NewsEvent[symbol =='IBM']as n unidirectional \n" +
" on t.symbol == n.symbol\n" +
"insert into JoinStream ;");
Assert.assertNotNull(query);
Assert.assertTrue(((JoinStream) query.getInputStream()).getTrigger() == JoinStream.EventTrigger.RIGHT);
}
示例13: Test
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from cseEventStream[price>3]#window.lenghtBatch(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having (price >= 20) " +
"insert into StockQuote for all-events ; "
);
Assert.assertNotNull(query);
}
示例14: Test
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from cseEventStream#window.lenghtBatch(50) " +
"select symbol, avg(price) as avgPrice " +
"group by symbol " +
"having (price >= 20)" +
"output every 5 sec " +
"insert into StockQuote for all-events ; "
);
Assert.assertNotNull(query);
}
示例15: Test6
import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入方法依赖的package包/类
@Test
public void Test6() throws RecognitionException, SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from cseEventStream[price==foo.price and foo.try>5 in foo] " +
"select symbol, avg(price) as avgPrice "
);
Assert.assertNotNull(query);
}