use of io.siddhi.query.api.SiddhiApp in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery56.
@Test
public void testFilterQuery56() throws InterruptedException {
log.info("Filter test56");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.EQUAL, Expression.value(70))));
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", 50f, 60d });
inputHandler.send(new Object[] { "WSO2", 70f, 40d });
inputHandler.send(new Object[] { "WSO2", 44f, 200d });
SiddhiTestHelper.waitForEvents(10, 1, count, 100);
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.SiddhiApp in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery57.
@Test
public void testFilterQuery57() throws InterruptedException {
log.info("Filter test57");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.EQUAL, Expression.value(60L))));
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", 50f, 60d });
inputHandler.send(new Object[] { "WSO2", 70f, 60d });
inputHandler.send(new Object[] { "WSO2", 60f, 200d });
SiddhiTestHelper.waitForEvents(10, 1, count, 100);
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.SiddhiApp in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery62.
@Test
public void testFilterQuery62() throws InterruptedException {
log.info("Filter test62");
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.EQUAL, Expression.value(200L))));
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, 5 });
inputHandler.send(new Object[] { "WSO2", 70f, 60L, 2 });
inputHandler.send(new Object[] { "WSO2", 60f, 200L, 4 });
SiddhiTestHelper.waitForEvents(10, 1, count, 100);
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.SiddhiApp in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery60.
@Test
public void testFilterQuery60() throws InterruptedException {
log.info("Filter test60");
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.EQUAL, Expression.value(2))));
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, 60d, 5 });
inputHandler.send(new Object[] { "WSO2", 70f, 60d, 2 });
inputHandler.send(new Object[] { "WSO2", 60f, 200d, 4 });
SiddhiTestHelper.waitForEvents(10, 1, count, 100);
siddhiAppRuntime.shutdown();
}
use of io.siddhi.query.api.SiddhiApp in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery64.
@Test
public void testFilterQuery64() throws InterruptedException {
log.info("Filter test64");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.EQUAL, Expression.value(40f))));
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", 50f, 60L });
inputHandler.send(new Object[] { "WSO2", 70f, 40L });
inputHandler.send(new Object[] { "WSO2", 44f, 200L });
SiddhiTestHelper.waitForEvents(10, 1, count, 100);
siddhiAppRuntime.shutdown();
}
Aggregations