use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class CountPreStateProcessor method processAndReturn.
@Override
public ComplexEventChunk<StateEvent> processAndReturn(ComplexEventChunk complexEventChunk) {
ComplexEventChunk<StateEvent> returnEventChunk = new ComplexEventChunk<StateEvent>();
complexEventChunk.reset();
// Sure only one will be sent
StreamEvent streamEvent = (StreamEvent) complexEventChunk.next();
CountStreamPreState state = (CountStreamPreState) stateHolder.getState();
lock.lock();
try {
for (Iterator<StateEvent> iterator = state.getPendingStateEventList().iterator(); iterator.hasNext(); ) {
StateEvent stateEvent = iterator.next();
if (removeIfNextStateProcessed(stateEvent, iterator, stateId + 1)) {
continue;
}
if (removeIfNextStateProcessed(stateEvent, iterator, stateId + 2)) {
continue;
}
stateEvent.addEvent(stateId, streamEventCloner.copyStreamEvent(streamEvent));
state.successCondition = false;
process(stateEvent);
if (this.thisLastProcessor.isEventReturned()) {
this.thisLastProcessor.clearProcessedEvent();
returnEventChunk.add(stateEvent);
}
if (state.isStateChanged()) {
iterator.remove();
}
if (!state.successCondition) {
switch(stateType) {
case PATTERN:
stateEvent.removeLastEvent(stateId);
break;
case SEQUENCE:
stateEvent.removeLastEvent(stateId);
iterator.remove();
break;
}
}
}
} finally {
lock.unlock();
stateHolder.returnState(state);
}
return returnEventChunk;
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class StreamPostStateProcessor method process.
protected void process(StateEvent stateEvent, ComplexEventChunk complexEventChunk) {
thisStatePreProcessor.stateChanged();
StreamEvent streamEvent = stateEvent.getStreamEvent(stateId);
stateEvent.setTimestamp(streamEvent.getTimestamp());
if (nextProcessor != null) {
complexEventChunk.reset();
this.isEventReturned = true;
}
if (nextStatePreProcessor != null) {
nextStatePreProcessor.addState(stateEvent);
}
if (nextEveryStatePreProcessor != null) {
nextEveryStatePreProcessor.addEveryState(stateEvent);
}
if (callbackPreStateProcessor != null) {
callbackPreStateProcessor.startStateReset();
}
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class AbsentLogicalPostStateProcessor method process.
protected void process(StateEvent stateEvent, ComplexEventChunk complexEventChunk) {
// Mark the state changed
thisStatePreProcessor.stateChanged();
// Update the timestamp
StreamEvent streamEvent = stateEvent.getStreamEvent(stateId);
// This is the notification to AbsentStreamPreStateProcessor that this event has been processed
this.isEventReturned = true;
((AbsentPreStateProcessor) thisStatePreProcessor).updateLastArrivalTime(streamEvent.getTimestamp());
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class DeleteOnDemandQueryRuntime method generateResetComplexEventChunk.
private ComplexEventChunk<ComplexEvent> generateResetComplexEventChunk(MetaStreamEvent metaStreamEvent) {
StreamEvent streamEvent = new StreamEvent(metaStreamEvent.getBeforeWindowData().size(), metaStreamEvent.getOnAfterWindowData().size(), metaStreamEvent.getOutputData().size());
streamEvent.setType(ComplexEvent.Type.RESET);
StateEvent stateEvent = stateEventFactory.newInstance();
stateEvent.addEvent(0, streamEvent);
stateEvent.setType(ComplexEvent.Type.RESET);
ComplexEventChunk<ComplexEvent> complexEventChunk = new ComplexEventChunk<>();
complexEventChunk.add(stateEvent);
return complexEventChunk;
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class InsertOnDemandQueryRuntime method generateResetComplexEventChunk.
private ComplexEventChunk<ComplexEvent> generateResetComplexEventChunk(MetaStreamEvent metaStreamEvent) {
StreamEvent streamEvent = new StreamEvent(metaStreamEvent.getBeforeWindowData().size(), metaStreamEvent.getOnAfterWindowData().size(), metaStreamEvent.getOutputData().size());
streamEvent.setType(ComplexEvent.Type.RESET);
StateEvent stateEvent = stateEventFactory.newInstance();
stateEvent.addEvent(0, streamEvent);
stateEvent.setType(ComplexEvent.Type.RESET);
ComplexEventChunk<ComplexEvent> complexEventChunk = new ComplexEventChunk<>();
complexEventChunk.add(stateEvent);
return complexEventChunk;
}
Aggregations