boolean isAt()

in src/main/java/com/spotify/sparkey/IndexHash.java [347:385]


  boolean isAt(int keyLen, byte[] key, long position, int entryIndex) throws IOException {
    HashType hashData = header.getHashType();
    AddressSize addressData = header.getAddressData();
    long hash = hashData.hash(keyLen, key, hashSeed);
    long wantedSlot = getWantedSlot(hash, hashCapacity);

    int start = indexStart;
    long pos = start + wantedSlot * slotSize;
    indexData.seek(pos);

    long slot = wantedSlot;
    long displacement = 0;
    while (true) {
      long hash2 = hashData.readHash(indexData);
      long position2 = addressData.readAddress(indexData);
      if (position2 == 0) {
        return false;
      }
      int entryIndex2 = (int) (position2) & entryBlockBitmask;
      position2 >>>= entryBlockBits;
      if (hash == hash2 && position2 == position && entryIndex == entryIndex2) {
        return true;
      }

      long otherDisplacement = getDisplacement(hashCapacity, slot, hash2);
      if (displacement > otherDisplacement) {
        return false;
      }

      pos += slotSize;
      displacement++;
      slot++;
      if (slot == hashCapacity) {
        pos = start;
        slot = 0;
        indexData.seek(start);
      }
    }
  }