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;
}
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);
}
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;
}
}
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);
}
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();
}
}
Aggregations