use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.
the class AbstractStreamProcessor method cloneProcessor.
@Override
public Processor cloneProcessor(String key) {
try {
AbstractStreamProcessor abstractStreamProcessor = this.getClass().newInstance();
abstractStreamProcessor.inputDefinition = inputDefinition;
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
for (int i = 0; i < attributeExpressionLength; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
}
abstractStreamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
abstractStreamProcessor.attributeExpressionLength = attributeExpressionLength;
abstractStreamProcessor.additionalAttributes = additionalAttributes;
abstractStreamProcessor.complexEventPopulater = complexEventPopulater;
abstractStreamProcessor.siddhiAppContext = siddhiAppContext;
abstractStreamProcessor.elementId = elementId + "-" + key;
abstractStreamProcessor.configReader = configReader;
abstractStreamProcessor.outputExpectsExpiredEvents = outputExpectsExpiredEvents;
abstractStreamProcessor.queryName = queryName;
abstractStreamProcessor.siddhiAppContext.getSnapshotService().addSnapshotable(queryName, abstractStreamProcessor);
abstractStreamProcessor.siddhiAppContext.addEternalReferencedHolder(abstractStreamProcessor);
abstractStreamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
abstractStreamProcessor.start();
return abstractStreamProcessor;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.
the class AggregateWindowProcessor method cloneProcessor.
@Override
public Processor cloneProcessor(String key) {
try {
AggregateWindowProcessor streamProcessor = new AggregateWindowProcessor(aggregationRuntime, within, per);
streamProcessor.inputDefinition = inputDefinition;
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
for (int i = 0; i < attributeExpressionLength; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
}
streamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
streamProcessor.attributeExpressionLength = attributeExpressionLength;
streamProcessor.additionalAttributes = additionalAttributes;
streamProcessor.complexEventPopulater = complexEventPopulater;
streamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
streamProcessor.start();
return streamProcessor;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater 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.event.stream.populater.ComplexEventPopulater in project carbon-apimgt by wso2.
the class EmitOnStateChange method process.
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) {
while (streamEventChunk.hasNext()) {
StreamEvent event = streamEventChunk.next();
Boolean currentThrottleState = (Boolean) isThrottledExpressionExecutor.execute(event);
String key = (String) keyExpressionExecutor.execute(event);
Boolean lastThrottleState = throttleStateMap.get(key);
if (lastThrottleState == currentThrottleState && !currentThrottleState) {
streamEventChunk.remove();
} else {
throttleStateMap.put(key, currentThrottleState);
}
}
nextProcessor.process(streamEventChunk);
}
use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.
the class QueryParserHelper method initSingleStreamRuntime.
private static void initSingleStreamRuntime(SingleStreamRuntime singleStreamRuntime, int streamEventChainIndex, MetaComplexEvent metaComplexEvent, StateEventPool stateEventPool, LockWrapper lockWrapper, String queryName) {
MetaStreamEvent metaStreamEvent;
if (metaComplexEvent instanceof MetaStateEvent) {
metaStreamEvent = ((MetaStateEvent) metaComplexEvent).getMetaStreamEvent(streamEventChainIndex);
} else {
metaStreamEvent = (MetaStreamEvent) metaComplexEvent;
}
StreamEventPool streamEventPool = new StreamEventPool(metaStreamEvent, 5);
ProcessStreamReceiver processStreamReceiver = singleStreamRuntime.getProcessStreamReceiver();
processStreamReceiver.setMetaStreamEvent(metaStreamEvent);
processStreamReceiver.setStreamEventPool(streamEventPool);
processStreamReceiver.setLockWrapper(lockWrapper);
processStreamReceiver.init();
Processor processor = singleStreamRuntime.getProcessorChain();
while (processor != null) {
if (processor instanceof SchedulingProcessor) {
((SchedulingProcessor) processor).getScheduler().setStreamEventPool(streamEventPool);
((SchedulingProcessor) processor).getScheduler().init(lockWrapper, queryName);
}
if (processor instanceof AbstractStreamProcessor) {
((AbstractStreamProcessor) processor).setStreamEventCloner(new StreamEventCloner(metaStreamEvent, streamEventPool));
((AbstractStreamProcessor) processor).constructStreamEventPopulater(metaStreamEvent, streamEventChainIndex);
}
if (stateEventPool != null && processor instanceof JoinProcessor) {
if (((JoinProcessor) processor).getCompiledCondition() instanceof IncrementalAggregateCompileCondition) {
IncrementalAggregateCompileCondition compiledCondition = (IncrementalAggregateCompileCondition) ((JoinProcessor) processor).getCompiledCondition();
ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamEvent, 0, compiledCondition.getAdditionalAttributes());
compiledCondition.setComplexEventPopulater(complexEventPopulater);
}
((JoinProcessor) processor).setStateEventPool(stateEventPool);
((JoinProcessor) processor).setJoinLock(lockWrapper);
}
if (stateEventPool != null && processor instanceof StreamPreStateProcessor) {
((StreamPreStateProcessor) processor).setStateEventPool(stateEventPool);
((StreamPreStateProcessor) processor).setStreamEventPool(streamEventPool);
((StreamPreStateProcessor) processor).setStreamEventCloner(new StreamEventCloner(metaStreamEvent, streamEventPool));
if (metaComplexEvent instanceof MetaStateEvent) {
((StreamPreStateProcessor) processor).setStateEventCloner(new StateEventCloner(((MetaStateEvent) metaComplexEvent), stateEventPool));
}
}
processor = processor.getNextProcessor();
}
}
Aggregations