From 6e5f5d2d442ad9e3d664f3d6a30f09e55c627fab Mon Sep 17 00:00:00 2001 From: martinsumner Date: Sat, 24 Dec 2016 18:13:55 +0000 Subject: [PATCH] Alter ordering don't try the cache hit before checking for presence, only look in the cache if protecting a lookup from the persisted part --- src/leveled_sst.erl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/leveled_sst.erl b/src/leveled_sst.erl index 1388280..f132d00 100644 --- a/src/leveled_sst.erl +++ b/src/leveled_sst.erl @@ -230,17 +230,17 @@ fetch(LedgerKey, Hash, State) -> {not_present, summary_bloom, null}; true -> Slot = lookup_slot(LedgerKey, Summary#summary.index), - CacheEntry = array:get(Slot#slot_index_value.slot_id, + SlotBloom = Slot#slot_index_value.bloom, + case is_check_slot_required({hash, Hash}, SlotBloom) of + false -> + {not_present, slot_bloom, null}; + true -> + CacheEntry = array:get(Slot#slot_index_value.slot_id, State#state.cache), - case CacheEntry of - {LedgerKey, CachedValue} -> - {{LedgerKey, CachedValue}, cache_entry, null}; - _ -> - SlotBloom = Slot#slot_index_value.bloom, - case is_check_slot_required({hash, Hash}, SlotBloom) of - false -> - {not_present, slot_bloom, null}; - true -> + case CacheEntry of + {LedgerKey, CachedValue} -> + {{LedgerKey, CachedValue}, cache_entry, null}; + _ -> SlotLook = lookup_in_slot(LedgerKey, {pointer, State#state.handle,