Check fpr with 4 keys
Up key count in bloom
This commit is contained in:
parent
29a2d9fc35
commit
d5bcccf0ec
1 changed files with 13 additions and 16 deletions
|
@ -50,8 +50,8 @@ check_hash(_Hash, <<>>) ->
|
||||||
false;
|
false;
|
||||||
check_hash({_SegHash, Hash}, BloomBin) ->
|
check_hash({_SegHash, Hash}, BloomBin) ->
|
||||||
SlotSplit = (byte_size(BloomBin) div ?BITS_PER_KEY) - 1,
|
SlotSplit = (byte_size(BloomBin) div ?BITS_PER_KEY) - 1,
|
||||||
{Slot, H0, H1} = split_hash(Hash, SlotSplit),
|
{Slot, H0, H1, H2, H3} = split_hash(Hash, SlotSplit),
|
||||||
Mask = get_mask(H0, H1),
|
Mask = get_mask(H0, H1, H2, H3),
|
||||||
Pos = Slot * ?BITS_PER_KEY,
|
Pos = Slot * ?BITS_PER_KEY,
|
||||||
IntSize = ?INTEGER_SIZE,
|
IntSize = ?INTEGER_SIZE,
|
||||||
<<_H:Pos/binary, CheckInt:IntSize/integer, _T/binary>> = BloomBin,
|
<<_H:Pos/binary, CheckInt:IntSize/integer, _T/binary>> = BloomBin,
|
||||||
|
@ -70,15 +70,12 @@ split_hash(Hash, SlotSplit) ->
|
||||||
Slot = Hash band SlotSplit,
|
Slot = Hash band SlotSplit,
|
||||||
H0 = (Hash bsr 4) band (?BAND_MASK),
|
H0 = (Hash bsr 4) band (?BAND_MASK),
|
||||||
H1 = (Hash bsr 10) band (?BAND_MASK),
|
H1 = (Hash bsr 10) band (?BAND_MASK),
|
||||||
{Slot, H0, H1}.
|
H2 = (Hash bsr 16) band (?BAND_MASK),
|
||||||
|
H3 = (Hash bsr 24) band (?BAND_MASK),
|
||||||
|
{Slot, H0, H1, H2, H3}.
|
||||||
|
|
||||||
get_mask(H0, H1) ->
|
get_mask(H0, H1, H2, H3) ->
|
||||||
case H0 == H1 of
|
(1 bsl H0) bor (1 bsl H1) bor (1 bsl H2) bor (1 bsl H3).
|
||||||
true ->
|
|
||||||
1 bsl H0;
|
|
||||||
false ->
|
|
||||||
(1 bsl H0) + (1 bsl H1)
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
%% This looks ugly and clunky, but in tests it was quicker than modifying an
|
%% This looks ugly and clunky, but in tests it was quicker than modifying an
|
||||||
|
@ -88,8 +85,8 @@ add_hashlist([], _S, S0, S1) ->
|
||||||
IntSize = ?INTEGER_SIZE,
|
IntSize = ?INTEGER_SIZE,
|
||||||
<<S0:IntSize/integer, S1:IntSize/integer>>;
|
<<S0:IntSize/integer, S1:IntSize/integer>>;
|
||||||
add_hashlist([{_SegHash, TopHash}|T], SlotSplit, S0, S1) ->
|
add_hashlist([{_SegHash, TopHash}|T], SlotSplit, S0, S1) ->
|
||||||
{Slot, H0, H1} = split_hash(TopHash, SlotSplit),
|
{Slot, H0, H1, H2, H3} = split_hash(TopHash, SlotSplit),
|
||||||
Mask = get_mask(H0, H1),
|
Mask = get_mask(H0, H1, H2, H3),
|
||||||
case Slot of
|
case Slot of
|
||||||
0 ->
|
0 ->
|
||||||
add_hashlist(T, SlotSplit, S0 bor Mask, S1);
|
add_hashlist(T, SlotSplit, S0 bor Mask, S1);
|
||||||
|
@ -102,8 +99,8 @@ add_hashlist([], _S, S0, S1, S2, S3) ->
|
||||||
<<S0:IntSize/integer, S1:IntSize/integer,
|
<<S0:IntSize/integer, S1:IntSize/integer,
|
||||||
S2:IntSize/integer, S3:IntSize/integer>>;
|
S2:IntSize/integer, S3:IntSize/integer>>;
|
||||||
add_hashlist([{_SegHash, TopHash}|T], SlotSplit, S0, S1, S2, S3) ->
|
add_hashlist([{_SegHash, TopHash}|T], SlotSplit, S0, S1, S2, S3) ->
|
||||||
{Slot, H0, H1} = split_hash(TopHash, SlotSplit),
|
{Slot, H0, H1, H2, H3} = split_hash(TopHash, SlotSplit),
|
||||||
Mask = get_mask(H0, H1),
|
Mask = get_mask(H0, H1, H2, H3),
|
||||||
case Slot of
|
case Slot of
|
||||||
0 ->
|
0 ->
|
||||||
add_hashlist(T, SlotSplit, S0 bor Mask, S1, S2, S3);
|
add_hashlist(T, SlotSplit, S0 bor Mask, S1, S2, S3);
|
||||||
|
@ -130,8 +127,8 @@ add_hashlist([{_SegHash, TopHash}|T],
|
||||||
SlotSplit,
|
SlotSplit,
|
||||||
S0, S1, S2, S3, S4, S5, S6, S7, S8, S9,
|
S0, S1, S2, S3, S4, S5, S6, S7, S8, S9,
|
||||||
SA, SB, SC, SD, SE, SF) ->
|
SA, SB, SC, SD, SE, SF) ->
|
||||||
{Slot, H0, H1} = split_hash(TopHash, SlotSplit),
|
{Slot, H0, H1, H2, H3} = split_hash(TopHash, SlotSplit),
|
||||||
Mask = get_mask(H0, H1),
|
Mask = get_mask(H0, H1, H2, H3),
|
||||||
case Slot of
|
case Slot of
|
||||||
0 ->
|
0 ->
|
||||||
add_hashlist(T,
|
add_hashlist(T,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue