Search in sources :

Example 1 with EventVariableFunctionExecutor

use of io.siddhi.core.executor.EventVariableFunctionExecutor in project siddhi by wso2.

the class ExpressionParser method constructEventExpressionExecutor.

private static ExpressionExecutor constructEventExpressionExecutor(Variable variable, int currentState, SiddhiQueryContext siddhiQueryContext, int[] eventPosition, MetaStateEvent metaStateEvent) {
    AbstractDefinition definition;
    MetaStreamEvent[] metaStreamEvents = metaStateEvent.getMetaStreamEvents();
    for (int i = 0, metaStreamEventsLength = metaStreamEvents.length; i < metaStreamEventsLength; i++) {
        MetaStreamEvent metaStreamEvent = metaStreamEvents[i];
        definition = metaStreamEvent.getLastInputDefinition();
        if (metaStreamEvent.getInputReferenceId() == null) {
            if (definition.getId().equals(variable.getAttributeName())) {
                eventPosition[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX] = i;
                FunctionExecutor functionExecutor = new EventVariableFunctionExecutor(eventPosition[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX], eventPosition[SiddhiConstants.STREAM_EVENT_INDEX_IN_CHAIN]);
                functionExecutor.initExecutor(new ExpressionExecutor[0], ProcessingMode.BATCH, null, false, siddhiQueryContext);
                return functionExecutor;
            }
        } else {
            if (metaStreamEvent.getInputReferenceId().equals(variable.getAttributeName())) {
                eventPosition[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX] = i;
                if (currentState > -1 && metaStreamEvents[currentState].getInputReferenceId() != null && variable.getStreamIndex() != null && variable.getStreamIndex() <= SiddhiConstants.LAST) {
                    if (variable.getAttributeName().equals(metaStreamEvents[currentState].getInputReferenceId())) {
                        eventPosition[SiddhiConstants.STREAM_EVENT_INDEX_IN_CHAIN] = variable.getStreamIndex();
                    }
                }
                FunctionExecutor functionExecutor = new EventVariableFunctionExecutor(eventPosition[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX], eventPosition[SiddhiConstants.STREAM_EVENT_INDEX_IN_CHAIN]);
                functionExecutor.initExecutor(new ExpressionExecutor[0], ProcessingMode.BATCH, null, false, siddhiQueryContext);
                return functionExecutor;
            }
        }
    }
    return null;
}
Also used : FunctionExecutor(io.siddhi.core.executor.function.FunctionExecutor) EventVariableFunctionExecutor(io.siddhi.core.executor.EventVariableFunctionExecutor) MultiValueVariableFunctionExecutor(io.siddhi.core.executor.MultiValueVariableFunctionExecutor) ScriptFunctionExecutor(io.siddhi.core.executor.function.ScriptFunctionExecutor) EventVariableFunctionExecutor(io.siddhi.core.executor.EventVariableFunctionExecutor) AbstractDefinition(io.siddhi.query.api.definition.AbstractDefinition) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Aggregations

MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)1 EventVariableFunctionExecutor (io.siddhi.core.executor.EventVariableFunctionExecutor)1 MultiValueVariableFunctionExecutor (io.siddhi.core.executor.MultiValueVariableFunctionExecutor)1 FunctionExecutor (io.siddhi.core.executor.function.FunctionExecutor)1 ScriptFunctionExecutor (io.siddhi.core.executor.function.ScriptFunctionExecutor)1 AbstractDefinition (io.siddhi.query.api.definition.AbstractDefinition)1