public static int length(PositionedByteRange buff) {
    PositionedByteRange b =
      new SimplePositionedMutableByteRange(buff.getBytes(), buff.getOffset(), buff.getLength());
    b.setPosition(buff.getPosition());
    int cnt = 0;
    for (; isEncodedValue(b); skip(b), cnt++)
      ;
    return cnt;
  }
Return the number of encoded entries remaining in {@code buff}. The state of {@code buff} is
not modified through use of this method.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java