use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class EventChunkOperator method update.
@Override
public void update(ComplexEventChunk<StateEvent> updatingEventChunk, Object storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet) {
ComplexEventChunk<StreamEvent> storeEventChunk = (ComplexEventChunk<StreamEvent>) storeEvents;
updatingEventChunk.reset();
while (updatingEventChunk.hasNext()) {
StateEvent updatingEvent = updatingEventChunk.next();
try {
storeEventChunk.reset();
while (storeEventChunk.hasNext()) {
StreamEvent storeEvent = storeEventChunk.next();
updatingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(updatingEvent)) {
for (Map.Entry<Integer, ExpressionExecutor> entry : compiledUpdateSet.getExpressionExecutorMap().entrySet()) {
storeEvent.setOutputData(entry.getValue().execute(updatingEvent), entry.getKey());
}
}
}
} finally {
updatingEvent.setEvent(storeEventPosition, null);
}
}
}
use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class EventChunkOperator method contains.
@Override
public boolean contains(StateEvent matchingEvent, Object storeEvents) {
ComplexEventChunk<StreamEvent> storeEventChunk = (ComplexEventChunk<StreamEvent>) storeEvents;
try {
storeEventChunk.reset();
while (storeEventChunk.hasNext()) {
StreamEvent storeEvent = storeEventChunk.next();
matchingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(matchingEvent)) {
return true;
}
}
return false;
} finally {
matchingEvent.setEvent(storeEventPosition, null);
}
}
use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class IncrementalAggregateCompileCondition method createAggregateSelectionEventChunk.
private ComplexEventChunk<StreamEvent> createAggregateSelectionEventChunk(ComplexEventChunk<StreamEvent> complexEventChunkToHoldMatches, List<ExpressionExecutor> outputExpressionExecutors) {
ComplexEventChunk<StreamEvent> aggregateSelectionComplexEventChunk = new ComplexEventChunk<>(true);
StreamEvent resetEvent = streamEventPoolForTableMeta.borrowEvent();
resetEvent.setType(ComplexEvent.Type.RESET);
while (complexEventChunkToHoldMatches.hasNext()) {
StreamEvent streamEvent = complexEventChunkToHoldMatches.next();
StreamEvent newStreamEvent = streamEventPoolForAggregateMeta.borrowEvent();
Object[] outputData = new Object[newStreamEvent.getOutputData().length];
for (int i = 0; i < outputExpressionExecutors.size(); i++) {
outputData[i] = outputExpressionExecutors.get(i).execute(streamEvent);
}
newStreamEvent.setTimestamp(streamEvent.getTimestamp());
newStreamEvent.setOutputData(outputData);
aggregateSelectionComplexEventChunk.add(newStreamEvent);
}
for (ExpressionExecutor expressionExecutor : outputExpressionExecutors) {
expressionExecutor.execute(resetEvent);
}
return aggregateSelectionComplexEventChunk;
}
use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
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.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class AnyAndCollectionExecutor method find.
public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
Collection<StreamEvent> resultEventSet = findEvents(matchingEvent, indexedEventHolder);
ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
if (resultEventSet != null) {
for (StreamEvent resultEvent : resultEventSet) {
if (storeEventCloner != null) {
returnEventChunk.add(storeEventCloner.copyStreamEvent(resultEvent));
} else {
returnEventChunk.add(resultEvent);
}
}
return returnEventChunk.getFirst();
} else {
return exhaustiveCollectionExecutor.find(matchingEvent, indexedEventHolder, storeEventCloner);
}
}
Aggregations