Add tests for different tree sizes
Note that accelerating segment_list queries will not work for tree sizes smaller than small. How to flag this up? Should smaller tree sizes just be removed from leveled_tictac?
This commit is contained in:
parent
f80aae7d78
commit
81180e9310
3 changed files with 97 additions and 43 deletions
|
@ -66,7 +66,8 @@
|
|||
riak_extract_metadata/2,
|
||||
magic_hash/1,
|
||||
segment_hash/1,
|
||||
to_lookup/1]).
|
||||
to_lookup/1,
|
||||
riak_metadata_to_binary/2]).
|
||||
|
||||
-define(V1_VERS, 1).
|
||||
-define(MAGIC, 53). % riak_kv -> riak_object
|
||||
|
|
|
@ -274,13 +274,7 @@ sst_getkvrange(Pid, StartKey, EndKey, ScanWidth) ->
|
|||
%% To make the range open-ended (either ta start, end or both) the all atom
|
||||
%% can be use din place of the Key tuple.
|
||||
sst_getfilteredrange(Pid, StartKey, EndKey, ScanWidth, SegList) ->
|
||||
SegList0 =
|
||||
case is_list(SegList) of
|
||||
true ->
|
||||
lists:map(fun tune_hash/1, SegList);
|
||||
false ->
|
||||
SegList
|
||||
end,
|
||||
SegList0 = tune_seglist(SegList),
|
||||
case gen_fsm:sync_send_event(Pid,
|
||||
{get_kvrange,
|
||||
StartKey, EndKey,
|
||||
|
@ -309,13 +303,7 @@ sst_getslots(Pid, SlotList) ->
|
|||
%% returned (not precisely - with false results returned in addition). Use
|
||||
%% false as a SegList to not filter
|
||||
sst_getfilteredslots(Pid, SlotList, SegList) ->
|
||||
SegList0 =
|
||||
case is_list(SegList) of
|
||||
true ->
|
||||
lists:map(fun tune_hash/1, SegList);
|
||||
false ->
|
||||
SegList
|
||||
end,
|
||||
SegList0 = tune_seglist(SegList),
|
||||
SlotBins = gen_fsm:sync_send_event(Pid,
|
||||
{get_slots, SlotList, SegList0},
|
||||
infinity),
|
||||
|
@ -1339,6 +1327,14 @@ extra_hash(NotHash) ->
|
|||
tune_hash(SegHash) ->
|
||||
SegHash band 32767.
|
||||
|
||||
tune_seglist(SegList) ->
|
||||
case is_list(SegList) of
|
||||
true ->
|
||||
lists:map(fun tune_hash/1, SegList);
|
||||
false ->
|
||||
SegList
|
||||
end.
|
||||
|
||||
fetch_value([], _BlockLengths, _Blocks, _Key) ->
|
||||
not_present;
|
||||
fetch_value([Pos|Rest], BlockLengths, Blocks, Key) ->
|
||||
|
@ -2228,4 +2224,48 @@ nonsense_coverage_test() ->
|
|||
?assertMatch({reply, undefined, reader, #state{}},
|
||||
handle_sync_event("hello", self(), reader, #state{})).
|
||||
|
||||
hashmatching_bytreesize_test() ->
|
||||
B = <<"Bucket">>,
|
||||
V = leveled_codec:riak_metadata_to_binary(term_to_binary([{"actor1", 1}]),
|
||||
<<1:32/integer,
|
||||
0:32/integer,
|
||||
0:32/integer>>),
|
||||
GenKeyFun =
|
||||
fun(X) ->
|
||||
LK =
|
||||
{?RIAK_TAG,
|
||||
B,
|
||||
list_to_binary("Key" ++ integer_to_list(X)),
|
||||
null},
|
||||
LKV = leveled_codec:generate_ledgerkv(LK,
|
||||
X,
|
||||
V,
|
||||
byte_size(V),
|
||||
{active, infinity}),
|
||||
{_Bucket, _Key, MetaValue, _Hashes, _LastMods} = LKV,
|
||||
{LK, MetaValue}
|
||||
end,
|
||||
KVL = lists:map(GenKeyFun, lists:seq(1, 128)),
|
||||
{PosBinIndex1, _FullBin, _HL, _LK} =
|
||||
generate_binary_slot(lookup, KVL),
|
||||
check_segment_match(PosBinIndex1, KVL, small),
|
||||
check_segment_match(PosBinIndex1, KVL, medium).
|
||||
|
||||
|
||||
check_segment_match(PosBinIndex1, KVL, TreeSize) ->
|
||||
CheckFun =
|
||||
fun({{_T, B, K, null}, _V}) ->
|
||||
Seg =
|
||||
leveled_tictac:get_segment(
|
||||
leveled_tictac:keyto_segment32(<<B/binary, K/binary>>),
|
||||
TreeSize),
|
||||
SegList0 = tune_seglist([Seg]),
|
||||
PosList = find_pos(PosBinIndex1, SegList0, [], 0),
|
||||
?assertMatch(true, length(PosList) >= 1)
|
||||
end,
|
||||
lists:foreach(CheckFun, KVL).
|
||||
|
||||
|
||||
|
||||
|
||||
-endif.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue