Search in sources :

Example 61 with StreamEvent

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(List<Event> events) {
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        for (Event event : events) {
            try {
                multiProcessReturn.set(new ReturnEventHolder());
                stabilizeStates(event.getTimestamp());
                for (int anEventSequence : eventSequence) {
                    StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                    StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                    StreamEvent newEvent = aStreamEventFactory.newInstance();
                    aStreamEventConverter.convertEvent(event, newEvent);
                    process(anEventSequence, newEvent);
                    if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                        returnEventHolderList.add(multiProcessReturn.get());
                        multiProcessReturn.set(new ReturnEventHolder());
                    }
                }
            } finally {
                multiProcessReturn.set(null);
            }
        }
    }
    for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
        outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
    }
}
Also used : StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList) Event(io.siddhi.core.event.Event) ComplexEvent(io.siddhi.core.event.ComplexEvent) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Example 62 with StreamEvent

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(ComplexEvent complexEvent) {
    ComplexEvent aComplexEvent = complexEvent;
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        while (aComplexEvent != null) {
            try {
                multiProcessReturn.set(new ReturnEventHolder());
                stabilizeStates(aComplexEvent.getTimestamp());
                for (int anEventSequence : eventSequence) {
                    StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                    StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                    StreamEvent newEvent = aStreamEventFactory.newInstance();
                    aStreamEventConverter.convertComplexEvent(aComplexEvent, newEvent);
                    process(anEventSequence, newEvent);
                    if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                        returnEventHolderList.add(multiProcessReturn.get());
                        multiProcessReturn.set(new ReturnEventHolder());
                    }
                }
            } finally {
                multiProcessReturn.set(null);
            }
            aComplexEvent = aComplexEvent.getNext();
        }
        for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
            outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
        }
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList)

Example 63 with StreamEvent

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(long timestamp, Object[] data) {
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        try {
            multiProcessReturn.set(new ReturnEventHolder());
            stabilizeStates(timestamp);
            for (int anEventSequence : eventSequence) {
                StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                StreamEvent newEvent = aStreamEventFactory.newInstance();
                aStreamEventConverter.convertData(timestamp, data, newEvent);
                process(anEventSequence, newEvent);
                if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                    returnEventHolderList.add(multiProcessReturn.get());
                    multiProcessReturn.set(new ReturnEventHolder());
                }
            }
        } finally {
            multiProcessReturn.set(null);
        }
    }
    for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
        outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
    }
}
Also used : StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList)

Example 64 with StreamEvent

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(Event event) {
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        try {
            multiProcessReturn.set(new ReturnEventHolder());
            stabilizeStates(event.getTimestamp());
            for (int anEventSequence : eventSequence) {
                StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                StreamEvent newEvent = aStreamEventFactory.newInstance();
                aStreamEventConverter.convertEvent(event, newEvent);
                process(anEventSequence, newEvent);
                if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                    returnEventHolderList.add(multiProcessReturn.get());
                    multiProcessReturn.set(new ReturnEventHolder());
                }
            }
        } finally {
            multiProcessReturn.set(null);
        }
    }
    for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
        outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
    }
}
Also used : StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList)

Example 65 with StreamEvent

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

the class SingleProcessStreamReceiver method processAndClear.

protected void processAndClear(ComplexEventChunk<StreamEvent> streamEventChunk) {
    ComplexEventChunk<StateEvent> retEventChunk = new ComplexEventChunk<>();
    ComplexEventChunk<StreamEvent> currentStreamEventChunk = new ComplexEventChunk<>();
    synchronized (patternSyncObject) {
        while (streamEventChunk.hasNext()) {
            StreamEvent streamEvent = streamEventChunk.next();
            streamEventChunk.remove();
            stabilizeStates(streamEvent.getTimestamp());
            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));
    }
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent) StateEvent(io.siddhi.core.event.state.StateEvent) StreamPreStateProcessor(io.siddhi.core.query.input.stream.state.StreamPreStateProcessor)

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