Search in sources :

Example 1 with IncrementalUnixTimeFunctionExecutor

use of io.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor in project siddhi by wso2.

the class IncrementalAggregationProcessor method process.

@Override
public void process(ComplexEventChunk complexEventChunk) {
    ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<>();
    try {
        int noOfEvents = 0;
        if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            latencyTrackerInsert.markIn();
        }
        while (complexEventChunk.hasNext()) {
            ComplexEvent complexEvent = complexEventChunk.next();
            if (!isFirstEventArrived) {
                aggregationRuntime.initialiseExecutors(true);
                isFirstEventArrived = true;
            }
            StreamEvent newEvent = streamEventFactory.newInstance();
            for (int i = 0; i < incomingExpressionExecutors.size(); i++) {
                ExpressionExecutor expressionExecutor = incomingExpressionExecutors.get(i);
                Object outputData = expressionExecutor.execute(complexEvent);
                if (expressionExecutor instanceof IncrementalUnixTimeFunctionExecutor && outputData == null) {
                    throw new SiddhiAppRuntimeException("Cannot retrieve the timestamp of event");
                }
                newEvent.setOutputData(outputData, i);
            }
            streamEventChunk.add(newEvent);
            noOfEvents++;
        }
        aggregationRuntime.processEvents(streamEventChunk);
        if (throughputTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            throughputTrackerInsert.eventsIn(noOfEvents);
        }
    } finally {
        if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            latencyTrackerInsert.markOut();
        }
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) ExpressionExecutor(io.siddhi.core.executor.ExpressionExecutor) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException) IncrementalUnixTimeFunctionExecutor(io.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor)

Example 2 with IncrementalUnixTimeFunctionExecutor

use of io.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor in project siddhi by siddhi-io.

the class IncrementalAggregationProcessor method process.

@Override
public void process(ComplexEventChunk complexEventChunk) {
    ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<>();
    try {
        int noOfEvents = 0;
        if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            latencyTrackerInsert.markIn();
        }
        while (complexEventChunk.hasNext()) {
            ComplexEvent complexEvent = complexEventChunk.next();
            if (!isFirstEventArrived) {
                aggregationRuntime.initialiseExecutors(true);
                isFirstEventArrived = true;
            }
            StreamEvent newEvent = streamEventFactory.newInstance();
            for (int i = 0; i < incomingExpressionExecutors.size(); i++) {
                ExpressionExecutor expressionExecutor = incomingExpressionExecutors.get(i);
                Object outputData = expressionExecutor.execute(complexEvent);
                if (expressionExecutor instanceof IncrementalUnixTimeFunctionExecutor && outputData == null) {
                    throw new SiddhiAppRuntimeException("Cannot retrieve the timestamp of event");
                }
                newEvent.setOutputData(outputData, i);
            }
            streamEventChunk.add(newEvent);
            noOfEvents++;
        }
        aggregationRuntime.processEvents(streamEventChunk);
        if (throughputTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            throughputTrackerInsert.eventsIn(noOfEvents);
        }
    } finally {
        if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            latencyTrackerInsert.markOut();
        }
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) ExpressionExecutor(io.siddhi.core.executor.ExpressionExecutor) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException) IncrementalUnixTimeFunctionExecutor(io.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor)

Aggregations

ComplexEvent (io.siddhi.core.event.ComplexEvent)2 ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)2 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)2 StreamEvent (io.siddhi.core.event.stream.StreamEvent)2 SiddhiAppRuntimeException (io.siddhi.core.exception.SiddhiAppRuntimeException)2 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)2 IncrementalUnixTimeFunctionExecutor (io.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor)2