Compare base64 strings for MinHash.

@param numOfBits The number of MinHash bits
@param str1 MinHash base64 string
@param str2 MinHash base64 string
@return similarity (0 to 1.0f)
970374
public static float compare(final int numOfBits, final String str1,
            final String str2) {
        return compare(numOfBits, BaseEncoding.base64().decode(str1),
                BaseEncoding.base64().decode(str2));
    }
1329909
public char match(String str1, String str2) {
        invocationCount++;
        char rel = IMappingElement.IDK;

        if (str1 == null || str2 == null) {
            rel = IMappingElement.IDK;
        } else {
            if ((str1.length() > 3) && (str2.length() > 3)) {
                if (str1.startsWith(str2)) {
                    if (str1.contains(" ")) {
                        rel = IMappingElement.LESS_GENERAL;
                    } else {
                        rel = IMappingElement.EQUIVALENCE;
                    }
                } else {
                    if (str2.startsWith(str1)) {
                        if (str2.contains(" ")) {
                            rel = IMappingElement.MORE_GENERAL;
                        } else {
                            rel = IMappingElement.EQUIVALENCE;
                        }
                    }
                }
            }//if ((str1.length() > 3) && (str2.length() > 3)) {
        }

        if (rel != IMappingElement.IDK) {
            relCount++;
            addCase(str1, str2, rel);
        }
        return rel;
    }
896954
@SuppressWarnings("checkstyle:ReturnCount")
  public static int compareBuff(final DirectBuffer o1, final DirectBuffer o2) {
    requireNonNull(o1);
    requireNonNull(o2);
    if (o1.equals(o2)) {
      return 0;
    }
    final int minLength = Math.min(o1.capacity(), o2.capacity());
    final int minWords = minLength / Long.BYTES;

    for (int i = 0; i < minWords * Long.BYTES; i += Long.BYTES) {
      final long lw = o1.getLong(i, BIG_ENDIAN);
      final long rw = o2.getLong(i, BIG_ENDIAN);
      final int diff = Long.compareUnsigned(lw, rw);
      if (diff != 0) {
        return diff;
      }
    }

    for (int i = minWords * Long.BYTES; i < minLength; i++) {
      final int lw = Byte.toUnsignedInt(o1.getByte(i));
      final int rw = Byte.toUnsignedInt(o2.getByte(i));
      final int result = Integer.compareUnsigned(lw, rw);
      if (result != 0) {
        return result;
      }
    }

    return o1.capacity() - o2.capacity();
  }
150091
private boolean equivalent(int start1, int start2, int len) {
    if (start1 + len > size || start2 + len > size)
      return false;

    while (len-- > 0)
      if (serialized[start1++] != serialized[start2++])
        return false;

    return true;
  }
97558
function arrayBufferEquals(ab1, ab2) {
    if (ab1.byteLength !== ab2.byteLength) {
        return false;
    }
    var arr1 = new Uint8Array(ab1);
    var arr2 = new Uint8Array(ab2);
    for (var i = 0, len = arr1.length; i < len; i++) {
        if (arr1[i] !== arr2[i]) {
            return false;
        }
    }
    return true;
}
120426
def ct_bytes_compare(a, b):
    
    if not isinstance(a, bytes):
        a = a.decode('utf8')
    if not isinstance(b, bytes):
        b = b.decode('utf8')

    if len(a) != len(b):
        return False

    result = 0
    for x, y in zip(a, b):
        result |= x ^ y

    return (result == 0)
894664
private static boolean matchNaN(byte[] str, byte firstchar, int start, int end) {
    final int len = end - start;
    if(len < 2 || len > 3 || (firstchar != 'N' && firstchar != 'n')) {
      return false;
    }
    final byte c1 = str[start + 1];
    if(c1 != 'a' && c1 != 'A') {
      return false;
    }
    // Accept just "NA", too:
    if(len == 2) {
      return true;
    }
    final byte c2 = str[start + 2];
    return c2 == 'N' || c2 == 'n';
  }
251055
public static boolean equal(String str1, String str2) {
		return str1 != null && str2 != null && str1.equals(str2);
	}
