use of io.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class CountPreStateProcessor method addEveryState.
@Override
public void addEveryState(StateEvent stateEvent) {
lock.lock();
try {
StateEvent clonedEvent = stateEventCloner.copyStateEvent(stateEvent);
clonedEvent.setType(ComplexEvent.Type.CURRENT);
for (int i = stateId; i < clonedEvent.getStreamEvents().length; i++) {
clonedEvent.setEvent(i, null);
}
StreamPreState state = stateHolder.getState();
try {
state.getNewAndEveryStateEventList().add(clonedEvent);
} finally {
stateHolder.returnState(state);
}
} finally {
lock.unlock();
}
}
use of io.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class LogicalPreStateProcessor method addEveryState.
@Override
public void addEveryState(StateEvent stateEvent) {
StateEvent clonedEvent = stateEventCloner.copyStateEvent(stateEvent);
clonedEvent.setType(ComplexEvent.Type.CURRENT);
clonedEvent.setEvent(stateId, null);
for (int i = stateId; i < clonedEvent.getStreamEvents().length; i++) {
clonedEvent.setEvent(i, null);
}
StreamPreState state = stateHolder.getState();
lock.lock();
try {
state.getNewAndEveryStateEventList().add(clonedEvent);
if (partnerStatePreProcessor != null) {
clonedEvent.setEvent(partnerStatePreProcessor.stateId, null);
partnerStatePreProcessor.addEventToNewAndEveryStateEventList(clonedEvent);
}
} finally {
lock.unlock();
stateHolder.returnState(state);
}
}
use of io.siddhi.core.event.state.StateEvent 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.state.StateEvent 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;
}
use of io.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class OutputCallback method constructMatchingStateEventChunk.
protected ComplexEventChunk<StateEvent> constructMatchingStateEventChunk(ComplexEventChunk matchingComplexEventChunk, boolean convertToStreamEvent, StateEventFactory stateEventFactory, int matchingStreamIndex, StreamEventFactory streamEventFactory, StreamEventConverter streamEventConverter) {
ComplexEventChunk<StateEvent> stateEventChunk = new ComplexEventChunk<>();
while (matchingComplexEventChunk.hasNext()) {
ComplexEvent matchingComplexEvent = matchingComplexEventChunk.next();
matchingComplexEventChunk.remove();
StateEvent stateEvent = stateEventFactory.newInstance();
if (convertToStreamEvent) {
StreamEvent borrowEvent = streamEventFactory.newInstance();
streamEventConverter.convertData(matchingComplexEvent.getTimestamp(), matchingComplexEvent.getOutputData(), matchingComplexEvent.getType() == ComplexEvent.Type.EXPIRED ? ComplexEvent.Type.CURRENT : matchingComplexEvent.getType(), borrowEvent);
stateEvent.addEvent(matchingStreamIndex, borrowEvent);
} else {
stateEvent.addEvent(matchingStreamIndex, (StreamEvent) matchingComplexEvent);
}
stateEventChunk.add(stateEvent);
}
return stateEventChunk;
}
Aggregations