code: public static DirectBuffer toBuffer(NDArrayMessage message) {
          ByteBuffer byteBuffer =
                          ByteBuffer.allocateDirect(byteBufferSizeForMessage(message)).order(ByteOrder.nativeOrder());
          //declare message opType
          byteBuffer.putInt(MessageType.WHOLE.ordinal());
          //perform the ndarray put on the
          if (message.getArr().isCompressed()) {
              AeronNDArraySerde.doByteBufferPutCompressed(message.getArr(), byteBuffer, false);
          } else {
              AeronNDArraySerde.doByteBufferPutUnCompressed(message.getArr(), byteBuffer, false);
          }
  
          long sent = message.getSent();
          long index = message.getIndex();
  
          byteBuffer.putLong(sent);
          byteBuffer.putLong(index);
          byteBuffer.putInt(message.getDimensions().length);
          for (int i = 0; i < message.getDimensions().length; i++) {
              byteBuffer.putInt(message.getDimensions()[i]);
          }
  
          //rewind the buffer before putting it in to the unsafe buffer
          //note that we set rewind to false in the do byte buffer put methods
          byteBuffer.rewind();
  
          return new UnsafeBuffer(byteBuffer);
      }
docs: Convert a message to a direct buffer.
  See {@link NDArrayMessage#fromBuffer(DirectBuffer, int)}
  for a description of the format for the buffer
  @param message the message to convert
  @return a direct byte buffer representing this message.