private boolean isSameKey(byte[] key, int offset, int length, long ref, int hashCode,
      WriteBuffers.Position readPos) {
    if (!compareHashBits(ref, hashCode)) {
      return false;  // Hash bits don't match.
    }
    writeBuffers.setReadPoint(getFirstRecordLengthsOffset(ref, readPos), readPos);
    int valueLength = (int)writeBuffers.readVLong(readPos),
        keyLength = (int)writeBuffers.readVLong(readPos);
    long keyOffset = Ref.getOffset(ref) - (valueLength + keyLength);
    // See the comment in the other isSameKey
    if (offset == 0) {
      return writeBuffers.isEqual(key, length, keyOffset, keyLength);
    } else {
      return writeBuffers.isEqual(key, offset, length, keyOffset, keyLength);
    }
  }
Same as {@link #isSameKey(long, int, long, int)} but for externally stored key.
ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java