use of io.siddhi.core.event.ComplexEventChunk 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();
}
}
use of io.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class EventChunkOperator method find.
@Override
public StreamEvent find(StateEvent matchingEvent, Object storeEvents, StreamEventCloner storeEventCloner) {
ComplexEventChunk<StreamEvent> storeEventChunk = (ComplexEventChunk<StreamEvent>) storeEvents;
ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<>();
storeEventChunk.reset();
while (storeEventChunk.hasNext()) {
StreamEvent storeEvent = storeEventChunk.next();
matchingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(matchingEvent)) {
returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
}
matchingEvent.setEvent(storeEventPosition, null);
}
return returnEventChunk.getFirst();
}
use of io.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class CacheTable method updateOrAddAndTrimUptoMaxSize.
public void updateOrAddAndTrimUptoMaxSize(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor, int maxTableSize) {
ComplexEventChunk<StateEvent> updateOrAddingEventChunkForCache = new ComplexEventChunk<>();
updateOrAddingEventChunk.reset();
while (updateOrAddingEventChunk.hasNext()) {
StateEvent event = updateOrAddingEventChunk.next();
updateOrAddingEventChunkForCache.add((StateEvent) generateEventWithRequiredFields(event, siddhiAppContext, cacheExpiryEnabled));
}
readWriteLock.writeLock().lock();
TableState state = stateHolder.getState();
try {
InMemoryCompiledCondition inMemoryCompiledCondition = (InMemoryCompiledCondition) compiledCondition;
ComplexEventChunk<StateEvent> failedEvents = ((Operator) inMemoryCompiledCondition.getOperatorCompiledCondition()).tryUpdate(updateOrAddingEventChunkForCache, state.getEventHolder(), (InMemoryCompiledUpdateSet) compiledUpdateSet, addingStreamEventExtractor);
if (failedEvents != null && failedEvents.getFirst() != null) {
state.getEventHolder().add(reduceEventsForUpdateOrInsert(addingStreamEventExtractor, inMemoryCompiledCondition, (InMemoryCompiledUpdateSet) compiledUpdateSet, failedEvents));
}
if (this.size() > maxSize) {
this.deleteEntriesUsingCachePolicy(this.size() - maxSize);
}
} finally {
stateHolder.returnState(state);
readWriteLock.writeLock().unlock();
}
}
use of io.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class StateMultiProcessStreamReceiver method processAndClear.
protected void processAndClear(int processIndex, StreamEvent streamEvent) {
ComplexEventChunk<StateEvent> retEventChunk = new ComplexEventChunk<StateEvent>();
ComplexEventChunk<StreamEvent> currentStreamEventChunk = new ComplexEventChunk<StreamEvent>(streamEvent, streamEvent);
ComplexEventChunk<StateEvent> eventChunk = ((StreamPreStateProcessor) nextProcessors[processIndex]).processAndReturn(currentStreamEventChunk);
if (eventChunk.getFirst() != null) {
retEventChunk.add(eventChunk.getFirst());
}
eventChunk.clear();
if (querySelector != null) {
while (retEventChunk.hasNext()) {
StateEvent stateEvent = retEventChunk.next();
retEventChunk.remove();
querySelector.process(new ComplexEventChunk<StateEvent>(stateEvent, stateEvent));
}
}
}
use of io.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class JoinProcessor method process.
@Override
public void process(List<ComplexEventChunk> complexEventChunks) {
if (trigger) {
List<ComplexEventChunk> returnEventChunkList = new LinkedList<>();
for (ComplexEventChunk streamEventChunk : complexEventChunks) {
execute(streamEventChunk, returnEventChunkList);
}
selector.process(returnEventChunkList);
} else {
if (preJoinProcessor) {
nextProcessor.process(complexEventChunks);
}
}
}
Aggregations