private static int getBufferPosition(@Nullable AppendMemoryBuffer buffer) {
      return buffer != null ? buffer.bufferPosition : 0;
    }
private static int getBufferPosition(@Nullable AppendMemoryBuffer buffer)