Search in sources :

Example 6 with ComplexEvent

use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.

the class SnapshotOutputRateLimiter method sendToCallBacks.

protected void sendToCallBacks(List<ComplexEventChunk> outputEventChunks) {
    if (!outputEventChunks.isEmpty()) {
        ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<>();
        for (ComplexEventChunk eventChunk : outputEventChunks) {
            outputEventChunk.addAll(eventChunk);
        }
        wrappedSnapshotOutputRateLimiter.passToCallBacks(outputEventChunk);
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk)

Example 7 with ComplexEvent

use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.

the class FirstGroupByPerTimeOutputRateLimiter method process.

@Override
public void process(ComplexEventChunk complexEventChunk) {
    ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<>();
    complexEventChunk.reset();
    RateLimiterState state = stateHolder.getState();
    try {
        synchronized (state) {
            long currentTime = siddhiQueryContext.getSiddhiAppContext().getTimestampGenerator().currentTime();
            while (complexEventChunk.hasNext()) {
                ComplexEvent event = complexEventChunk.next();
                complexEventChunk.remove();
                GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
                Long outputTime = state.groupByOutputTime.get(groupedComplexEvent.getGroupKey());
                if (outputTime == null || outputTime + value <= currentTime) {
                    state.groupByOutputTime.put(groupedComplexEvent.getGroupKey(), currentTime);
                    outputEventChunk.add(groupedComplexEvent);
                }
            }
        }
    } finally {
        stateHolder.returnState(state);
    }
    outputEventChunk.reset();
    if (outputEventChunk.hasNext()) {
        sendToCallBacks(outputEventChunk);
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) GroupedComplexEvent(io.siddhi.core.event.GroupedComplexEvent) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) GroupedComplexEvent(io.siddhi.core.event.GroupedComplexEvent)

Example 8 with ComplexEvent

use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.

the class FilterProcessor method process.

@Override
public void process(ComplexEventChunk complexEventChunk) {
    complexEventChunk.reset();
    while (complexEventChunk.hasNext()) {
        ComplexEvent complexEvent = complexEventChunk.next();
        Object result = conditionExecutor.execute(complexEvent);
        if (result == null || !(Boolean) result) {
            complexEventChunk.remove();
        }
    }
    if (complexEventChunk.getFirst() != null) {
        this.next.process(complexEventChunk);
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent)

Example 9 with ComplexEvent

use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.

the class QuerySelector method executePassThrough.

private ComplexEventChunk executePassThrough(ComplexEventChunk complexEventChunk) {
    complexEventChunk.reset();
    synchronized (this) {
        while (complexEventChunk.hasNext()) {
            ComplexEvent event = complexEventChunk.next();
            if (((event.getType() != StreamEvent.Type.CURRENT || !currentOn) && (event.getType() != StreamEvent.Type.EXPIRED || !expiredOn))) {
                complexEventChunk.remove();
            }
        }
    }
    complexEventChunk.reset();
    if (complexEventChunk.hasNext()) {
        return complexEventChunk;
    }
    return null;
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) GroupedComplexEvent(io.siddhi.core.event.GroupedComplexEvent)

Example 10 with ComplexEvent

use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.

the class QuerySelector method offsetEventChunk.

private void offsetEventChunk(ComplexEventChunk complexEventChunk) {
    complexEventChunk.reset();
    int offsetCount = 0;
    while (complexEventChunk.hasNext()) {
        ComplexEvent event = complexEventChunk.next();
        if (event.getType() == StreamEvent.Type.CURRENT || event.getType() == StreamEvent.Type.EXPIRED) {
            if (offset > offsetCount) {
                if ((event.getType() == StreamEvent.Type.CURRENT && currentOn) || (event.getType() == StreamEvent.Type.EXPIRED && expiredOn)) {
                    offsetCount++;
                }
                complexEventChunk.remove();
            } else {
                break;
            }
        }
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) GroupedComplexEvent(io.siddhi.core.event.GroupedComplexEvent)

Aggregations

ComplexEvent (io.siddhi.core.event.ComplexEvent)75 ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)41 StreamEvent (io.siddhi.core.event.stream.StreamEvent)34 GroupedComplexEvent (io.siddhi.core.event.GroupedComplexEvent)19 Event (io.siddhi.core.event.Event)16 SiddhiAppRuntime (io.siddhi.core.SiddhiAppRuntime)13 SiddhiManager (io.siddhi.core.SiddhiManager)13 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)13 StreamCallback (io.siddhi.core.stream.output.StreamCallback)13 StateEvent (io.siddhi.core.event.state.StateEvent)12 InputHandler (io.siddhi.core.stream.input.InputHandler)12 Test (org.testng.annotations.Test)12 LinkedList (java.util.LinkedList)8 AttributeProcessor (io.siddhi.core.query.selector.attribute.processor.AttributeProcessor)4 ArrayList (java.util.ArrayList)4 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)3 Map (java.util.Map)3 SiddhiAppRuntimeException (io.siddhi.core.exception.SiddhiAppRuntimeException)2 Iterator (java.util.Iterator)2 Operation (io.siddhi.core.event.stream.Operation)1