private Map<Node, ProxyRequest> split(
        short apiVersion,
        ClientIdMetadata clientId,
        int timeout,
        short requiredAcks,
        short flag,
        String transactionId,
        Map<TopicPartition, MemoryRecords> entriesPerPartition
    ) {
        Map<Node, List<Map.Entry<TopicPartition, MemoryRecords>>> node2Entries = new HashMap<>();
        entriesPerPartition.forEach((tp, records) -> {
            Node node = mapping.getRouteOutNode(tp.topic(), tp.partition(), clientId);
            node2Entries.compute(node, (n, list) -> {
                if (list == null) {
                    list = new ArrayList<>();
                }
                list.add(Map.entry(tp, records));
                return list;
            });
        });
        Map<Node, ProxyRequest> rst = new HashMap<>();
        node2Entries.forEach((node, entries) -> {
            AtomicInteger size = new AtomicInteger();
            ProduceRequestData data = new ProduceRequestData();
            data.setTransactionalId(transactionId);
            data.setAcks(requiredAcks);
            data.setTimeoutMs(timeout);

            Map<String, Map<Integer, MemoryRecords>> topicData = new HashMap<>();
            entries.forEach(e -> {
                TopicPartition tp = e.getKey();
                MemoryRecords records = e.getValue();
                topicData.compute(tp.topic(), (topicName, map) -> {
                    if (map == null) {
                        map = new HashMap<>();
                    }
                    map.put(tp.partition(), records);
                    size.addAndGet(records.sizeInBytes());
                    return map;
                });
            });
            ProduceRequestData.TopicProduceDataCollection list = new ProduceRequestData.TopicProduceDataCollection();
            topicData.forEach((topicName, partitionData) -> {
                list.add(
                    new ProduceRequestData.TopicProduceData()
                        .setName(topicName)
                        .setPartitionData(
                            partitionData.entrySet()
                                .stream()
                                .map(e -> new ProduceRequestData.PartitionProduceData().setIndex(e.getKey()).setRecords(e.getValue()))
                                .collect(Collectors.toList())
                        )
                );
            });
            data.setTopicData(list);
            rst.put(node, new ProxyRequest(apiVersion, flag, data, size.get()));
        });
        return rst;
    }
Split the produce request to different nodes
core/src/main/java/kafka/automq/zerozone/RouterOut.java