Refine query to accept fold functions

Need to be able to pass external fold functions into different queries,
to work as a Riak backend
This commit is contained in:
martinsumner 2016-11-18 15:53:22 +00:00
parent ac223ced68
commit 6684e8e1d3
6 changed files with 68 additions and 34 deletions

View file

@ -11,9 +11,9 @@
rotating_objects/1]).
all() -> [
small_load_with2i,
query_count,
rotating_objects
small_load_with2i %,
% query_count,
% rotating_objects
].
@ -40,6 +40,26 @@ small_load_with2i(_Config) ->
testutil:check_forlist(Bookie1, ChkList1),
testutil:check_forobject(Bookie1, TestObject),
% Find all keys index, and then just the last key
IdxQ1 = {index_query,
"Bucket",
{fun testutil:foldkeysfun/3, []},
{"idx1_bin", "#", "~"},
{true, undefined}},
{async, IdxFolder} = leveled_bookie:book_returnfolder(Bookie1, IdxQ1),
KeyList1 = lists:usort(IdxFolder()),
true = 10000 == length(KeyList1),
{LastTerm, LastKey} = lists:last(KeyList1),
IdxQ2 = {index_query,
{"Bucket", LastKey},
{fun testutil:foldkeysfun/3, []},
{"idx1_bin", LastTerm, "~"},
{false, undefined}},
{async, IdxFolderLK} = leveled_bookie:book_returnfolder(Bookie1, IdxQ2),
KeyList2 = lists:usort(IdxFolderLK()),
io:format("List should be last key ~w ~w~n", [LastKey, KeyList2]),
true = 1 == length(KeyList2),
%% Delete the objects from the ChkList removing the indexes
lists:foreach(fun({_RN, Obj, Spc}) ->
DSpc = lists:map(fun({add, F, T}) -> {remove, F, T}