Search in sources :

Example 1 with StateEventCloner

use of org.wso2.siddhi.core.event.state.StateEventCloner 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();
    }
}
Also used : ProcessStreamReceiver(org.wso2.siddhi.core.query.input.ProcessStreamReceiver) StreamPreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor) Processor(org.wso2.siddhi.core.query.processor.Processor) JoinProcessor(org.wso2.siddhi.core.query.input.stream.join.JoinProcessor) AbstractStreamProcessor(org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor) SchedulingProcessor(org.wso2.siddhi.core.query.processor.SchedulingProcessor) AbstractStreamProcessor(org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor) IncrementalAggregateCompileCondition(org.wso2.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition) ComplexEventPopulater(org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater) StreamPreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor) MetaStateEvent(org.wso2.siddhi.core.event.state.MetaStateEvent) SchedulingProcessor(org.wso2.siddhi.core.query.processor.SchedulingProcessor) StreamEventPool(org.wso2.siddhi.core.event.stream.StreamEventPool) StreamEventCloner(org.wso2.siddhi.core.event.stream.StreamEventCloner) JoinProcessor(org.wso2.siddhi.core.query.input.stream.join.JoinProcessor) StateEventCloner(org.wso2.siddhi.core.event.state.StateEventCloner) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent)

Example 2 with StateEventCloner

use of org.wso2.siddhi.core.event.state.StateEventCloner in project siddhi by wso2.

the class WrappedSnapshotOutputRateLimiter method init.

public void init(int outPutAttributeSize, List<AttributeProcessor> attributeProcessorList, MetaComplexEvent metaComplexEvent) {
    for (AttributeProcessor attributeProcessor : attributeProcessorList) {
        if (attributeProcessor.getExpressionExecutor() instanceof AbstractAggregationAttributeExecutor) {
            aggregateAttributePositionList.add(attributeProcessor.getOutputPosition());
        }
    }
    if (windowed) {
        if (groupBy) {
            if (outPutAttributeSize == aggregateAttributePositionList.size()) {
                // All Aggregation
                outputRateLimiter = new AllAggregationGroupByWindowedPerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, this, siddhiAppContext, queryName);
            } else if (aggregateAttributePositionList.size() > 0) {
                // Some Aggregation
                outputRateLimiter = new AggregationGroupByWindowedPerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, aggregateAttributePositionList, this, siddhiAppContext, queryName);
            } else {
                // No aggregation
                // GroupBy is same as Non GroupBy
                outputRateLimiter = new WindowedPerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, this, siddhiAppContext, queryName);
            }
        } else {
            if (outPutAttributeSize == aggregateAttributePositionList.size()) {
                // All Aggregation
                outputRateLimiter = new AllAggregationPerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, this, siddhiAppContext, queryName);
            } else if (aggregateAttributePositionList.size() > 0) {
                // Some Aggregation
                outputRateLimiter = new AggregationWindowedPerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, aggregateAttributePositionList, this, siddhiAppContext, queryName);
            } else {
                // No aggregation
                outputRateLimiter = new WindowedPerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, this, siddhiAppContext, queryName);
            }
        }
    } else {
        if (groupBy) {
            outputRateLimiter = new GroupByPerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, this, siddhiAppContext, queryName);
        } else {
            outputRateLimiter = new PerSnapshotOutputRateLimiter(id, value, scheduledExecutorService, this, siddhiAppContext, queryName);
        }
    }
    if (metaComplexEvent instanceof MetaStateEvent) {
        StateEventPool stateEventPool = new StateEventPool((MetaStateEvent) metaComplexEvent, 5);
        outputRateLimiter.setStateEventCloner(new StateEventCloner((MetaStateEvent) metaComplexEvent, stateEventPool));
    } else {
        StreamEventPool streamEventPool = new StreamEventPool((MetaStreamEvent) metaComplexEvent, 5);
        outputRateLimiter.setStreamEventCloner(new StreamEventCloner((MetaStreamEvent) metaComplexEvent, streamEventPool));
    }
}
Also used : AbstractAggregationAttributeExecutor(org.wso2.siddhi.core.query.selector.attribute.processor.executor.AbstractAggregationAttributeExecutor) StateEventPool(org.wso2.siddhi.core.event.state.StateEventPool) MetaStateEvent(org.wso2.siddhi.core.event.state.MetaStateEvent) StreamEventPool(org.wso2.siddhi.core.event.stream.StreamEventPool) StreamEventCloner(org.wso2.siddhi.core.event.stream.StreamEventCloner) AttributeProcessor(org.wso2.siddhi.core.query.selector.attribute.processor.AttributeProcessor) StateEventCloner(org.wso2.siddhi.core.event.state.StateEventCloner) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent)

Aggregations

MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)2 StateEventCloner (org.wso2.siddhi.core.event.state.StateEventCloner)2 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)2 StreamEventCloner (org.wso2.siddhi.core.event.stream.StreamEventCloner)2 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)2 StateEventPool (org.wso2.siddhi.core.event.state.StateEventPool)1 ComplexEventPopulater (org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater)1 ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)1 JoinProcessor (org.wso2.siddhi.core.query.input.stream.join.JoinProcessor)1 StreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)1 Processor (org.wso2.siddhi.core.query.processor.Processor)1 SchedulingProcessor (org.wso2.siddhi.core.query.processor.SchedulingProcessor)1 AbstractStreamProcessor (org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor)1 AttributeProcessor (org.wso2.siddhi.core.query.selector.attribute.processor.AttributeProcessor)1 AbstractAggregationAttributeExecutor (org.wso2.siddhi.core.query.selector.attribute.processor.executor.AbstractAggregationAttributeExecutor)1 IncrementalAggregateCompileCondition (org.wso2.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition)1