Search in sources :

Example 56 with ComplexEventChunk

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

the class AndMultiPrimaryKeyCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>();
    Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
    if (storeEventSet == null) {
        return returnEventChunk.getFirst();
    } else {
        for (StreamEvent storeEvent : storeEventSet) {
            if (cacheTable != null) {
                cacheTable.updateCachePolicyAttribute(storeEvent);
            }
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    }
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Example 57 with ComplexEventChunk

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

the class EventChunkOperator method find.

@Override
public StreamEvent find(StateEvent matchingEvent, Object storeEvents, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> storeEventChunk = (ComplexEventChunk<StreamEvent>) storeEvents;
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<>();
    storeEventChunk.reset();
    while (storeEventChunk.hasNext()) {
        StreamEvent storeEvent = storeEventChunk.next();
        matchingEvent.setEvent(storeEventPosition, storeEvent);
        if ((Boolean) expressionExecutor.execute(matchingEvent)) {
            returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
        }
        matchingEvent.setEvent(storeEventPosition, null);
    }
    return returnEventChunk.getFirst();
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Example 58 with ComplexEventChunk

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

the class CacheTable method updateOrAddAndTrimUptoMaxSize.

public void updateOrAddAndTrimUptoMaxSize(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor, int maxTableSize) {
    ComplexEventChunk<StateEvent> updateOrAddingEventChunkForCache = new ComplexEventChunk<>();
    updateOrAddingEventChunk.reset();
    while (updateOrAddingEventChunk.hasNext()) {
        StateEvent event = updateOrAddingEventChunk.next();
        updateOrAddingEventChunkForCache.add((StateEvent) generateEventWithRequiredFields(event, siddhiAppContext, cacheExpiryEnabled));
    }
    readWriteLock.writeLock().lock();
    TableState state = stateHolder.getState();
    try {
        InMemoryCompiledCondition inMemoryCompiledCondition = (InMemoryCompiledCondition) compiledCondition;
        ComplexEventChunk<StateEvent> failedEvents = ((Operator) inMemoryCompiledCondition.getOperatorCompiledCondition()).tryUpdate(updateOrAddingEventChunkForCache, state.getEventHolder(), (InMemoryCompiledUpdateSet) compiledUpdateSet, addingStreamEventExtractor);
        if (failedEvents != null && failedEvents.getFirst() != null) {
            state.getEventHolder().add(reduceEventsForUpdateOrInsert(addingStreamEventExtractor, inMemoryCompiledCondition, (InMemoryCompiledUpdateSet) compiledUpdateSet, failedEvents));
        }
        if (this.size() > maxSize) {
            this.deleteEntriesUsingCachePolicy(this.size() - maxSize);
        }
    } finally {
        stateHolder.returnState(state);
        readWriteLock.writeLock().unlock();
    }
}
Also used : Operator(io.siddhi.core.util.collection.operator.Operator) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) StateEvent(io.siddhi.core.event.state.StateEvent)

Example 59 with ComplexEventChunk

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

the class StateMultiProcessStreamReceiver method processAndClear.

protected void processAndClear(int processIndex, StreamEvent streamEvent) {
    ComplexEventChunk<StateEvent> retEventChunk = new ComplexEventChunk<StateEvent>();
    ComplexEventChunk<StreamEvent> currentStreamEventChunk = new ComplexEventChunk<StreamEvent>(streamEvent, streamEvent);
    ComplexEventChunk<StateEvent> eventChunk = ((StreamPreStateProcessor) nextProcessors[processIndex]).processAndReturn(currentStreamEventChunk);
    if (eventChunk.getFirst() != null) {
        retEventChunk.add(eventChunk.getFirst());
    }
    eventChunk.clear();
    if (querySelector != null) {
        while (retEventChunk.hasNext()) {
            StateEvent stateEvent = retEventChunk.next();
            retEventChunk.remove();
            querySelector.process(new ComplexEventChunk<StateEvent>(stateEvent, stateEvent));
        }
    }
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent) StateEvent(io.siddhi.core.event.state.StateEvent) StreamPreStateProcessor(io.siddhi.core.query.input.stream.state.StreamPreStateProcessor)

Example 60 with ComplexEventChunk

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

the class JoinProcessor method process.

@Override
public void process(List<ComplexEventChunk> complexEventChunks) {
    if (trigger) {
        List<ComplexEventChunk> returnEventChunkList = new LinkedList<>();
        for (ComplexEventChunk streamEventChunk : complexEventChunks) {
            execute(streamEventChunk, returnEventChunkList);
        }
        selector.process(returnEventChunkList);
    } else {
        if (preJoinProcessor) {
            nextProcessor.process(complexEventChunks);
        }
    }
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) SelectorTypeComplexEventChunk(io.siddhi.core.query.selector.SelectorTypeComplexEventChunk) LinkedList(java.util.LinkedList)

Aggregations

ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)114 StreamEvent (io.siddhi.core.event.stream.StreamEvent)75 ComplexEvent (io.siddhi.core.event.ComplexEvent)41 StateEvent (io.siddhi.core.event.state.StateEvent)38 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)34 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)14 GroupedComplexEvent (io.siddhi.core.event.GroupedComplexEvent)13 LinkedList (java.util.LinkedList)12 Map (java.util.Map)12 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)10 ArrayList (java.util.ArrayList)10 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)7 HashMap (java.util.HashMap)7 Attribute (io.siddhi.query.api.definition.Attribute)5 Event (io.siddhi.core.event.Event)4 TimePeriod (io.siddhi.query.api.aggregation.TimePeriod)4 SnapshotableStreamEventQueue (io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue)3 SiddhiAppRuntimeException (io.siddhi.core.exception.SiddhiAppRuntimeException)3 Table (io.siddhi.core.table.Table)3 ConstantExpressionExecutor (io.siddhi.core.executor.ConstantExpressionExecutor)2