use of io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue in project siddhi by wso2.
the class SnapshotableEventQueueOperator method delete.
@Override
public void delete(ComplexEventChunk<StateEvent> deletingEventChunk, Object storeEvents) {
SnapshotableStreamEventQueue storeEventQueue = (SnapshotableStreamEventQueue) storeEvents;
deletingEventChunk.reset();
while (deletingEventChunk.hasNext()) {
StateEvent deletingEvent = deletingEventChunk.next();
try {
storeEventQueue.reset();
while (storeEventQueue.hasNext()) {
StreamEvent storeEvent = storeEventQueue.next();
deletingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(deletingEvent)) {
storeEventQueue.remove();
}
}
} finally {
deletingEvent.setEvent(storeEventPosition, null);
}
}
}
use of io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue in project siddhi by wso2.
the class SnapshotableEventQueueOperator method contains.
@Override
public boolean contains(StateEvent matchingEvent, Object storeEvents) {
SnapshotableStreamEventQueue storeEventQueue = (SnapshotableStreamEventQueue) storeEvents;
try {
storeEventQueue.reset();
while (storeEventQueue.hasNext()) {
StreamEvent storeEvent = storeEventQueue.next();
matchingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(matchingEvent)) {
return true;
}
}
return false;
} finally {
matchingEvent.setEvent(storeEventPosition, null);
}
}
use of io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue in project siddhi by wso2.
the class SnapshotableEventQueueOperator method update.
@Override
public void update(ComplexEventChunk<StateEvent> updatingEventChunk, Object storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet) {
SnapshotableStreamEventQueue storeEventQueue = (SnapshotableStreamEventQueue) storeEvents;
updatingEventChunk.reset();
while (updatingEventChunk.hasNext()) {
StateEvent updatingEvent = updatingEventChunk.next();
try {
storeEventQueue.reset();
while (storeEventQueue.hasNext()) {
StreamEvent storeEvent = storeEventQueue.next();
updatingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(updatingEvent)) {
for (Map.Entry<Integer, ExpressionExecutor> entry : compiledUpdateSet.getExpressionExecutorMap().entrySet()) {
Object value = entry.getValue().execute(updatingEvent);
storeEvent.setOutputData(value, entry.getKey());
}
storeEventQueue.overwrite(storeEvent);
}
}
} finally {
updatingEvent.setEvent(storeEventPosition, null);
}
}
}
use of io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue in project siddhi by wso2.
the class SnapshotableEventQueueOperator method tryUpdate.
@Override
public ComplexEventChunk<StateEvent> tryUpdate(ComplexEventChunk<StateEvent> updatingOrAddingEventChunk, Object storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor) {
SnapshotableStreamEventQueue storeEventQueue = (SnapshotableStreamEventQueue) storeEvents;
updatingOrAddingEventChunk.reset();
ComplexEventChunk<StateEvent> failedEventChunk = new ComplexEventChunk<>();
while (updatingOrAddingEventChunk.hasNext()) {
StateEvent overwritingOrAddingEvent = updatingOrAddingEventChunk.next();
try {
boolean updated = false;
storeEventQueue.reset();
while (storeEventQueue.hasNext()) {
StreamEvent storeEvent = storeEventQueue.next();
overwritingOrAddingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(overwritingOrAddingEvent)) {
for (Map.Entry<Integer, ExpressionExecutor> entry : compiledUpdateSet.getExpressionExecutorMap().entrySet()) {
storeEvent.setOutputData(entry.getValue().execute(overwritingOrAddingEvent), entry.getKey());
}
storeEventQueue.overwrite(storeEvent);
updated = true;
}
}
if (!updated) {
updatingOrAddingEventChunk.remove();
failedEventChunk.add(overwritingOrAddingEvent);
}
} finally {
overwritingOrAddingEvent.setEvent(storeEventPosition, null);
}
}
return failedEventChunk;
}
use of io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue in project siddhi by wso2.
the class SnapshotableEventQueueOperator method find.
@Override
public StreamEvent find(StateEvent matchingEvent, Object storeEvents, StreamEventCloner storeEventCloner) {
SnapshotableStreamEventQueue storeEventQueue = (SnapshotableStreamEventQueue) storeEvents;
ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<>();
storeEventQueue.reset();
while (storeEventQueue.hasNext()) {
StreamEvent storeEvent = storeEventQueue.next();
matchingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(matchingEvent)) {
returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
}
matchingEvent.setEvent(storeEventPosition, null);
}
return returnEventChunk.getFirst();
}
Aggregations