1025209
function customBase64Hash(str, hashFunction) {
  const result = hashFunction(str).toString(encBase64);
  return customBase64(result);
}
213719
def diff_commonSuffix(self, text1, text2):
    
    # Quick check for common null cases.
    if not text1 or not text2 or text1[-1] != text2[-1]:
      return 0
    # Binary search.
    # Performance analysis: https://neil.fraser.name/news/2007/10/09/
    pointermin = 0
    pointermax = min(len(text1), len(text2))
    pointermid = pointermax
    pointerend = 0
    while pointermin < pointermid:
      if (text1[-pointermid:len(text1) - pointerend] ==
          text2[-pointermid:len(text2) - pointerend]):
        pointermin = pointermid
        pointerend = pointermin
      else:
        pointermax = pointermid
      pointermid = (pointermax - pointermin) // 2 + pointermin
    return pointermid
1202496
public static int compareUnsigned(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
    {
        return BestHolder.BEST.compare(b1, s1, l1, b2, s2, l2);
    }
180330
public static <T> SerializableComparator<T> hashCodeComparator() {
      return (o1, o2) -> {
         if (o1 == o2) {
            return 0;
         } else if (o1 == null) {
            return 1;
         } else if (o2 == null) {
            return -1;
         }
         return Integer.compare(o1.hashCode(), o2.hashCode());
      };
   }
1226517
public static long calculateLastSrTimestamp(long ntp1, long ntp2) {
		byte[] high = uIntLongToByteWord(ntp1);
		byte[] low = uIntLongToByteWord(ntp2);
		low[3] = low[1];
		low[2] = low[0];
		low[1] = high[3];
		low[0] = high[2];
		return bytesToUIntLong(low, 0);
	}
729991
public static long mixHash(String str) {
		long hash = str.hashCode();
		hash <<= 32;
		hash |= fnvHash(str);
		return hash;
	}
898684
public static boolean isEqual(byte ba1[], byte ba2[]) {
		if(ba1.length!=ba2.length)return false;
		for(int i = 0;i<ba1.length; ++i) {
			if(ba1[i]!=ba2[i])return false;
		}
		return true;
	}
122806
public static int compareHashes(int[] leftHashes, int[] rightHashes) {
        assert(leftHashes != null);
        assert(rightHashes != null);
        assert(leftHashes.length >= 3);
        assert(rightHashes.length >= 3);

        // Compare total checksum first
        if (leftHashes[0] == rightHashes[0]) {
            return -1;
        }
        int includedHashLeft = Math.min(leftHashes[2], MAX_HASHES_COUNT);
        int includedHashRight = Math.min(rightHashes[2], MAX_HASHES_COUNT);
        int includedHashMin = Math.min(includedHashLeft, includedHashRight);
        int pos = 0;
        for(int i = HEADER_OFFSET ; i < HEADER_OFFSET + includedHashMin; i += 2) {
            if(leftHashes[i] != rightHashes[i] || leftHashes[i + 1] != rightHashes[i + 1]) {
                return pos;
            }
            pos++;
        }
        // If the number of per-statement hashes is more than MAX_HASHES_COUNT and
        // the mismatched hash isn't included in the per-statement hashes
        return HASH_NOT_INCLUDE;
    }
1363147
public static function mb_similar_text($str1, $str2, &$percent = null)
    {
        if (0 === mb_strlen($str1) + mb_strlen($str2)) {
            $percent = 0.0;

            return 0;
        }

        $pos1 = $pos2 = $max = 0;
        $l1 = mb_strlen($str1);
        $l2 = mb_strlen($str2);

        for ($p = 0; $p < $l1; ++$p) {
            for ($q = 0; $q < $l2; ++$q) {
                for ($l = 0; ($p + $l < $l1) && ($q + $l < $l2) && mb_substr($str1, $p + $l, 1) === mb_substr($str2, $q + $l, 1); ++$l) {
                    // nothing to do
                }
                if ($l > $max) {
                    $max = $l;
                    $pos1 = $p;
                    $pos2 = $q;
                }
            }
        }

        $similarity = $max;
        if ($similarity) {
            if ($pos1 && $pos2) {
                $similarity += self::mb_similar_text(mb_substr($str1, 0, $pos1), mb_substr($str2, 0, $pos2));
            }
            if (($pos1 + $max < $l1) && ($pos2 + $max < $l2)) {
                $similarity += self::mb_similar_text(
                    mb_substr($str1, $pos1 + $max, $l1 - $pos1 - $max),
                    mb_substr($str2, $pos2 + $max, $l2 - $pos2 - $max)
                );
            }
        }

        $percent = ($similarity * 200.0) / ($l1 + $l2);

        return $similarity;
    }