Search in sources :

Example 6 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class ConversionStreamEventChunk method convertAndAssign.

// @Override
// public void convertAndAssignFirst(StreamEvent streamEvent) {
// StreamEvent newEvent = streamEventFactory.borrowEvent();
// eventConverter.convertComplexEvent(streamEvent, newEvent);
// first = newEvent;
// last = first;
// }
public void convertAndAssign(Event[] events) {
    StreamEvent firstEvent = streamEventFactory.newInstance();
    streamEventConverter.convertEvent(events[0], firstEvent);
    StreamEvent currentEvent = firstEvent;
    for (int i = 1, eventsLength = events.length; i < eventsLength; i++) {
        StreamEvent nextEvent = streamEventFactory.newInstance();
        streamEventConverter.convertEvent(events[i], nextEvent);
        currentEvent.setNext(nextEvent);
        currentEvent = nextEvent;
    }
    first = firstEvent;
    last = currentEvent;
}
Also used : MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(io.siddhi.core.event.stream.StreamEvent)

Example 7 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class StateEvent method getStreamEvent.

public StreamEvent getStreamEvent(int[] position) {
    StreamEvent streamEvent = streamEvents[position[STREAM_EVENT_CHAIN_INDEX]];
    if (streamEvent == null) {
        return null;
    }
    int streamEventIndex = position[STREAM_EVENT_INDEX_IN_CHAIN];
    if (streamEventIndex >= 0) {
        for (int i = 1; i <= position[STREAM_EVENT_INDEX_IN_CHAIN]; i++) {
            streamEvent = streamEvent.getNext();
            if (streamEvent == null) {
                return null;
            }
        }
    } else if (streamEventIndex == CURRENT) {
        while (streamEvent.getNext() != null) {
            streamEvent = streamEvent.getNext();
        }
    } else if (streamEventIndex == LAST) {
        if (streamEvent.getNext() == null) {
            return null;
        }
        while (streamEvent.getNext().getNext() != null) {
            streamEvent = streamEvent.getNext();
        }
    } else {
        List<StreamEvent> stateEventList = new ArrayList<StreamEvent>();
        while (streamEvent != null) {
            stateEventList.add(streamEvent);
            streamEvent = streamEvent.getNext();
        }
        int index = stateEventList.size() + streamEventIndex;
        if (index < 0) {
            return null;
        } else {
            streamEvent = stateEventList.get(index);
        }
    }
    return streamEvent;
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent) ArrayList(java.util.ArrayList)

Example 8 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class SnapshotableStreamEventQueue method poll.

public StreamEvent poll() {
    reset();
    if (first != null) {
        StreamEvent firstEvent = first;
        first = first.getNext();
        firstEvent.setNext(null);
        if (!isFullSnapshot()) {
            if (isOperationLogEnabled) {
                operationChangeLog.add(new Operation(Operator.REMOVE));
            }
            operationChangeLogSize++;
        } else {
            operationChangeLog.clear();
            operationChangeLogSize = 0;
            forceFullSnapshot = true;
        }
        return firstEvent;
    } else {
        return null;
    }
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent) Operation(io.siddhi.core.event.stream.Operation)

Example 9 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class SnapshotableStreamEventQueue method overwrite.

public void overwrite(StreamEvent streamEvent) {
    if (!isFullSnapshot()) {
        if (isOperationLogEnabled) {
            operationChangeLog.add(new Operation(Operator.OVERWRITE, new Object[] { eventIndex, eventClonerHolder.getStreamEventCloner().copyStreamEvent(streamEvent) }));
        }
        operationChangeLogSize++;
    } else {
        operationChangeLog.clear();
        operationChangeLogSize = 0;
        forceFullSnapshot = true;
    }
    if (previousToLastReturned != null) {
        previousToLastReturned.setNext(streamEvent);
    } else {
        first = streamEvent;
    }
    StreamEvent next = lastReturned.getNext();
    if (next != null) {
        streamEvent.setNext(next);
    } else {
        last = streamEvent;
    }
    lastReturned = streamEvent;
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent) Operation(io.siddhi.core.event.stream.Operation)

Example 10 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class BatchingWindowProcessor method processEventChunk.

@Override
protected void processEventChunk(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater, S state) {
    streamEventChunk.reset();
    while (streamEventChunk.hasNext()) {
        StreamEvent streamEvent = streamEventChunk.next();
        streamEvent.setBeforeWindowData(null);
    }
    streamEventChunk.reset();
    process(streamEventChunk, nextProcessor, streamEventCloner, state);
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

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