@Override
    public int read(byte[] b, int off, int len) {
        if (off < 0 || len < 0 || len > b.length - off) {
            throw new IndexOutOfBoundsException();
        }
        if (pos >= count) {
            return -1;
        }
        if (pos + len > count) {
            // noinspection AssignmentToMethodParameter
            len = count - pos;
        }
        if (len <= 0) {
            return 0;
        }
        System.arraycopy(buf, pos, b, off, len);
        pos += len;
        return len;
    }
Special constructor fo creating InputStream over not fully filled array

@param buf   byte array
@param count number of filled elements
clickhouse-data/src/main/java/com/clickhouse/data/format/tsv/FastByteArrayInputStream.java