Search in sources :

Example 1 with StreamEvent

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);
        }
    }
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) OnDemandQueryRuntime(io.siddhi.core.query.OnDemandQueryRuntime) TimePeriod(io.siddhi.query.api.aggregation.TimePeriod) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) Event(io.siddhi.core.event.Event) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) OnDemandQuery(io.siddhi.query.api.execution.query.OnDemandQuery)

Example 2 with StreamEvent

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;
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Example 3 with StreamEvent

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;
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Example 4 with StreamEvent

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;
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Example 5 with StreamEvent

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;
    }
}
Also used : MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Aggregations

StreamEvent (io.siddhi.core.event.stream.StreamEvent)203 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)92 ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)74 StateEvent (io.siddhi.core.event.state.StateEvent)52 ComplexEvent (io.siddhi.core.event.ComplexEvent)33 ArrayList (java.util.ArrayList)27 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)26 Map (java.util.Map)24 Event (io.siddhi.core.event.Event)23 Test (org.testng.annotations.Test)23 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)20 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)18 Attribute (io.siddhi.query.api.definition.Attribute)17 HashMap (java.util.HashMap)17 Operation (io.siddhi.core.event.stream.Operation)12 LinkedList (java.util.LinkedList)12 SnapshotableStreamEventQueue (io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue)11 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)10 HashSet (java.util.HashSet)10 StreamEventConverter (io.siddhi.core.event.stream.converter.StreamEventConverter)8