Search in sources :

Example 11 with MatchingMetaInfoHolder

use of org.ballerinalang.siddhi.core.util.collection.operator.MatchingMetaInfoHolder in project ballerina by ballerina-lang.

the class MatcherParser method constructMatchingMetaStateHolder.

public static MatchingMetaInfoHolder constructMatchingMetaStateHolder(MetaComplexEvent matchingMetaComplexEvent, int defaultStreamEventIndex, AbstractDefinition candsidateDefinition, int currentState) {
    int storeEventIndex = 0;
    MetaStreamEvent tableStreamEvent = new MetaStreamEvent();
    tableStreamEvent.setEventType(MetaStreamEvent.EventType.TABLE);
    tableStreamEvent.addInputDefinition(candsidateDefinition);
    for (Attribute attribute : candsidateDefinition.getAttributeList()) {
        tableStreamEvent.addOutputData(attribute);
    }
    MetaStateEvent metaStateEvent = null;
    if (matchingMetaComplexEvent instanceof MetaStreamEvent) {
        metaStateEvent = new MetaStateEvent(2);
        metaStateEvent.addEvent(((MetaStreamEvent) matchingMetaComplexEvent));
        metaStateEvent.addEvent(tableStreamEvent);
        storeEventIndex = 1;
        defaultStreamEventIndex = 0;
        if (currentState == UNKNOWN_STATE) {
            currentState = defaultStreamEventIndex;
        }
    } else {
        MetaStreamEvent[] metaStreamEvents = ((MetaStateEvent) matchingMetaComplexEvent).getMetaStreamEvents();
        // for join
        for (; storeEventIndex < metaStreamEvents.length; storeEventIndex++) {
            MetaStreamEvent metaStreamEvent = metaStreamEvents[storeEventIndex];
            if (storeEventIndex != defaultStreamEventIndex && metaStreamEvent.getLastInputDefinition().equalsIgnoreAnnotations(candsidateDefinition)) {
                metaStateEvent = ((MetaStateEvent) matchingMetaComplexEvent);
                break;
            }
        }
        if (metaStateEvent == null) {
            metaStateEvent = new MetaStateEvent(metaStreamEvents.length + 1);
            for (MetaStreamEvent metaStreamEvent : metaStreamEvents) {
                metaStateEvent.addEvent(metaStreamEvent);
            }
            metaStateEvent.addEvent(tableStreamEvent);
            storeEventIndex = metaStreamEvents.length;
        }
    }
    return new MatchingMetaInfoHolder(metaStateEvent, defaultStreamEventIndex, storeEventIndex, metaStateEvent.getMetaStreamEvent(defaultStreamEventIndex).getLastInputDefinition(), candsidateDefinition, currentState);
}
Also used : Attribute(org.ballerinalang.siddhi.query.api.definition.Attribute) MatchingMetaInfoHolder(org.ballerinalang.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(org.ballerinalang.siddhi.core.event.state.MetaStateEvent)

Aggregations

MatchingMetaInfoHolder (org.ballerinalang.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)11 MetaStreamEvent (org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)7 CompiledCondition (org.ballerinalang.siddhi.core.util.collection.operator.CompiledCondition)7 MetaStateEvent (org.ballerinalang.siddhi.core.event.state.MetaStateEvent)6 Attribute (org.ballerinalang.siddhi.query.api.definition.Attribute)5 SiddhiAppCreationException (org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException)4 VariableExpressionExecutor (org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor)3 FindStoreQueryRuntime (org.ballerinalang.siddhi.core.query.FindStoreQueryRuntime)3 Table (org.ballerinalang.siddhi.core.table.Table)3 ExpressionExecutor (org.ballerinalang.siddhi.core.executor.ExpressionExecutor)2 AbstractDefinition (org.ballerinalang.siddhi.query.api.definition.AbstractDefinition)2 AttributeFunction (org.ballerinalang.siddhi.query.api.expression.AttributeFunction)2 Expression (org.ballerinalang.siddhi.query.api.expression.Expression)2 Variable (org.ballerinalang.siddhi.query.api.expression.Variable)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ComplexEventChunk (org.ballerinalang.siddhi.core.event.ComplexEventChunk)1 StateEvent (org.ballerinalang.siddhi.core.event.state.StateEvent)1 StateEventPool (org.ballerinalang.siddhi.core.event.state.StateEventPool)1