Search in sources :

Example 26 with StreamEventCloner

use of org.wso2.siddhi.core.event.stream.StreamEventCloner in project siddhi by wso2.

the class EventChunkOperator method find.

@Override
public StreamEvent find(StateEvent matchingEvent, Object storeEvents, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> storeEventChunk = (ComplexEventChunk<StreamEvent>) storeEvents;
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    storeEventChunk.reset();
    while (storeEventChunk.hasNext()) {
        StreamEvent storeEvent = storeEventChunk.next();
        matchingEvent.setEvent(storeEventPosition, storeEvent);
        if ((Boolean) expressionExecutor.execute(matchingEvent)) {
            returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
        }
        matchingEvent.setEvent(storeEventPosition, null);
    }
    return returnEventChunk.getFirst();
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 27 with StreamEventCloner

use of org.wso2.siddhi.core.event.stream.StreamEventCloner in project siddhi by wso2.

the class AndMultiPrimaryKeyCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
    if (storeEventSet == null) {
        return returnEventChunk.getFirst();
    } else {
        for (StreamEvent storeEvent : storeEventSet) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 28 with StreamEventCloner

use of org.wso2.siddhi.core.event.stream.StreamEventCloner in project siddhi by wso2.

the class CompareCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
    if (storeEventSet == null) {
        // triggering sequential scan
        Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
        for (StreamEvent storeEvent : storeEvents) {
            matchingEvent.setEvent(storeEventIndex, storeEvent);
            if ((Boolean) expressionExecutor.execute(matchingEvent)) {
                if (storeEventCloner != null) {
                    returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
                } else {
                    returnEventChunk.add(storeEvent);
                }
            }
            matchingEvent.setEvent(storeEventIndex, null);
        }
        return returnEventChunk.getFirst();
    } else {
        for (StreamEvent storeEvent : storeEventSet) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 29 with StreamEventCloner

use of org.wso2.siddhi.core.event.stream.StreamEventCloner in project siddhi by wso2.

the class NonCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    if ((Boolean) expressionExecutor.execute(matchingEvent)) {
        ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
        Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
        for (StreamEvent storeEvent : storeEvents) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    } else {
        return null;
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Aggregations

StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)23 ComplexEventChunk (org.wso2.siddhi.core.event.ComplexEventChunk)11 ArrayList (java.util.ArrayList)5 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)4 StreamEventCloner (org.wso2.siddhi.core.event.stream.StreamEventCloner)4 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)4 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)2 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)2 StateEventCloner (org.wso2.siddhi.core.event.state.StateEventCloner)2 SchedulingProcessor (org.wso2.siddhi.core.query.processor.SchedulingProcessor)2 Attribute (org.wso2.siddhi.query.api.definition.Attribute)2 Collection (java.util.Collection)1 StateEventPool (org.wso2.siddhi.core.event.state.StateEventPool)1 ComplexEventPopulater (org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater)1 ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)1 JoinProcessor (org.wso2.siddhi.core.query.input.stream.join.JoinProcessor)1 EntryValveProcessor (org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor)1 StreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)1 Processor (org.wso2.siddhi.core.query.processor.Processor)1 AbstractStreamProcessor (org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor)1