private void execute(ComplexEventChunk complexEventChunk,
                         List<ComplexEventChunk> returnEventChunkList) {
        StateEvent joinStateEvent = new StateEvent(2, 0);
        StreamEvent nextEvent = (StreamEvent) complexEventChunk.getFirst();
        complexEventChunk.clear();
        while (nextEvent != null) {
            StreamEvent streamEvent = nextEvent;
            nextEvent = streamEvent.getNext();
            streamEvent.setNext(null);
            ComplexEvent.Type eventType = streamEvent.getType();
            if (eventType == ComplexEvent.Type.TIMER) {
                continue;
            } else if (eventType == ComplexEvent.Type.RESET) {
                if (!leftJoinProcessor) {
                    StateEvent outputStateEvent = joinEventBuilder(null, streamEvent, eventType);
                    returnEventChunkList.add(new SelectorTypeComplexEventChunk(new ComplexEventChunk<>(
                            outputStateEvent, outputStateEvent), false));
                } else {
                    StateEvent outputStateEvent = joinEventBuilder(streamEvent, null, eventType);
                    returnEventChunkList.add(new SelectorTypeComplexEventChunk(new ComplexEventChunk<>(
                            outputStateEvent, outputStateEvent), false));
                }
            } else {
                joinStateEvent.setEvent(matchingStreamIndex, streamEvent);

                StreamEvent foundStreamEvent;
                if (this.isOptimisedQuery) {
                    try {
                        foundStreamEvent = query(joinStateEvent);
                    } catch (SiddhiAppRuntimeException e) {
                        log.warn("Performing select clause in databases failed due to '" + e.getMessage() +
                                " in query '" + queryName + "' within Siddhi app '" + siddhiAppName +
                                "' hence reverting back to querying only with where clause.", e);
                        this.isOptimisedQuery = false;
                        foundStreamEvent = findableProcessor.find(joinStateEvent, compiledCondition);
                    }
                } else {
                    foundStreamEvent = findableProcessor.find(joinStateEvent, compiledCondition);
                }

                joinStateEvent.setEvent(matchingStreamIndex, null);
                if (foundStreamEvent == null) {
                    if (outerJoinProcessor && !leftJoinProcessor) {
                        StateEvent outputStateEvent = joinEventBuilder(null, streamEvent, eventType);
                        returnEventChunkList.add(new SelectorTypeComplexEventChunk(new ComplexEventChunk<>(
                                outputStateEvent, outputStateEvent), false));
                    } else if (outerJoinProcessor && leftJoinProcessor) {
                        StateEvent outputStateEvent = joinEventBuilder(streamEvent, null, eventType);
                        returnEventChunkList.add(new SelectorTypeComplexEventChunk(new ComplexEventChunk<>(
                                outputStateEvent, outputStateEvent), false));
                    }
                } else if (!isOptimisedQuery) {
                    ComplexEventChunk<ComplexEvent> returnEventChunk = new ComplexEventChunk<>();
                    while (foundStreamEvent != null) {
                        StreamEvent nextFoundStreamEvent = foundStreamEvent.getNext();
                        foundStreamEvent.setNext(null);
                        if (!leftJoinProcessor) {
                            returnEventChunk.add(joinEventBuilder(foundStreamEvent, streamEvent, eventType));
                        } else {
                            returnEventChunk.add(joinEventBuilder(streamEvent, foundStreamEvent, eventType));
                        }
                        foundStreamEvent = nextFoundStreamEvent;
                    }
                    returnEventChunkList.add(new SelectorTypeComplexEventChunk(returnEventChunk, false));
                } else {
                    ComplexEventChunk<ComplexEvent> returnEventChunk = new ComplexEventChunk<>();
                    while (foundStreamEvent != null) {
                        StreamEvent nextFoundStreamEvent = foundStreamEvent.getNext();
                        StateEvent returnEvent = stateEventFactory.newInstance();
                        returnEvent.setType(eventType);
                        returnEvent.setTimestamp(foundStreamEvent.getTimestamp());
                        Object[] outputData = foundStreamEvent.getOutputData();
                        for (int i = 0; i < outputData.length; i++) {
                            Object data = outputData[i];
                            returnEvent.setOutputData(data, i);
                        }
                        returnEventChunk.add(returnEvent);
                        foundStreamEvent = nextFoundStreamEvent;
                    }
                    returnEventChunkList.add(new SelectorTypeComplexEventChunk(returnEventChunk, true));
                }
            }
        }
    }
Process the handed StreamEvent.

@param complexEventChunk event chunk to be processed
modules/siddhi-core/src/main/java/io/siddhi/core/query/input/stream/join/JoinProcessor.java