final void mapAndSend(Event[] events) {
        if (groupDeterminer != null) {
            LinkedHashMap<String, ArrayList<Event>> eventMap = new LinkedHashMap<>();
            for (Event event : events) {
                String key = groupDeterminer.decideGroup(event);
                ArrayList<Event> eventList = eventMap.computeIfAbsent(key, k -> new ArrayList<>());
                eventList.add(event);
            }
            for (ArrayList<Event> eventList : eventMap.values()) {
                try {
                    trpDynamicOptions.set(new DynamicOptions(eventList.get(0)));
                    if (mapperLatencyTracker != null &&
                            Level.DETAIL.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                        mapperLatencyTracker.markIn();
                    }
                    mapAndSend(eventList.toArray(new Event[eventList.size()]), optionHolder, templateBuilderMap,
                            sinkListener);
                } finally {
                    trpDynamicOptions.remove();
                    if (mapperLatencyTracker != null &&
                            Level.DETAIL.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                        mapperLatencyTracker.markOut();
                    }
                }
            }
        } else {
            try {
                trpDynamicOptions.set(new DynamicOptions(events[0]));
                if (mapperLatencyTracker != null &&
                        Level.DETAIL.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                    mapperLatencyTracker.markIn();
                }
                mapAndSend(events, optionHolder, templateBuilderMap, sinkListener);
            } finally {
                trpDynamicOptions.remove();
                if (mapperLatencyTracker != null &&
                        Level.DETAIL.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                    mapperLatencyTracker.markOut();
                }
            }
        }
    }
Called to map the events and send them to {@link SinkListener} for publishing

@param events {@link Event}s that need to be mapped
modules/siddhi-core/src/main/java/io/siddhi/core/stream/output/sink/SinkMapper.java