public static byte[][] readArrowBatches(ReadableByteChannel channel) throws IOException {
        List<byte[]> results = new ArrayList<>();
        byte[] batch;
        while ((batch = readNextBatch(channel)) != null) {
            results.add(batch);
        }
        return results.toArray(new byte[0][]);
    }
@Test
    void testReadArrowBatches() throws IOException {
        VectorSchemaRoot root =
                VectorSchemaRoot.create(ArrowUtils.toArrowSchema(rowType), allocator);
        ArrowWriter<RowData> arrowWriter = ArrowUtils.createRowDataArrowWriter(root, rowType);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ArrowStreamWriter arrowStreamWriter = new ArrowStreamWriter(root, null, baos);
        arrowStreamWriter.start();

        List<RowData> testData =
                Arrays.asList(
                        new GenericRowData(rowType.getFieldCount()),
                        new GenericRowData(rowType.getFieldCount()),
                        new GenericRowData(rowType.getFieldCount()),
                        new GenericRowData(rowType.getFieldCount()),
                        new GenericRowData(rowType.getFieldCount()));
        int batches = 3;
        List<List<RowData>> subLists = Lists.partition(testData, testData.size() / batches + 1);
        for (List<RowData> subList : subLists) {
            for (RowData value : subList) {
                arrowWriter.write(value);
            }
            arrowWriter.finish();
            arrowStreamWriter.writeBatch();
            arrowWriter.reset();
        }

        assertThat(
                        ArrowUtils.readArrowBatches(
                                        Channels.newChannel(
                                                new ByteArrayInputStream(baos.toByteArray())))
                                .length)
                .isEqualTo(batches);
    }