use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class SiddhiAppRuntime method getStoreQueryOutputAttributes.
/**
* This method get the storeQuery and return the corresponding output and its types.
*
* @param storeQuery this storeQuery is processed and get the output attributes.
* @param storeQueryString this passed to report errors with context if there are any.
* @return List of output attributes
*/
private Attribute[] getStoreQueryOutputAttributes(StoreQuery storeQuery, String storeQueryString) {
try {
StoreQueryRuntime storeQueryRuntime = storeQueryRuntimeMap.get(storeQuery);
if (storeQueryRuntime == null) {
storeQueryRuntime = StoreQueryParser.parse(storeQuery, siddhiAppContext, tableMap, windowMap, aggregationMap);
storeQueryRuntimeMap.put(storeQuery, storeQueryRuntime);
}
return storeQueryRuntime.getStoreQueryOutputAttributes();
} catch (RuntimeException e) {
if (e instanceof SiddhiAppContextException) {
throw new StoreQueryCreationException(((SiddhiAppContextException) e).getMessageWithOutContext(), e, ((SiddhiAppContextException) e).getQueryContextStartIndex(), ((SiddhiAppContextException) e).getQueryContextEndIndex(), null, siddhiAppContext.getSiddhiAppString());
}
throw new StoreQueryCreationException(e.getMessage(), e);
}
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionTest4.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void convertFunctionTest4() throws InterruptedException {
log.info("convert function test 4");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "" + "" + "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL long, typeB " + "bool) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS) as valueB1 " + "insert into outputStream ;";
siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionExceptionTest9.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void convertFunctionExceptionTest9() throws InterruptedException {
log.info("convert function test 9");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream typeStream (typeS object, typeF float, typeD double, typeI int, typeL " + "long, typeB bool, typeN double) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,typeS) as valueS, convert(typeF,'float') as valueF, convert(typeD," + "'double') as valueD , convert(typeI,'int') as valueI , convert(typeL,'long') as valueL , " + "convert(typeB,'bool') as valueB, convert(typeN,'string') as valueN " + "insert into outputStream ;";
siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionTest6.
@Test(expectedExceptions = SiddhiAppValidationException.class)
public void convertFunctionTest6() throws InterruptedException {
log.info("convert function test 6");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "" + "" + "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL long, typeB " + "bool) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,string) as valueB1 " + "insert into outputStream ;";
siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionTest1.
@Test
public void convertFunctionTest1() throws InterruptedException {
log.info("convert function test 1");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "" + "" + "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL long, typeB " + "bool, typeN double) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,'string') as valueS, convert(typeF,'float') as valueF, convert(typeD,'double') " + "as valueD , convert(typeI,'int') as valueI , convert(typeL,'long') as valueL , convert(typeB,'bool')" + " as valueB, convert(typeN,'string') as valueN " + "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);
for (Event inEvent : inEvents) {
count++;
AssertJUnit.assertTrue(inEvent.getData(0) instanceof String);
AssertJUnit.assertTrue(inEvent.getData(1) instanceof Float);
AssertJUnit.assertTrue(inEvent.getData(2) instanceof Double);
AssertJUnit.assertTrue(inEvent.getData(3) instanceof Integer);
AssertJUnit.assertTrue(inEvent.getData(4) instanceof Long);
AssertJUnit.assertTrue(inEvent.getData(5) instanceof Boolean);
AssertJUnit.assertTrue(inEvent.getData(6) == null);
}
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("typeStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 2f, 3d, 4, 5L, true, null });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
Aggregations