use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class PartitionStreamReceiver method receive.
@Override
public void receive(long timestamp, Object[] data) {
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertData(timestamp, data, newEvent);
if (partitionExecutors.size() == 0) {
send(newEvent);
} else {
for (PartitionExecutor partitionExecutor : partitionExecutors) {
String key = partitionExecutor.execute(newEvent);
send(key, newEvent);
}
}
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class PartitionStreamReceiver method receive.
@Override
public void receive(Event event) {
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertEvent(event, newEvent);
for (PartitionExecutor partitionExecutor : partitionExecutors) {
String key = partitionExecutor.execute(newEvent);
send(key, newEvent);
}
if (partitionExecutors.size() == 0) {
send(newEvent);
}
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class PartitionStreamReceiver method receive.
@Override
public void receive(List<Event> events) {
if (partitionExecutors.size() == 0) {
StreamEvent firstEvent = null;
StreamEvent currentEvent = null;
for (Event event : events) {
StreamEvent nextEvent = streamEventFactory.newInstance();
streamEventConverter.convertEvent(event, nextEvent);
if (firstEvent == null) {
firstEvent = nextEvent;
} else {
currentEvent.setNext(nextEvent);
}
currentEvent = nextEvent;
}
send(firstEvent);
} else {
String key = null;
StreamEvent firstEvent = null;
StreamEvent currentEvent = null;
for (Event event : events) {
StreamEvent nextEvent = streamEventFactory.newInstance();
streamEventConverter.convertEvent(event, nextEvent);
for (PartitionExecutor partitionExecutor : partitionExecutors) {
String currentKey = partitionExecutor.execute(nextEvent);
if (currentKey != null) {
if (key == null) {
key = currentKey;
firstEvent = nextEvent;
} else if (!currentKey.equals(key)) {
send(key, firstEvent);
key = currentKey;
firstEvent = nextEvent;
} else {
currentEvent.setNext(nextEvent);
}
currentEvent = nextEvent;
}
}
}
send(key, firstEvent);
}
}
use of io.siddhi.core.event.stream.StreamEvent 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;
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class CountPostStateProcessor method process.
protected void process(StateEvent stateEvent, ComplexEventChunk complexEventChunk) {
StreamEvent streamEvent = stateEvent.getStreamEvent(stateId);
int streamEvents = 1;
while (streamEvent.getNext() != null) {
streamEvents++;
streamEvent = streamEvent.getNext();
}
((CountPreStateProcessor) thisStatePreProcessor).successCondition();
stateEvent.setTimestamp(streamEvent.getTimestamp());
if (streamEvents >= minCount) {
if (thisStatePreProcessor.stateType == StateInputStream.Type.SEQUENCE) {
if (nextStatePreProcessor != null) {
nextStatePreProcessor.addState(stateEvent);
}
if (streamEvents != maxCount) {
thisStatePreProcessor.addState(stateEvent);
}
} else if (streamEvents == minCount) {
processMinCountReached(stateEvent, complexEventChunk);
}
if (streamEvents == maxCount) {
thisStatePreProcessor.stateChanged();
}
}
}
Aggregations