public ClickHouseOutputStream writeBytes(ByteBuffer buffer, int length) throws IOException {
        if (buffer == null || length < 0) {
            throw new IllegalArgumentException("Non-null ByteBuffer and positive length are required");
        }

        byte[] bytes;
        if (buffer.hasArray()) {
            bytes = buffer.array();
        } else {
            bytes = new byte[length];
            buffer.get(bytes);
        }
        return writeBytes(bytes, 0, length);
    }
Writes bytes into output stream.

@param buffer non-null byte buffer
@param length bytes to write
@return current output stream
@throws IOException when failed to write value into output stream, not able
                    to sent all bytes, or operate on a closed stream
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseOutputStream.java