public static void serializeRecordBatch(ArrowRecordBatch recordBatch, MemoryBuffer buffer) {
    // TODO(chaokunyang) add custom WritableByteChannel to avoid copy in `WritableByteChannelImpl`
    try (WriteChannel channel =
        new WriteChannel(Channels.newChannel(new MemoryBufferOutputStream(buffer)))) {
      MessageSerializer.serialize(channel, recordBatch);
    } catch (IOException e) {
      throw new RuntimeException(String.format("Serialize record batch %s failed", recordBatch), e);
    }
  }
@Test
  public void testSerializeRecordBatch() {
    VectorSchemaRoot vectorSchemaRoot = createVectorSchemaRoot(2);
    VectorUnloader unloader = new VectorUnloader(vectorSchemaRoot);
    ArrowRecordBatch recordBatch = unloader.getRecordBatch();
    MemoryBuffer buffer = MemoryUtils.buffer(32);
    ArrowUtils.serializeRecordBatch(recordBatch, buffer);
    try (ArrowRecordBatch batch = ArrowUtils.deserializeRecordBatch(buffer)) {
      System.out.println("newRecordBatch " + batch);
      assertEquals(batch.getLength(), recordBatch.getLength());
      assertEquals(batch.computeBodyLength(), recordBatch.computeBodyLength());
      assertEquals(batch.getMessageType(), recordBatch.getMessageType());
    }
  }