@Override
    public ClickHouseOutputStream writeBuffer(ClickHouseByteBuffer buffer) throws IOException {
        if (buffer == null) {
            throw new NullPointerException();
        } else if (buffer.isEmpty()) {
            return this;
        }
        ensureOpen();

        byte[] b = this.buffer;
        int limit = b.length;
        int length = buffer.length();
        log.debug("writeBuffer limit:[{}] length:[{}] position:[{}]", limit, length, position);
        if (length <= limit - position) {
            System.arraycopy(buffer.array(), buffer.position(), b, position, length);
            position += length;
        } else {
            flushBuffer();
            flushBuffer(buffer.array(), buffer.position(), buffer.length());
        }
        return this;
    }
Writes the given byte array without using {@code buffer} and
{@code position}.

@param bytes  non-null byte array to write
@param offset offset
@param length length in byte
@throws IOException when failed to write data
clickhouse-data/src/main/java/com/clickhouse/data/stream/AbstractByteArrayOutputStream.java