Add support for buckets that are tuples

Only {binary(), binary()} tuples
This commit is contained in:
Martin Sumner 2018-09-27 09:34:40 +01:00
parent cbd7713c71
commit 0fb35e658f
3 changed files with 23 additions and 6 deletions

View file

@ -181,7 +181,7 @@
-type head_timings() :: no_timing|#head_timings{}. -type head_timings() :: no_timing|#head_timings{}.
-type timing_types() :: head|get|put|fold. -type timing_types() :: head|get|put|fold.
-type recent_aae() :: false|#recent_aae{}|undefined. -type recent_aae() :: false|#recent_aae{}|undefined.
-type key() :: binary()|string(). -type key() :: binary()|string()|{binary(), binary()}.
% Keys SHOULD be binary() % Keys SHOULD be binary()
% string() support is a legacy of old tests % string() support is a legacy of old tests
-type open_options() :: -type open_options() ::

View file

@ -843,7 +843,9 @@ get_metadata_from_siblings(<<ValLen:32/integer, Rest0/binary>>,
next_key(Key) when is_binary(Key) -> next_key(Key) when is_binary(Key) ->
<<Key/binary, 0>>; <<Key/binary, 0>>;
next_key(Key) when is_list(Key) -> next_key(Key) when is_list(Key) ->
Key ++ [0]. Key ++ [0];
next_key({Type, Bucket}) when is_binary(Type), is_binary(Bucket) ->
{Type, next_key(Bucket)}.
%%%============================================================================ %%%============================================================================

View file

@ -500,7 +500,7 @@ multibucket_fold(_Config) ->
[], [],
ObjectGen, ObjectGen,
IndexGen, IndexGen,
<<"Bucket1">>), {<<"Type1">>, <<"Bucket1">>}),
testutil:riakload(Bookie1, ObjL1), testutil:riakload(Bookie1, ObjL1),
ObjL2 = testutil:generate_objects(17000, ObjL2 = testutil:generate_objects(17000,
uuid, uuid,
@ -521,7 +521,7 @@ multibucket_fold(_Config) ->
[], [],
ObjectGen, ObjectGen,
IndexGen, IndexGen,
<<"Bucket4">>), {<<"Type2">>, <<"Bucket4">>}),
testutil:riakload(Bookie1, ObjL4), testutil:riakload(Bookie1, ObjL4),
FF = fun(B, K, _PO, Acc) -> FF = fun(B, K, _PO, Acc) ->
@ -531,7 +531,9 @@ multibucket_fold(_Config) ->
{async, R1} = leveled_bookie:book_headfold(Bookie1, {async, R1} = leveled_bookie:book_headfold(Bookie1,
?RIAK_TAG, ?RIAK_TAG,
{bucket_list, [<<"Bucket1">>, <<"Bucket4">>]}, {bucket_list,
[{<<"Type1">>, <<"Bucket1">>},
{<<"Type2">>, <<"Bucket4">>}]},
FoldAccT, FoldAccT,
false, false,
true, true,
@ -556,7 +558,20 @@ multibucket_fold(_Config) ->
true = 36000 == O1, true = 36000 == O1,
true = 24000 == O2, true = 24000 == O2,
FoldBucketsFun = fun(B, Acc) -> [B|Acc] end,
{async, Folder} =
leveled_bookie:book_bucketlist(Bookie1,
?RIAK_TAG,
{FoldBucketsFun, []},
all),
BucketList = Folder(),
ExpectedBucketList =
[{<<"Type1">>, <<"Bucket1">>}, {<<"Type2">>, <<"Bucket4">>},
<<"Bucket2">>, <<"Bucket3">>],
io:format("BucketList ~w", [BucketList]),
true = ExpectedBucketList == BucketList,
ok = leveled_bookie:book_close(Bookie1), ok = leveled_bookie:book_close(Bookie1),
testutil:reset_filestructure(). testutil:reset_filestructure().