use of org.wso2.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class SelectiveStateEventPopulator method populateStateEvent.
public void populateStateEvent(ComplexEvent complexEvent) {
StateEvent stateEvent = (StateEvent) complexEvent;
for (StateMappingElement stateMappingElement : stateMappingElements) {
int toPosition = stateMappingElement.getToPosition();
stateEvent.setOutputData(getFromData(stateEvent, stateMappingElement.getFromPosition()), toPosition);
// switch (toPosition[0]) {
// case 0:
// stateEvent.setPreOutputData(getFromData(stateEvent, stateMappingElement.getFromPosition()),
// toPosition[1]);
// break;
// case 1:
// stateEvent.setOutputData(getFromData(stateEvent, stateMappingElement.getFromPosition()),
// toPosition[1]);
// break;
// default:
// //will not happen
// throw new IllegalStateException("To Position cannot be :" + toPosition[0]);
// }
}
}
use of org.wso2.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class FindStoreQueryRuntime method executeSelector.
private Event[] executeSelector(StreamEvent streamEvents, MetaStreamEvent.EventType eventType) {
ComplexEventChunk<StateEvent> complexEventChunk = new ComplexEventChunk<>(true);
while (streamEvents != null) {
StreamEvent streamEvent = streamEvents;
streamEvents = streamEvents.getNext();
streamEvent.setNext(null);
StateEvent stateEvent = stateEventPool.borrowEvent();
if (eventType == MetaStreamEvent.EventType.AGGREGATE) {
stateEvent.addEvent(1, streamEvent);
} else {
stateEvent.addEvent(0, streamEvent);
}
complexEventChunk.add(stateEvent);
}
ComplexEventChunk outputComplexEventChunk = selector.execute(complexEventChunk);
if (outputComplexEventChunk != null) {
List<Event> events = new ArrayList<>();
outputComplexEventChunk.reset();
while (outputComplexEventChunk.hasNext()) {
ComplexEvent complexEvent = outputComplexEventChunk.next();
events.add(new Event(complexEvent.getTimestamp(), complexEvent.getOutputData()));
}
return events.toArray(new Event[0]);
} else {
return null;
}
}
use of org.wso2.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class SelectStoreQueryRuntime method execute.
public Event[] execute() {
try {
StateEvent stateEvent = new StateEvent(1, 0);
StreamEvent streamEvents = queryableProcessor.query(stateEvent, compiledCondition, compiledSelection);
if (streamEvents == null) {
return null;
} else {
List<Event> events = new ArrayList<Event>();
while (streamEvents != null) {
events.add(new Event(streamEvents.getTimestamp(), streamEvents.getOutputData()));
streamEvents = streamEvents.getNext();
}
return events.toArray(new Event[0]);
}
} catch (Throwable t) {
throw new StoreQueryRuntimeException("Error executing '" + queryName + "', " + t.getMessage(), t);
}
}
use of org.wso2.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class SingleProcessStreamReceiver method processAndClear.
protected void processAndClear(ComplexEventChunk<StreamEvent> streamEventChunk) {
ComplexEventChunk<StateEvent> retEventChunk = new ComplexEventChunk<StateEvent>(false);
synchronized (lockKey) {
while (streamEventChunk.hasNext()) {
StreamEvent streamEvent = streamEventChunk.next();
streamEventChunk.remove();
stabilizeStates();
currentStreamEventChunk.add(streamEvent);
ComplexEventChunk<StateEvent> eventChunk = ((StreamPreStateProcessor) next).processAndReturn(currentStreamEventChunk);
if (eventChunk.getFirst() != null) {
retEventChunk.add(eventChunk.getFirst());
}
eventChunk.clear();
currentStreamEventChunk.clear();
}
}
while (retEventChunk.hasNext()) {
StateEvent stateEvent = retEventChunk.next();
retEventChunk.remove();
querySelector.process(new ComplexEventChunk<StateEvent>(stateEvent, stateEvent, false));
}
}
use of org.wso2.siddhi.core.event.state.StateEvent in project siddhi by wso2.
the class StateMultiProcessStreamReceiver method processAndClear.
protected void processAndClear(int processIndex, StreamEvent streamEvent) {
ComplexEventChunk<StateEvent> retEventChunk = new ComplexEventChunk<StateEvent>(batchProcessingAllowed);
ComplexEventChunk<StreamEvent> currentStreamEventChunk = new ComplexEventChunk<StreamEvent>(streamEvent, streamEvent, batchProcessingAllowed);
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, batchProcessingAllowed));
}
}
}
Aggregations