public int size() {
    return curBuf.position();
  }
@param bb ByteBuffer to use. If too small, will be discarded and a new one allocated in its
          place; i.e. the passed in BB may NOT BE RETURNED!! Minimally it will be altered. SIDE
          EFFECT!! If you want to get the newly allocated ByteBuffer, you'll need to pick it up
          when done with this instance by calling {@link #getByteBuffer()}. All this
          encapsulation violation is so we can recycle buffers rather than allocate each time;
          it can get expensive especially if the buffers are big doing allocations each time or
          having them undergo resizing because initial allocation was small.
@see #getByteBuffer()
hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBufferOutputStream.java