private void shiftOrResize() {
        if (posNext > 0) {
            byte[] oldBuf = buf;
            buf = new byte[buf.length];
            System.arraycopy(oldBuf, posNext, buf, 0, oldBuf.length - posNext);
            posRead -= posNext;
            posNext = 0;
        } else {
            byte[] oldBuf = buf;
            int len = buf.length * 2;
            if (len > MAX_ARRAY_LENGTH) {
                len = MAX_ARRAY_LENGTH;
            }
            buf = new byte[len];
            System.arraycopy(oldBuf, 0, buf, 0, oldBuf.length);
        }
    }
We have a stream of bytes and a separator as an input. We split the stream by
the separator and pass the byte arrays to output.
clickhouse-data/src/main/java/com/clickhouse/data/format/tsv/StreamSplitter.java