public static boolean equals(ByteBuffer buf1, int o1, int l1, byte[] buf2, int o2, int l2) {
    if ((l1 == 0) || (l2 == 0)) {
      // both 0 length, return true, or else false
      return l1 == l2;
    }
    // Since we're often comparing adjacent sorted data,
    // it's usual to have equal arrays except for the very last byte
    // so check that first
    if (toByte(buf1, o1 + l1 - 1) != buf2[o2 + l2 - 1]) {
      return false;
    }
    return compareTo(buf1, o1, l1, buf2, o2, l2) == 0;
  }
ByteBuffer to hash offset to start from length to hash
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java