@Override
      public byte[] next() {
        i++;
        if (i == 0) return a;
        if (i == num + 1) return b;

        BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));
        byte[] padded = curBI.toByteArray();
        if (padded[1] == 0) padded = tail(padded, padded.length - 2);
        else padded = tail(padded, padded.length - 1);
        return padded;
      }
Iterate over keys within the passed range.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java