Search in sources :

Example 91 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class ExhaustiveCollectionExecutor method findEvents.

public Collection<StreamEvent> findEvents(StateEvent matchingEvent, Collection<StreamEvent> preProcessedstoreEvents) {
    HashSet<StreamEvent> streamEvents = new HashSet<StreamEvent>();
    for (StreamEvent storeEvent : preProcessedstoreEvents) {
        matchingEvent.setEvent(storeEventIndex, storeEvent);
        if ((Boolean) expressionExecutor.execute(matchingEvent)) {
            streamEvents.add(storeEvent);
        }
        matchingEvent.setEvent(storeEventIndex, null);
    }
    return streamEvents;
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent) HashSet(java.util.HashSet)

Example 92 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class ExhaustiveCollectionExecutor method delete.

@Override
public void delete(StateEvent deletingEvent, IndexedEventHolder indexedEventHolder) {
    Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
    Set<StreamEvent> toDeleteEvents = new HashSet<StreamEvent>();
    for (StreamEvent storeEvent : storeEvents) {
        deletingEvent.setEvent(storeEventIndex, storeEvent);
        if ((Boolean) expressionExecutor.execute(deletingEvent)) {
            toDeleteEvents.add(storeEvent);
        }
        deletingEvent.setEvent(storeEventIndex, null);
    }
    indexedEventHolder.deleteAll(toDeleteEvents);
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent) HashSet(java.util.HashSet)

Example 93 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class OnDemandQueryRuntimeUtil method executeSelector.

public static Event[] executeSelector(StateEventFactory stateEventFactory, StreamEvent streamEvent, StreamEvent storeEvents, int storeEventIndex, QuerySelector selector) {
    ComplexEventChunk outputComplexEventChunk = executeSelectorAndReturnChunk(stateEventFactory, streamEvent, storeEvents, storeEventIndex, selector);
    if (outputComplexEventChunk != null) {
        List<Event> events = new ArrayList<>();
        outputComplexEventChunk.reset();
        while (outputComplexEventChunk.hasNext()) {
            ComplexEvent complexEvent = outputComplexEventChunk.next();
            events.add(new Event(complexEvent.getTimestamp(), complexEvent.getOutputData()));
        }
        return events.toArray(new Event[0]);
    } else {
        return null;
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) ArrayList(java.util.ArrayList) Event(io.siddhi.core.event.Event) ComplexEvent(io.siddhi.core.event.ComplexEvent) StateEvent(io.siddhi.core.event.state.StateEvent) StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Example 94 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class OnDemandQueryRuntimeUtil method executeSelectorAndReturnChunk.

private static ComplexEventChunk executeSelectorAndReturnChunk(StateEventFactory stateEventFactory, StreamEvent streamEvent, StreamEvent storeEvents, int storeEventIndex, QuerySelector selector) {
    ComplexEventChunk<StateEvent> complexEventChunk = new ComplexEventChunk<>();
    while (storeEvents != null) {
        StreamEvent storeEvent = storeEvents;
        storeEvents = storeEvents.getNext();
        storeEvent.setNext(null);
        StateEvent joinEvent = stateEventFactory.newInstance();
        if (streamEvent == null) {
            joinEvent.addEvent(storeEventIndex, storeEvent);
        } else {
            joinEvent.addEvent(0, streamEvent);
            joinEvent.addEvent(1, storeEvent);
        }
        complexEventChunk.add(joinEvent);
    }
    return selector.execute(complexEventChunk);
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent) StateEvent(io.siddhi.core.event.state.StateEvent)

Example 95 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent 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)

Aggregations

StreamEvent (io.siddhi.core.event.stream.StreamEvent)203 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)92 ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)74 StateEvent (io.siddhi.core.event.state.StateEvent)52 ComplexEvent (io.siddhi.core.event.ComplexEvent)33 ArrayList (java.util.ArrayList)27 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)26 Map (java.util.Map)24 Event (io.siddhi.core.event.Event)23 Test (org.testng.annotations.Test)23 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)20 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)18 Attribute (io.siddhi.query.api.definition.Attribute)17 HashMap (java.util.HashMap)17 Operation (io.siddhi.core.event.stream.Operation)12 LinkedList (java.util.LinkedList)12 SnapshotableStreamEventQueue (io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue)11 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)10 HashSet (java.util.HashSet)10 StreamEventConverter (io.siddhi.core.event.stream.converter.StreamEventConverter)8