@Override
  public int size() {
    int s = 0;
    for (int i = 0; i < this.allBufs.size() - 1; i++) {
      s += this.allBufs.get(i).remaining();
    }
    // On the last BB, it might not be flipped yet if getByteBuffers is not yet called
    if (this.lastBufFlipped) {
      s += this.curBuf.remaining();
    } else {
      s += this.curBuf.position();
    }
    return s;
  }
An OutputStream which writes data into ByteBuffers. It will try to get ByteBuffer, as and when
needed, from the passed pool. When pool is not giving a ByteBuffer it will create one on heap.
Make sure to call {@link #releaseResources()} method once the Stream usage is over and data is
transferred to the wanted destination. Not thread safe!
hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBufferListOutputStream.java