public static int numEqualPrefixBytes(ByteRange left, ByteRange right, int rightInnerOffset) {
    int maxCompares = Math.min(left.getLength(), right.getLength() - rightInnerOffset);
    final byte[] lbytes = left.getBytes();
    final byte[] rbytes = right.getBytes();
    final int loffset = left.getOffset();
    final int roffset = right.getOffset();
    for (int i = 0; i < maxCompares; ++i) {
      if (lbytes[loffset + i] != rbytes[roffset + rightInnerOffset + i]) {
        return i;
      }
    }
    return maxCompares;
  }
Utility methods for working with {@link ByteRange}.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteRangeUtils.java