use of io.siddhi.query.api.execution.query.Query in project siddhi by wso2.
the class FilterTestCase2 method testFilterQuery106.
@Test
public void testFilterQuery106() throws InterruptedException {
log.info("Filter test106");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG).attribute("quantity", Attribute.Type.INT);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(100d))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("quantity", Expression.variable("quantity")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count.addAndGet(inEvents.length);
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50f, 60L, 6 });
inputHandler.send(new Object[] { "WSO2", 70f, 40L, 10 });
inputHandler.send(new Object[] { "WSO2", 44f, 200L, 56 });
SiddhiTestHelper.waitForEvents(10, 1, count, 100);
AssertJUnit.assertEquals(1, count.get());
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.execution.query.Query in project siddhi by wso2.
the class FilterTestCase2 method testFilterQuery85.
@Test
public void testFilterQuery85() throws InterruptedException {
log.info("Filter test85");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE).attribute("quantity", Attribute.Type.INT);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.LESS_THAN, Expression.value(4L))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("quantity", Expression.variable("quantity")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count.addAndGet(inEvents.length);
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 500f, 50d, 6 });
inputHandler.send(new Object[] { "WSO2", 70f, 60d, 2 });
inputHandler.send(new Object[] { "WSO2", 50f, 300d, 4 });
SiddhiTestHelper.waitForEvents(10, 1, count, 100);
AssertJUnit.assertEquals(1, count.get());
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.execution.query.Query in project siddhi by wso2.
the class FilterTestCase2 method testFilterQuery92.
@Test
public void testFilterQuery92() throws InterruptedException {
log.info("Filter test92");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG).attribute("quantity", Attribute.Type.INT);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.LESS_THAN, Expression.value(100d))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("quantity", Expression.variable("quantity")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count.addAndGet(inEvents.length);
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50f, 60L, 6 });
inputHandler.send(new Object[] { "WSO2", 70f, 40L, 10 });
inputHandler.send(new Object[] { "WSO2", 44f, 200L, 56 });
SiddhiTestHelper.waitForEvents(10, 2, count, 100);
AssertJUnit.assertEquals(2, count.get());
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.execution.query.Query in project siddhi by wso2.
the class FilterTestCase2 method testFilterQuery96.
@Test
public void testFilterQuery96() throws InterruptedException {
log.info("Filter test96");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.DOUBLE);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(50))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count.addAndGet(inEvents.length);
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50d, 60d });
inputHandler.send(new Object[] { "WSO2", 70d, 40d });
inputHandler.send(new Object[] { "WSO2", 44d, 200d });
SiddhiTestHelper.waitForEvents(10, 2, count, 100);
AssertJUnit.assertEquals(2, count.get());
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.execution.query.Query in project siddhi by wso2.
the class TableQueryTestCase method testCreatingDeleteByTypeQuery.
@Test
public void testCreatingDeleteByTypeQuery() {
Query query = Query.query();
query.from(InputStream.stream("cseEventStream").filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value(9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume")))).window("lengthBatch", Expression.value(50)));
query.deleteBy("StockQuote", OutputStream.OutputEventType.ALL_EVENTS, Expression.compare(Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote")));
}
Aggregations