public List<Object[]> reduceEventsForInsert(List<Object[]> failedRecords,
                                                Map<String, ExpressionExecutor> inMemorySetExecutors) {
        ComplexEventChunk<StreamEvent> toInsertEventChunk = new ComplexEventChunk<>();
        StateEvent joinEvent = stateEventFactory.newInstance();
        for (Object[] data : failedRecords) {
            StreamEvent failedEvent = streamEventFactory.newInstance();
            failedEvent.setOutputData(data);
            joinEvent.setEvent(streamEventIndex, failedEvent);
            boolean updated = false;
            toInsertEventChunk.reset();
            while (toInsertEventChunk.hasNext()) {
                StreamEvent toInsertEvent = toInsertEventChunk.next();
                joinEvent.setEvent(storeEventIndex, toInsertEvent);
                if ((Boolean) inMemoryCompiledCondition.execute(joinEvent)) {
                    for (Map.Entry<String, ExpressionExecutor> entry :
                            inMemorySetExecutors.entrySet()) {
                        toInsertEvent.setOutputData(entry.getValue().execute(failedEvent),
                                attributeMap.get(entry.getKey()));
                    }
                    updated = true;
                }
            }
            if (!updated) {
                toInsertEventChunk.add(failedEvent);
            }
        }
        List<Object[]> toInsertRecords = new LinkedList<>();
        toInsertEventChunk.reset();
        while (toInsertEventChunk.hasNext()) {
            StreamEvent streamEvent = toInsertEventChunk.next();
            toInsertRecords.add(streamEvent.getOutputData());
        }
        return toInsertRecords;
    }
Class used to reduce the fail to update events to such that they can be inserted at once.
modules/siddhi-core/src/main/java/io/siddhi/core/table/record/UpdateOrInsertReducer.java