use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class IndexOperator method update.
@Override
public void update(ComplexEventChunk<StateEvent> updatingEventChunk, Object storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet) {
updatingEventChunk.reset();
while (updatingEventChunk.hasNext()) {
StateEvent updatingEvent = updatingEventChunk.next();
StreamEvent streamEvents = collectionExecutor.find(updatingEvent, (IndexedEventHolder) storeEvents, null);
if (streamEvents != null) {
ComplexEventChunk<StreamEvent> foundEventChunk = new ComplexEventChunk<>(false);
foundEventChunk.add(streamEvents);
update((IndexedEventHolder) storeEvents, compiledUpdateSet, updatingEvent, foundEventChunk);
}
}
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class CompareCollectionExecutor method find.
public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
if (storeEventSet == null) {
// triggering sequential scan
Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
for (StreamEvent storeEvent : storeEvents) {
matchingEvent.setEvent(storeEventIndex, storeEvent);
if ((Boolean) expressionExecutor.execute(matchingEvent)) {
if (storeEventCloner != null) {
returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
} else {
returnEventChunk.add(storeEvent);
}
}
matchingEvent.setEvent(storeEventIndex, null);
}
return returnEventChunk.getFirst();
} else {
for (StreamEvent storeEvent : storeEventSet) {
if (storeEventCloner != null) {
returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
} else {
returnEventChunk.add(storeEvent);
}
}
return returnEventChunk.getFirst();
}
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
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 org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
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 org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class NonCollectionExecutor method find.
public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
if ((Boolean) expressionExecutor.execute(matchingEvent)) {
ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
for (StreamEvent storeEvent : storeEvents) {
if (storeEventCloner != null) {
returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
} else {
returnEventChunk.add(storeEvent);
}
}
return returnEventChunk.getFirst();
} else {
return null;
}
}
Aggregations