use of org.wso2.siddhi.query.api.execution.query.input.handler.Filter in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery6.
@Test
public void testFilterQuery6() throws InterruptedException {
log.info("Filter test6");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream cseEventStream (symbol string, price float, volume int);";
String query = "@info(name = 'query1') from cseEventStream[volume > 50L] select symbol,price,volume insert " + "into outputStream ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50f, 60 });
inputHandler.send(new Object[] { "WSO2", 70f, 40 });
inputHandler.send(new Object[] { "WSO2", 44f, 200 });
Thread.sleep(100);
AssertJUnit.assertEquals(2, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.execution.query.input.handler.Filter in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery29.
@Test
public void testFilterQuery29() throws InterruptedException {
log.info("Filter test29");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream cseEventStream (symbol string, price float, volume int);";
String query = "@info(name = 'query1') from cseEventStream[volume != 40d and volume != 400d] select symbol," + "price,volume insert into outputStream ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 55.5f, 40 });
inputHandler.send(new Object[] { "WSO2", 53.5f, 50 });
inputHandler.send(new Object[] { "WSO2", 50.5f, 400 });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.execution.query.input.handler.Filter in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery14.
@Test
public void testFilterQuery14() throws InterruptedException {
log.info("Filter test14");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream cseEventStream (symbol string, price float, volume float);";
String query = "@info(name = 'query1') from cseEventStream[volume > 45] select symbol,price insert into " + "outputStream ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50f, 60f });
inputHandler.send(new Object[] { "WSO2", 70f, 40f });
inputHandler.send(new Object[] { "WSO2", 44f, 200f });
Thread.sleep(100);
AssertJUnit.assertEquals(2, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.execution.query.input.handler.Filter in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery17.
@Test
public void testFilterQuery17() throws InterruptedException {
log.info("Filter test17");
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.GREATER_THAN, Expression.value(45))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("volume", Expression.variable("volume")));
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 = count + 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 });
Thread.sleep(100);
AssertJUnit.assertEquals(2, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.execution.query.input.handler.Filter in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery21.
@Test
public void testFilterQuery21() throws InterruptedException {
log.info("Filter test21");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
String query = "@info(name = 'query1') from cseEventStream[volume != 100] select symbol,price,volume insert " + "into outputStream ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
AssertJUnit.assertEquals(10L, ((Long) inEvents[0].getData(2)).longValue());
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 55.6f, 100L });
inputHandler.send(new Object[] { "WSO2", 57.6f, 10L });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
Aggregations