public static byte[] randomOrderedFixedLengthKey(Random rand, int i, int suffixLength) {
    StringBuilder k = new StringBuilder();

    // The fixed-length lexicographically increasing part of the key.
    for (int bitIndex = 31; bitIndex >= 0; --bitIndex) {
      if ((i & (1 << bitIndex)) == 0) k.append("a");
      else k.append("b");
    }

    // A random suffix of the key.
    for (int j = 0; j < suffixLength; ++j)
      k.append(randomReadableChar(rand));

    byte[] keyBytes = Bytes.toBytes(k.toString());
    return keyBytes;
  }
Generates a random key that is guaranteed to increase as the given index i increases. The
result consists of a prefix, which is a deterministic increasing function of i, and a random
suffix.
@param rand random number generator to use
@return the random key
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/RandomKeyValueUtil.java