use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class NotCollectionExecutor method delete.
@Override
public void delete(StateEvent deletingEvent, IndexedEventHolder indexedEventHolder) {
Collection<StreamEvent> notStreamEvents = notCollectionExecutor.findEvents(deletingEvent, indexedEventHolder);
if (notStreamEvents == null) {
exhaustiveCollectionExecutor.delete(deletingEvent, indexedEventHolder);
} else if (notStreamEvents.size() == 0) {
indexedEventHolder.deleteAll();
} else if (notStreamEvents.size() != indexedEventHolder.getAllEvents().size()) {
Collection<StreamEvent> allEvents = indexedEventHolder.getAllEvents();
Set<StreamEvent> returnSet = new HashSet<StreamEvent>();
for (StreamEvent aEvent : allEvents) {
if (!notStreamEvents.contains(aEvent)) {
returnSet.add(aEvent);
}
}
indexedEventHolder.deleteAll(returnSet);
}
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class ConversionStreamEventChunk method convertAndAdd.
public void convertAndAdd(Event event) {
StreamEvent borrowedEvent = streamEventPool.borrowEvent();
streamEventConverter.convertEvent(event, borrowedEvent);
if (first == null) {
first = borrowedEvent;
last = first;
} else {
last.setNext(borrowedEvent);
last = borrowedEvent;
}
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class ConversionStreamEventChunk method convertAndAssign.
// @Override
// public void convertAndAssignFirst(StreamEvent streamEvent) {
// StreamEvent borrowedEvent = streamEventPool.borrowEvent();
// eventConverter.convertComplexEvent(streamEvent, borrowedEvent);
// first = borrowedEvent;
// last = first;
// }
public void convertAndAssign(Event[] events) {
StreamEvent firstEvent = streamEventPool.borrowEvent();
streamEventConverter.convertEvent(events[0], firstEvent);
StreamEvent currentEvent = firstEvent;
for (int i = 1, eventsLength = events.length; i < eventsLength; i++) {
StreamEvent nextEvent = streamEventPool.borrowEvent();
streamEventConverter.convertEvent(events[i], nextEvent);
currentEvent.setNext(nextEvent);
currentEvent = nextEvent;
}
first = firstEvent;
last = currentEvent;
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class ConversionStreamEventChunk method convertAndAssign.
public void convertAndAssign(long timestamp, Object[] data) {
StreamEvent borrowedEvent = streamEventPool.borrowEvent();
streamEventConverter.convertData(timestamp, data, borrowedEvent);
first = borrowedEvent;
last = first;
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEvent in project ballerina by ballerina-lang.
the class StateEvent method getStreamEvent.
public StreamEvent getStreamEvent(int[] position) {
StreamEvent streamEvent = streamEvents[position[STREAM_EVENT_CHAIN_INDEX]];
if (streamEvent == null) {
return null;
}
int streamEventIndex = position[STREAM_EVENT_INDEX_IN_CHAIN];
if (streamEventIndex >= 0) {
for (int i = 1; i <= position[STREAM_EVENT_INDEX_IN_CHAIN]; i++) {
streamEvent = streamEvent.getNext();
if (streamEvent == null) {
return null;
}
}
} else if (streamEventIndex == CURRENT) {
while (streamEvent.getNext() != null) {
streamEvent = streamEvent.getNext();
}
} else if (streamEventIndex == LAST) {
if (streamEvent.getNext() == null) {
return null;
}
while (streamEvent.getNext().getNext() != null) {
streamEvent = streamEvent.getNext();
}
} else {
List<StreamEvent> stateEventList = new ArrayList<StreamEvent>();
while (streamEvent != null) {
stateEventList.add(streamEvent);
streamEvent = streamEvent.getNext();
}
int index = stateEventList.size() + streamEventIndex;
if (index < 0) {
return null;
} else {
streamEvent = stateEventList.get(index);
}
}
return streamEvent;
}
Aggregations