Search in sources :

Example 6 with NextStateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitEvery_sequence_source_chain.

@Override
public Object visitEvery_sequence_source_chain(SiddhiQLParser.Every_sequence_source_chainContext ctx) {
    // every_sequence_source_chain
    // : EVERY? sequence_source  within_time?  ',' sequence_source_chain
    // ;
    StateElement stateElement1;
    if (ctx.EVERY() != null) {
        stateElement1 = new EveryStateElement((StateElement) visit(ctx.sequence_source()));
    } else {
        stateElement1 = (StateElement) visit(ctx.sequence_source());
    }
    if (ctx.within_time() != null) {
        stateElement1.setWithin((TimeConstant) visit(ctx.within_time()));
    }
    populateQueryContext(stateElement1, ctx);
    NextStateElement nextStateElement = new NextStateElement(stateElement1, ((StateElement) visit(ctx.sequence_source_chain())));
    populateQueryContext(nextStateElement, ctx);
    StateInputStream stateInputStream = new StateInputStream(StateInputStream.Type.SEQUENCE, nextStateElement);
    populateQueryContext(stateInputStream, ctx);
    return stateInputStream;
}
Also used : NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) StateInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.StateInputStream) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)

Example 7 with NextStateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitEvery_pattern_source_chain.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitEvery_pattern_source_chain(@NotNull SiddhiQLParser.Every_pattern_source_chainContext ctx) {
    if (ctx.every_pattern_source_chain().size() == 1) {
        // '('every_pattern_source_chain')' within_time?
        StateElement stateElement = ((StateElement) visit(ctx.every_pattern_source_chain(0)));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else if (ctx.every_pattern_source_chain().size() == 2) {
        // every_pattern_source_chain  '->'
        // every_pattern_source_chain
        NextStateElement nextStateElement = new NextStateElement(((StateElement) visit(ctx.every_pattern_source_chain(0))), ((StateElement) visit(ctx.every_pattern_source_chain(1))));
        populateQueryContext(nextStateElement, ctx);
        return nextStateElement;
    } else if (ctx.EVERY() != null) {
        if (ctx.pattern_source_chain() != null) {
            // EVERY '('pattern_source_chain ')' within_time?
            EveryStateElement everyStateElement = new EveryStateElement((StateElement) visit(ctx.pattern_source_chain()));
            if (ctx.within_time() != null) {
                everyStateElement.setWithin((TimeConstant) visit(ctx.within_time()));
            }
            populateQueryContext(everyStateElement, ctx);
            return everyStateElement;
        } else if (ctx.pattern_source() != null) {
            // EVERY pattern_source within_time?
            EveryStateElement everyStateElement = new EveryStateElement((StateElement) visit(ctx.pattern_source()));
            if (ctx.within_time() != null) {
                everyStateElement.setWithin((TimeConstant) visit(ctx.within_time()));
            }
            populateQueryContext(everyStateElement, ctx);
            return everyStateElement;
        } else {
            throw newSiddhiParserException(ctx);
        }
    } else if (ctx.pattern_source_chain() != null) {
        // pattern_source_chain
        StateElement stateElement = ((StateElement) visit(ctx.pattern_source_chain()));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) TimeConstant(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 8 with NextStateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitSequence_source_chain.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public StateElement visitSequence_source_chain(@NotNull SiddhiQLParser.Sequence_source_chainContext ctx) {
    if (ctx.sequence_source_chain().size() == 1) {
        StateElement stateElement = ((StateElement) visit(ctx.sequence_source_chain(0)));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else if (ctx.sequence_source_chain().size() == 2) {
        NextStateElement nextStateElement = new NextStateElement(((StateElement) visit(ctx.sequence_source_chain(0))), ((StateElement) visit(ctx.sequence_source_chain(1))));
        populateQueryContext(nextStateElement, ctx);
        return nextStateElement;
    } else if (ctx.sequence_source() != null) {
        StateElement stateElement = ((StateElement) visit(ctx.sequence_source()));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)

Example 9 with NextStateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitLeft_absent_pattern_source.

@Override
public Object visitLeft_absent_pattern_source(SiddhiQLParser.Left_absent_pattern_sourceContext ctx) {
    if (ctx.left_absent_pattern_source().size() == 1 && ctx.every_absent_pattern_source() == null && ctx.every_pattern_source_chain() == null) {
        // EVERY? '('left_absent_pattern_source')' within_time?
        StateElement stateElement = (StateElement) visit(ctx.left_absent_pattern_source(0));
        if (ctx.EVERY() != null) {
            stateElement = new EveryStateElement(stateElement);
        }
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        NextStateElement nextStateElement = new NextStateElement((StateElement) visit(ctx.getChild(0)), (StateElement) visit(ctx.getChild(2)));
        populateQueryContext(nextStateElement, ctx);
        return nextStateElement;
    }
}
Also used : NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)

Example 10 with NextStateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement in project ballerina by ballerina-lang.

the class StateInputStreamParser method parse.

private static InnerStateRuntime parse(StateElement stateElement, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, MetaStateEvent metaStateEvent, SiddhiAppContext siddhiAppContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, ProcessStreamReceiver> processStreamReceiverMap, StreamPreStateProcessor streamPreStateProcessor, StreamPostStateProcessor streamPostStateProcessor, StateInputStream.Type stateType, ArrayList<Map.Entry<Long, Set<Integer>>> withinStates, LatencyTracker latencyTracker, String queryName) {
    if (stateElement instanceof StreamStateElement) {
        BasicSingleInputStream basicSingleInputStream = ((StreamStateElement) stateElement).getBasicSingleInputStream();
        SingleStreamRuntime singleStreamRuntime = SingleInputStreamParser.parseInputStream(basicSingleInputStream, siddhiAppContext, variableExpressionExecutors, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, processStreamReceiverMap.get(basicSingleInputStream.getUniqueStreamIds().get(0)), false, false, queryName);
        int stateIndex = metaStateEvent.getStreamEventCount() - 1;
        if (streamPreStateProcessor == null) {
            if (stateElement.getWithin() != null) {
                Set<Integer> withinStateset = new HashSet<Integer>();
                withinStateset.add(SiddhiConstants.ANY);
                withinStates.add(0, new AbstractMap.SimpleEntry<Long, Set<Integer>>(stateElement.getWithin().getValue(), withinStateset));
            }
            if (stateElement instanceof AbsentStreamStateElement) {
                AbsentStreamPreStateProcessor absentProcessor = new AbsentStreamPreStateProcessor(stateType, clonewithinStates(withinStates), ((AbsentStreamStateElement) stateElement).getWaitingTime());
                // Set the scheduler
                siddhiAppContext.addEternalReferencedHolder(absentProcessor);
                EntryValveProcessor entryValveProcessor = new EntryValveProcessor(siddhiAppContext);
                entryValveProcessor.setToLast(absentProcessor);
                Scheduler scheduler = SchedulerParser.parse(siddhiAppContext.getScheduledExecutorService(), entryValveProcessor, siddhiAppContext);
                absentProcessor.setScheduler(scheduler);
                // Assign the AbsentStreamPreStateProcessor to streamPreStateProcessor
                streamPreStateProcessor = absentProcessor;
            } else {
                streamPreStateProcessor = new StreamPreStateProcessor(stateType, clonewithinStates(withinStates));
            }
            streamPreStateProcessor.init(siddhiAppContext, queryName);
            if (stateElement.getWithin() != null) {
                withinStates.remove(0);
            }
        }
        streamPreStateProcessor.setStateId(stateIndex);
        streamPreStateProcessor.setNextProcessor(singleStreamRuntime.getProcessorChain());
        singleStreamRuntime.setProcessorChain(streamPreStateProcessor);
        if (streamPostStateProcessor == null) {
            if (stateElement instanceof AbsentStreamStateElement) {
                streamPostStateProcessor = new AbsentStreamPostStateProcessor();
            } else {
                streamPostStateProcessor = new StreamPostStateProcessor();
            }
        }
        streamPostStateProcessor.setStateId(stateIndex);
        singleStreamRuntime.getProcessorChain().setToLast(streamPostStateProcessor);
        streamPostStateProcessor.setThisStatePreProcessor(streamPreStateProcessor);
        streamPreStateProcessor.setThisStatePostProcessor(streamPostStateProcessor);
        streamPreStateProcessor.setThisLastProcessor(streamPostStateProcessor);
        StreamInnerStateRuntime innerStateRuntime = new StreamInnerStateRuntime(stateType);
        innerStateRuntime.setFirstProcessor(streamPreStateProcessor);
        innerStateRuntime.setLastProcessor(streamPostStateProcessor);
        innerStateRuntime.addStreamRuntime(singleStreamRuntime);
        return innerStateRuntime;
    } else if (stateElement instanceof NextStateElement) {
        StateElement currentElement = ((NextStateElement) stateElement).getStateElement();
        InnerStateRuntime currentInnerStateRuntime = parse(currentElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, siddhiAppContext, variableExpressionExecutors, processStreamReceiverMap, streamPreStateProcessor, streamPostStateProcessor, stateType, withinStates, latencyTracker, queryName);
        if (stateElement.getWithin() != null) {
            Set<Integer> withinStateSet = new HashSet<Integer>();
            withinStateSet.add(currentInnerStateRuntime.getFirstProcessor().getStateId());
            withinStateSet.add(currentInnerStateRuntime.getLastProcessor().getStateId());
            withinStates.add(0, new AbstractMap.SimpleEntry<Long, Set<Integer>>(stateElement.getWithin().getValue(), withinStateSet));
        }
        StateElement nextElement = ((NextStateElement) stateElement).getNextStateElement();
        InnerStateRuntime nextInnerStateRuntime = parse(nextElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, siddhiAppContext, variableExpressionExecutors, processStreamReceiverMap, streamPreStateProcessor, streamPostStateProcessor, stateType, withinStates, latencyTracker, queryName);
        if (stateElement.getWithin() != null) {
            withinStates.remove(0);
        }
        // currentInnerStateRuntime.getFirstProcessor().getStateId()
        currentInnerStateRuntime.getLastProcessor().setNextStatePreProcessor(nextInnerStateRuntime.getFirstProcessor());
        NextInnerStateRuntime nextStateRuntime = new NextInnerStateRuntime(currentInnerStateRuntime, nextInnerStateRuntime, stateType);
        nextStateRuntime.setFirstProcessor(currentInnerStateRuntime.getFirstProcessor());
        nextStateRuntime.setLastProcessor(nextInnerStateRuntime.getLastProcessor());
        for (SingleStreamRuntime singleStreamRuntime : currentInnerStateRuntime.getSingleStreamRuntimeList()) {
            nextStateRuntime.addStreamRuntime(singleStreamRuntime);
        }
        for (SingleStreamRuntime singleStreamRuntime : nextInnerStateRuntime.getSingleStreamRuntimeList()) {
            nextStateRuntime.addStreamRuntime(singleStreamRuntime);
        }
        return nextStateRuntime;
    } else if (stateElement instanceof EveryStateElement) {
        StateElement currentElement = ((EveryStateElement) stateElement).getStateElement();
        InnerStateRuntime innerStateRuntime = parse(currentElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, siddhiAppContext, variableExpressionExecutors, processStreamReceiverMap, streamPreStateProcessor, streamPostStateProcessor, stateType, withinStates, latencyTracker, queryName);
        EveryInnerStateRuntime everyInnerStateRuntime = new EveryInnerStateRuntime(innerStateRuntime, stateType);
        everyInnerStateRuntime.setFirstProcessor(innerStateRuntime.getFirstProcessor());
        everyInnerStateRuntime.setLastProcessor(innerStateRuntime.getLastProcessor());
        for (SingleStreamRuntime singleStreamRuntime : innerStateRuntime.getSingleStreamRuntimeList()) {
            everyInnerStateRuntime.addStreamRuntime(singleStreamRuntime);
        }
        everyInnerStateRuntime.getLastProcessor().setNextEveryStatePerProcessor(everyInnerStateRuntime.getFirstProcessor());
        return everyInnerStateRuntime;
    } else if (stateElement instanceof LogicalStateElement) {
        LogicalStateElement.Type type = ((LogicalStateElement) stateElement).getType();
        if (stateElement.getWithin() != null) {
            Set<Integer> withinStateset = new HashSet<Integer>();
            withinStateset.add(SiddhiConstants.ANY);
            withinStates.add(0, new AbstractMap.SimpleEntry<Long, Set<Integer>>(stateElement.getWithin().getValue(), withinStateset));
        }
        LogicalPreStateProcessor logicalPreStateProcessor1;
        if (((LogicalStateElement) stateElement).getStreamStateElement1() instanceof AbsentStreamStateElement) {
            logicalPreStateProcessor1 = new AbsentLogicalPreStateProcessor(type, stateType, clonewithinStates(withinStates), ((AbsentStreamStateElement) ((LogicalStateElement) stateElement).getStreamStateElement1()).getWaitingTime());
            // Set the scheduler
            siddhiAppContext.addEternalReferencedHolder((AbsentLogicalPreStateProcessor) logicalPreStateProcessor1);
            EntryValveProcessor entryValveProcessor = new EntryValveProcessor(siddhiAppContext);
            entryValveProcessor.setToLast(logicalPreStateProcessor1);
            Scheduler scheduler = SchedulerParser.parse(siddhiAppContext.getScheduledExecutorService(), entryValveProcessor, siddhiAppContext);
            ((SchedulingProcessor) logicalPreStateProcessor1).setScheduler(scheduler);
        } else {
            logicalPreStateProcessor1 = new LogicalPreStateProcessor(type, stateType, clonewithinStates(withinStates));
        }
        logicalPreStateProcessor1.init(siddhiAppContext, queryName);
        LogicalPostStateProcessor logicalPostStateProcessor1;
        if (((LogicalStateElement) stateElement).getStreamStateElement1() instanceof AbsentStreamStateElement) {
            logicalPostStateProcessor1 = new AbsentLogicalPostStateProcessor(type);
        } else {
            logicalPostStateProcessor1 = new LogicalPostStateProcessor(type);
        }
        LogicalPreStateProcessor logicalPreStateProcessor2;
        if (((LogicalStateElement) stateElement).getStreamStateElement2() instanceof AbsentStreamStateElement) {
            logicalPreStateProcessor2 = new AbsentLogicalPreStateProcessor(type, stateType, clonewithinStates(withinStates), ((AbsentStreamStateElement) ((LogicalStateElement) stateElement).getStreamStateElement2()).getWaitingTime());
            siddhiAppContext.addEternalReferencedHolder((AbsentLogicalPreStateProcessor) logicalPreStateProcessor2);
            EntryValveProcessor entryValveProcessor = new EntryValveProcessor(siddhiAppContext);
            entryValveProcessor.setToLast(logicalPreStateProcessor2);
            Scheduler scheduler = SchedulerParser.parse(siddhiAppContext.getScheduledExecutorService(), entryValveProcessor, siddhiAppContext);
            ((SchedulingProcessor) logicalPreStateProcessor2).setScheduler(scheduler);
        } else {
            logicalPreStateProcessor2 = new LogicalPreStateProcessor(type, stateType, clonewithinStates(withinStates));
        }
        logicalPreStateProcessor2.init(siddhiAppContext, queryName);
        LogicalPostStateProcessor logicalPostStateProcessor2;
        if (((LogicalStateElement) stateElement).getStreamStateElement2() instanceof AbsentStreamStateElement) {
            logicalPostStateProcessor2 = new AbsentLogicalPostStateProcessor(type);
        } else {
            logicalPostStateProcessor2 = new LogicalPostStateProcessor(type);
        }
        if (stateElement.getWithin() != null) {
            withinStates.remove(0);
        }
        logicalPostStateProcessor1.setPartnerPreStateProcessor(logicalPreStateProcessor2);
        logicalPostStateProcessor2.setPartnerPreStateProcessor(logicalPreStateProcessor1);
        logicalPostStateProcessor1.setPartnerPostStateProcessor(logicalPostStateProcessor2);
        logicalPostStateProcessor2.setPartnerPostStateProcessor(logicalPostStateProcessor1);
        logicalPreStateProcessor1.setPartnerStatePreProcessor(logicalPreStateProcessor2);
        logicalPreStateProcessor2.setPartnerStatePreProcessor(logicalPreStateProcessor1);
        StateElement stateElement2 = ((LogicalStateElement) stateElement).getStreamStateElement2();
        InnerStateRuntime innerStateRuntime2 = parse(stateElement2, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, siddhiAppContext, variableExpressionExecutors, processStreamReceiverMap, logicalPreStateProcessor2, logicalPostStateProcessor2, stateType, withinStates, latencyTracker, queryName);
        StateElement stateElement1 = ((LogicalStateElement) stateElement).getStreamStateElement1();
        InnerStateRuntime innerStateRuntime1 = parse(stateElement1, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, siddhiAppContext, variableExpressionExecutors, processStreamReceiverMap, logicalPreStateProcessor1, logicalPostStateProcessor1, stateType, withinStates, latencyTracker, queryName);
        LogicalInnerStateRuntime logicalInnerStateRuntime = new LogicalInnerStateRuntime(innerStateRuntime1, innerStateRuntime2, stateType);
        logicalInnerStateRuntime.setFirstProcessor(innerStateRuntime1.getFirstProcessor());
        logicalInnerStateRuntime.setLastProcessor(innerStateRuntime2.getLastProcessor());
        for (SingleStreamRuntime singleStreamRuntime : innerStateRuntime2.getSingleStreamRuntimeList()) {
            logicalInnerStateRuntime.addStreamRuntime(singleStreamRuntime);
        }
        for (SingleStreamRuntime singleStreamRuntime : innerStateRuntime1.getSingleStreamRuntimeList()) {
            logicalInnerStateRuntime.addStreamRuntime(singleStreamRuntime);
        }
        return logicalInnerStateRuntime;
    } else if (stateElement instanceof CountStateElement) {
        int minCount = ((CountStateElement) stateElement).getMinCount();
        int maxCount = ((CountStateElement) stateElement).getMaxCount();
        if (minCount == SiddhiConstants.ANY) {
            minCount = 0;
        }
        if (maxCount == SiddhiConstants.ANY) {
            maxCount = Integer.MAX_VALUE;
        }
        if (stateElement.getWithin() != null) {
            Set<Integer> withinStateset = new HashSet<Integer>();
            withinStateset.add(SiddhiConstants.ANY);
            withinStates.add(0, new AbstractMap.SimpleEntry<Long, Set<Integer>>(stateElement.getWithin().getValue(), withinStateset));
        }
        CountPreStateProcessor countPreStateProcessor = new CountPreStateProcessor(minCount, maxCount, stateType, withinStates);
        countPreStateProcessor.init(siddhiAppContext, queryName);
        CountPostStateProcessor countPostStateProcessor = new CountPostStateProcessor(minCount, maxCount);
        if (stateElement.getWithin() != null) {
            withinStates.remove(0);
        }
        countPreStateProcessor.setCountPostStateProcessor(countPostStateProcessor);
        StateElement currentElement = ((CountStateElement) stateElement).getStreamStateElement();
        InnerStateRuntime innerStateRuntime = parse(currentElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, siddhiAppContext, variableExpressionExecutors, processStreamReceiverMap, countPreStateProcessor, countPostStateProcessor, stateType, withinStates, latencyTracker, queryName);
        return new CountInnerStateRuntime((StreamInnerStateRuntime) innerStateRuntime);
    } else {
        throw new OperationNotSupportedException();
    }
}
Also used : CountPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.CountPreStateProcessor) Set(java.util.Set) HashSet(java.util.HashSet) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) Scheduler(org.ballerinalang.siddhi.core.util.Scheduler) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) LogicalStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.LogicalStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) AbsentStreamPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor) StreamPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.StreamPreStateProcessor) LogicalPostStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.LogicalPostStateProcessor) AbsentLogicalPostStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentLogicalPostStateProcessor) EveryInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.EveryInnerStateRuntime) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) AbsentLogicalPostStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentLogicalPostStateProcessor) AbstractMap(java.util.AbstractMap) InnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.InnerStateRuntime) CountInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.CountInnerStateRuntime) LogicalInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.LogicalInnerStateRuntime) StreamInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.StreamInnerStateRuntime) EveryInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.EveryInnerStateRuntime) NextInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.NextInnerStateRuntime) StreamPostStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.StreamPostStateProcessor) AbsentStreamPostStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPostStateProcessor) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) NextInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.NextInnerStateRuntime) LogicalInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.LogicalInnerStateRuntime) LogicalStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.LogicalStateElement) StreamInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.StreamInnerStateRuntime) HashSet(java.util.HashSet) OperationNotSupportedException(org.ballerinalang.siddhi.core.exception.OperationNotSupportedException) CountPostStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.CountPostStateProcessor) SingleStreamRuntime(org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime) CountInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.CountInnerStateRuntime) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) AbsentLogicalPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentLogicalPreStateProcessor) LogicalPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.LogicalPreStateProcessor) AbsentLogicalPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentLogicalPreStateProcessor) AbsentStreamPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) BasicSingleInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) EntryValveProcessor(org.ballerinalang.siddhi.core.query.input.stream.single.EntryValveProcessor) AbsentStreamPostStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPostStateProcessor)

Aggregations

AbsentStreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)10 CountStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement)10 EveryStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)10 NextStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement)10 StateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement)10 StreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)10 StateInputStream (org.ballerinalang.siddhi.query.api.execution.query.input.stream.StateInputStream)2 AbstractMap (java.util.AbstractMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 OperationNotSupportedException (org.ballerinalang.siddhi.core.exception.OperationNotSupportedException)1 EntryValveProcessor (org.ballerinalang.siddhi.core.query.input.stream.single.EntryValveProcessor)1 SingleStreamRuntime (org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime)1 AbsentLogicalPostStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.AbsentLogicalPostStateProcessor)1 AbsentLogicalPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.AbsentLogicalPreStateProcessor)1 AbsentStreamPostStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPostStateProcessor)1 AbsentStreamPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor)1 CountPostStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.CountPostStateProcessor)1 CountPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.CountPreStateProcessor)1 LogicalPostStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.LogicalPostStateProcessor)1