use of org.wso2.siddhi.core.query.FindStoreQueryRuntime in project siddhi by wso2.
the class StoreQueryParser method constructStoreQueryRuntime.
private static StoreQueryRuntime constructStoreQueryRuntime(Window window, StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, int metaPosition, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors) {
metaStreamEvent.setEventType(EventType.WINDOW);
initMetaStreamEvent(metaStreamEvent, window.getWindowDefinition());
MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, window.getWindowDefinition());
CompiledCondition compiledCondition = window.compileCondition(onCondition, generateMatchingMetaInfoHolder(metaStreamEvent, window.getWindowDefinition()), siddhiAppContext, variableExpressionExecutors, tableMap, queryName);
FindStoreQueryRuntime findStoreQueryRuntime = new FindStoreQueryRuntime(window, compiledCondition, queryName, metaStreamEvent);
populateFindStoreQueryRuntime(findStoreQueryRuntime, metaStreamInfoHolder, storeQuery.getSelector(), variableExpressionExecutors, siddhiAppContext, tableMap, queryName, metaPosition);
return findStoreQueryRuntime;
}
use of org.wso2.siddhi.core.query.FindStoreQueryRuntime in project siddhi by wso2.
the class StoreQueryParser method populateFindStoreQueryRuntime.
private static void populateFindStoreQueryRuntime(FindStoreQueryRuntime findStoreQueryRuntime, MatchingMetaInfoHolder metaStreamInfoHolder, Selector selector, List<VariableExpressionExecutor> variableExpressionExecutors, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, int metaPosition) {
QuerySelector querySelector = SelectorParser.parse(selector, new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS), siddhiAppContext, metaStreamInfoHolder.getMetaStateEvent(), tableMap, variableExpressionExecutors, queryName, metaPosition);
QueryParserHelper.reduceMetaComplexEvent(metaStreamInfoHolder.getMetaStateEvent());
QueryParserHelper.updateVariablePosition(metaStreamInfoHolder.getMetaStateEvent(), variableExpressionExecutors);
querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent()));
findStoreQueryRuntime.setStateEventPool(new StateEventPool(metaStreamInfoHolder.getMetaStateEvent(), 5));
findStoreQueryRuntime.setSelector(querySelector);
findStoreQueryRuntime.setOutputAttributes(metaStreamInfoHolder.getMetaStateEvent().getOutputStreamDefinition().getAttributeList());
}
use of org.wso2.siddhi.core.query.FindStoreQueryRuntime in project siddhi by wso2.
the class StoreQueryParser method constructStoreQueryRuntime.
private static StoreQueryRuntime constructStoreQueryRuntime(AggregationRuntime aggregation, StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, Within within, Expression per, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors) {
int metaPosition;
metaStreamEvent.setEventType(EventType.AGGREGATE);
initMetaStreamEvent(metaStreamEvent, aggregation.getAggregationDefinition());
MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, aggregation.getAggregationDefinition());
CompiledCondition compiledCondition = aggregation.compileExpression(onCondition, within, per, metaStreamInfoHolder, variableExpressionExecutors, tableMap, queryName, siddhiAppContext);
metaStreamInfoHolder = ((IncrementalAggregateCompileCondition) compiledCondition).getAlteredMatchingMetaInfoHolder();
FindStoreQueryRuntime findStoreQueryRuntime = new FindStoreQueryRuntime(aggregation, compiledCondition, queryName, metaStreamEvent);
metaPosition = 1;
populateFindStoreQueryRuntime(findStoreQueryRuntime, metaStreamInfoHolder, storeQuery.getSelector(), variableExpressionExecutors, siddhiAppContext, tableMap, queryName, metaPosition);
ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0), 0, ((IncrementalAggregateCompileCondition) compiledCondition).getAdditionalAttributes());
((IncrementalAggregateCompileCondition) compiledCondition).setComplexEventPopulater(complexEventPopulater);
return findStoreQueryRuntime;
}
use of org.wso2.siddhi.core.query.FindStoreQueryRuntime in project siddhi by wso2.
the class StoreQueryParser method constructStoreQueryRuntime.
private static StoreQueryRuntime constructStoreQueryRuntime(Table table, StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, int metaPosition, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors) {
metaStreamEvent.setEventType(EventType.TABLE);
initMetaStreamEvent(metaStreamEvent, table.getTableDefinition());
MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, table.getTableDefinition());
CompiledCondition compiledCondition = table.compileCondition(onCondition, metaStreamInfoHolder, siddhiAppContext, variableExpressionExecutors, tableMap, queryName);
if (table instanceof QueryableProcessor) {
List<Attribute> expectedOutputAttributes = buildExpectedOutputAttributes(storeQuery, siddhiAppContext, tableMap, queryName, metaPosition, metaStreamInfoHolder);
CompiledSelection compiledSelection = ((QueryableProcessor) table).compileSelection(storeQuery.getSelector(), expectedOutputAttributes, metaStreamInfoHolder, siddhiAppContext, variableExpressionExecutors, tableMap, queryName);
SelectStoreQueryRuntime storeQueryRuntime = new SelectStoreQueryRuntime((QueryableProcessor) table, compiledCondition, compiledSelection, expectedOutputAttributes, queryName);
QueryParserHelper.reduceMetaComplexEvent(metaStreamInfoHolder.getMetaStateEvent());
QueryParserHelper.updateVariablePosition(metaStreamInfoHolder.getMetaStateEvent(), variableExpressionExecutors);
return storeQueryRuntime;
} else {
FindStoreQueryRuntime storeQueryRuntime = new FindStoreQueryRuntime(table, compiledCondition, queryName, metaStreamEvent);
populateFindStoreQueryRuntime(storeQueryRuntime, metaStreamInfoHolder, storeQuery.getSelector(), variableExpressionExecutors, siddhiAppContext, tableMap, queryName, metaPosition);
return storeQueryRuntime;
}
}
Aggregations