public static Event[] executeSelector(StateEventFactory stateEventFactory,
                                          StreamEvent streamEvent, StreamEvent storeEvents,
                                          int storeEventIndex, QuerySelector selector) {
        ComplexEventChunk outputComplexEventChunk = executeSelectorAndReturnChunk(stateEventFactory, streamEvent,
                storeEvents, storeEventIndex, selector);
        if (outputComplexEventChunk != null) {
            List<Event> events = new ArrayList<>();
            outputComplexEventChunk.reset();
            while (outputComplexEventChunk.hasNext()) {
                ComplexEvent complexEvent = outputComplexEventChunk.next();
                events.add(new Event(complexEvent.getTimestamp(), complexEvent.getOutputData()));
            }
            return events.toArray(new Event[0]);
        } else {
            return null;
        }

    }
Class to hold util functions used during OnDemandQueryRuntime
modules/siddhi-core/src/main/java/io/siddhi/core/util/OnDemandQueryRuntimeUtil.java