-
-
Save zhenchuan/ac33042b68f4b01733da to your computer and use it in GitHub Desktop.
IndexHash.java#L275
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
displacement ++ ; //here! | |
pos += slotSize; | |
slot++; | |
if (slot == hashCapacity) { | |
pos = start; | |
slot = 0; | |
indexData.seek(start); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment