use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class IncrementalExecutorsInitialiser method recreateState.
private void recreateState(Long lastData, TimePeriod.Duration recreateForDuration, Table recreateFromTable, boolean isBeforeRoot) {
Executor incrementalExecutor = incrementalExecutorMap.get(recreateForDuration);
if (lastData != null) {
endOFLatestEventTimestamp = IncrementalTimeConverterUtil.getNextEmitTime(lastData, recreateForDuration, timeZone);
}
OnDemandQuery onDemandQuery = getOnDemandQuery(recreateFromTable, false, endOFLatestEventTimestamp);
onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.FIND);
OnDemandQueryRuntime onDemandQueryRuntime = OnDemandQueryParser.parse(onDemandQuery, null, siddhiAppContext, tableMap, windowMap, aggregationMap);
Event[] events = onDemandQueryRuntime.execute();
if (events != null) {
long referenceToNextLatestEvent = (Long) events[events.length - 1].getData(0);
ComplexEventChunk<StreamEvent> complexEventChunk = new ComplexEventChunk<>();
for (Event event : events) {
StreamEvent streamEvent = streamEventFactory.newInstance();
streamEvent.setOutputData(event.getData());
complexEventChunk.add(streamEvent);
}
incrementalExecutor.execute(complexEventChunk);
if (isBeforeRoot) {
TimePeriod.Duration rootDuration = incrementalDurations.get(0);
Executor rootIncrementalExecutor = incrementalExecutorMap.get(rootDuration);
long emitTimeOfLatestEventInTable = IncrementalTimeConverterUtil.getNextEmitTime(referenceToNextLatestEvent, rootDuration, timeZone);
rootIncrementalExecutor.setEmitTime(emitTimeOfLatestEventInTable);
}
}
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class FaultStreamEventConverter method convert.
public StreamEvent convert(Event[] events, Exception e) {
StreamEvent firstEvent = streamEventFactory.newInstance();
convertEvent(events[0], firstEvent, e);
StreamEvent currentEvent = firstEvent;
for (int i = 1, eventsLength = events.length; i < eventsLength; i++) {
StreamEvent nextEvent = streamEventFactory.newInstance();
convertEvent(events[i], nextEvent, e);
currentEvent.setNext(nextEvent);
currentEvent = nextEvent;
}
return firstEvent;
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class FaultStreamEventConverter method convert.
public StreamEvent convert(Event event, Exception e) {
StreamEvent newEvent = streamEventFactory.newInstance();
convertEvent(event, newEvent, e);
return newEvent;
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class FaultStreamEventConverter method convert.
public StreamEvent convert(List<Event> events, Exception e) {
StreamEvent firstEvent = streamEventFactory.newInstance();
convertEvent(events.get(0), firstEvent, e);
StreamEvent currentEvent = firstEvent;
for (int i = 1, eventsLength = events.size(); i < eventsLength; i++) {
StreamEvent nextEvent = streamEventFactory.newInstance();
convertEvent(events.get(i), nextEvent, e);
currentEvent.setNext(nextEvent);
currentEvent = nextEvent;
}
return firstEvent;
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class ConversionStreamEventChunk method convertAndAdd.
public void convertAndAdd(Event event) {
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertEvent(event, newEvent);
if (first == null) {
first = newEvent;
last = first;
} else {
last.setNext(newEvent);
last = newEvent;
}
}
Aggregations