protected ComplexEventChunk<StreamEvent> reduceEventsForUpdateOrInsert(
            AddingStreamEventExtractor addingStreamEventExtractor,
            InMemoryCompiledCondition inMemoryCompiledCondition,
            InMemoryCompiledUpdateSet compiledUpdateSet, ComplexEventChunk<StateEvent> failedEvents) {
        ComplexEventChunk<StreamEvent> toInsertEventChunk = new ComplexEventChunk<>();
        failedEvents.reset();
        while (failedEvents.hasNext()) {
            StateEvent failedEvent = failedEvents.next();
            boolean updated = false;
            toInsertEventChunk.reset();
            while (toInsertEventChunk.hasNext()) {
                StreamEvent toInsertEvent = toInsertEventChunk.next();
                failedEvent.setEvent(inMemoryCompiledCondition.getStoreEventIndex(), toInsertEvent);
                if ((Boolean) inMemoryCompiledCondition.
                        getUpdateOrInsertExpressionExecutor().execute(failedEvent)) {
                    for (Map.Entry<Integer, ExpressionExecutor> entry :
                            compiledUpdateSet.getExpressionExecutorMap().entrySet()) {
                        toInsertEvent.setOutputData(entry.getValue().
                                execute(failedEvent), entry.getKey());
                    }
                    updated = true;
                }
            }
            if (!updated) {
                toInsertEventChunk.add(addingStreamEventExtractor.getAddingStreamEvent(failedEvent));
            }
        }
        return toInsertEventChunk;
    }
In-memory event table implementation of SiddhiQL.
modules/siddhi-core/src/main/java/io/siddhi/core/table/InMemoryTable.java