Skip to content

Commit

Permalink
[core] Avoid hashbytes twice in HashLookupStoreReader
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi committed Jan 24, 2024
1 parent 3d8f14b commit 4cbd24d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,19 @@ public byte[] lookup(byte[] key) throws IOException {
return null;
}

if (bloomFilter != null && !bloomFilter.testHash(MurmurHashUtils.hashBytes(key))) {
int hashcode = MurmurHashUtils.hashBytes(key);
if (bloomFilter != null && !bloomFilter.testHash(hashcode)) {
return null;
}

long hash = MurmurHashUtils.hashBytesPositive(key);
long hashPositive = hashcode & 0x7fffffff;
int numSlots = slots[keyLength];
int slotSize = slotSizes[keyLength];
int indexOffset = indexOffsets[keyLength];
long dataOffset = dataOffsets[keyLength];

for (int probe = 0; probe < numSlots; probe++) {
long slot = (hash + probe) % numSlots;
long slot = (hashPositive + probe) % numSlots;
inputView.setReadPosition(indexOffset + slot * slotSize);
inputView.readFully(slotBuffer, 0, slotSize);

Expand Down

0 comments on commit 4cbd24d

Please sign in to comment.