public static StreamEvent executeSelectorAndReturnStreamEvent(StateEventFactory stateEventFactory,
                                                                  StreamEvent streamEvent, StreamEvent storeEvents,
                                                                  int storeEventIndex, QuerySelector selector) {
        ComplexEventChunk outputComplexEventChunk = executeSelectorAndReturnChunk(stateEventFactory, streamEvent,
                storeEvents, storeEventIndex, selector);
        if (outputComplexEventChunk != null) {
            outputComplexEventChunk.reset();
            ComplexEvent firstComplexEvent = outputComplexEventChunk.next();
            StreamEvent firstEvent = new StreamEvent(0, 0, firstComplexEvent.getOutputData().length);
            firstEvent.setOutputData(firstComplexEvent.getOutputData());
            StreamEvent eventPointer = firstEvent;
            while (outputComplexEventChunk.hasNext()) {
                ComplexEvent complexEvent = outputComplexEventChunk.next();
                StreamEvent resultEvent = new StreamEvent(0, 0, complexEvent.getOutputData().length);
                resultEvent.setOutputData(complexEvent.getOutputData());
                eventPointer.setNext(resultEvent);
                eventPointer = resultEvent;
            }
            return firstEvent;
        } else {
            return null;
        }
    }
Class to hold util functions used during OnDemandQueryRuntime
modules/siddhi-core/src/main/java/io/siddhi/core/util/OnDemandQueryRuntimeUtil.java