Add test with fold_heads
Build the AAE tree equally using fold_heads. This is a pre-cursor to running this within Riak. In part this leans on some of the work done to improve standard Riak AAE with leveled. When rebuilding the standard AAE store only the head is required, and so this process was switched in riak_kv_sweeper to make a fold_heads request if supported by the backend. The head response is a proxy object, which when loaded into a riak_object will allow for access to object metadata, but will use the passed function if access to object contents is requested.
This commit is contained in:
parent
22709abcd6
commit
dd20132892
1 changed files with 175 additions and 143 deletions
|
@ -21,6 +21,8 @@ all() -> [
|
|||
].
|
||||
|
||||
-define(LMD_FORMAT, "~4..0w~2..0w~2..0w~2..0w~2..0w").
|
||||
-define(V1_VERS, 1).
|
||||
-define(MAGIC, 53). % riak_kv -> riak_object
|
||||
|
||||
many_put_compare(_Config) ->
|
||||
TreeSize = small,
|
||||
|
@ -76,7 +78,7 @@ many_put_compare(_Config) ->
|
|||
{ok, Bookie3} = leveled_bookie:book_start(StartOpts3),
|
||||
lists:foreach(fun(ObjL) -> testutil:riakload(Bookie3, ObjL) end, CLs),
|
||||
|
||||
% Now run a tictac query against both stores to see th extent to which
|
||||
% Now run a tictac query against both stores to see the extent to which
|
||||
% state between stores is consistent
|
||||
|
||||
TicTacQ = {tictactree_obj,
|
||||
|
@ -99,8 +101,9 @@ many_put_compare(_Config) ->
|
|||
[timer:now_diff(os:timestamp(), SWC0)]),
|
||||
io:format("Tree comparison shows ~w different leaves~n",
|
||||
[length(SegList0)]),
|
||||
AltList = leveled_tictac:find_dirtyleaves(TreeA,
|
||||
leveled_tictac:new_tree(0)),
|
||||
AltList =
|
||||
leveled_tictac:find_dirtyleaves(TreeA,
|
||||
leveled_tictac:new_tree(0, TreeSize)),
|
||||
io:format("Tree comparison shows ~w altered leaves~n",
|
||||
[length(AltList)]),
|
||||
true = length(SegList0) == 1,
|
||||
|
@ -108,6 +111,35 @@ many_put_compare(_Config) ->
|
|||
true = length(AltList) > 10000,
|
||||
% check there are a significant number of differences from empty
|
||||
|
||||
% Now run the same query by putting the tree-building responsibility onto
|
||||
% the fold_objects_fun
|
||||
HashFun =
|
||||
fun(_Key, Value) ->
|
||||
{proxy_object, HeadBin, _Size, _FetchFun} = binary_to_term(Value),
|
||||
<<?MAGIC:8/integer, ?V1_VERS:8/integer, VclockLen:32/integer,
|
||||
Rest/binary>> = HeadBin,
|
||||
<<VclockBin:VclockLen/binary, _NotNeeded/binary>> = Rest,
|
||||
erlang:phash2(lists:sort(binary_to_term(VclockBin)))
|
||||
end,
|
||||
FoldObjectsFun =
|
||||
fun(_Bucket, Key, Value, Acc) ->
|
||||
leveled_tictac:add_kv(Acc, Key, Value, HashFun)
|
||||
end,
|
||||
FoldQ = {foldheads_bybucket,
|
||||
o_rkv,
|
||||
"Bucket",
|
||||
{FoldObjectsFun, leveled_tictac:new_tree(0, TreeSize)}},
|
||||
{async, TreeAObjFolder} = leveled_bookie:book_returnfolder(Bookie2, FoldQ),
|
||||
SWB0Obj = os:timestamp(),
|
||||
TreeAObj = TreeAObjFolder(),
|
||||
io:format("Build tictac tree via object foldwith 200K objects in ~w~n",
|
||||
[timer:now_diff(os:timestamp(), SWB0Obj)]),
|
||||
SegList0Obj = leveled_tictac:find_dirtyleaves(TreeA, TreeAObj),
|
||||
io:format("Fold object compared with tictac fold has ~w diffs~n",
|
||||
[length(SegList0Obj)]),
|
||||
true = length(SegList0Obj) == 0,
|
||||
|
||||
%% Finding differing keys
|
||||
FoldKeysFun =
|
||||
fun(SegListToFind) ->
|
||||
fun(_B, K, Acc) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue