Switch to binary format Riak object
Initial change to try and test assuming that leveled received the binary format of Riak objects (and parses that for metadata).
This commit is contained in:
parent
b0a515553f
commit
e8c1d39df9
6 changed files with 212 additions and 177 deletions
|
@ -968,112 +968,6 @@ generate_multiple_objects(Count, KeyNumber, ObjL) ->
|
|||
KeyNumber + 1,
|
||||
ObjL ++ [{Key, Value, IndexSpec}]).
|
||||
|
||||
|
||||
generate_multiple_robjects(Count, KeyNumber) ->
|
||||
generate_multiple_robjects(Count, KeyNumber, []).
|
||||
|
||||
generate_multiple_robjects(0, _KeyNumber, ObjL) ->
|
||||
ObjL;
|
||||
generate_multiple_robjects(Count, KeyNumber, ObjL) ->
|
||||
Obj = {"Bucket",
|
||||
"Key" ++ integer_to_list(KeyNumber),
|
||||
crypto:rand_bytes(1024),
|
||||
[],
|
||||
[{"MDK", "MDV" ++ integer_to_list(KeyNumber)},
|
||||
{"MDK2", "MDV" ++ integer_to_list(KeyNumber)}]},
|
||||
{B1, K1, V1, Spec1, MD} = Obj,
|
||||
Content = #r_content{metadata=MD, value=V1},
|
||||
Obj1 = #r_object{bucket=B1, key=K1, contents=[Content], vclock=[{'a',1}]},
|
||||
generate_multiple_robjects(Count - 1, KeyNumber + 1, ObjL ++ [{Obj1, Spec1}]).
|
||||
|
||||
|
||||
single_key_test() ->
|
||||
RootPath = reset_filestructure(),
|
||||
{ok, Bookie1} = book_start([{root_path, RootPath}]),
|
||||
{B1, K1, V1, Spec1, MD} = {"Bucket1",
|
||||
"Key1",
|
||||
"Value1",
|
||||
[],
|
||||
{"MDK1", "MDV1"}},
|
||||
Content = #r_content{metadata=MD, value=V1},
|
||||
Object = #r_object{bucket=B1, key=K1, contents=[Content], vclock=[{'a',1}]},
|
||||
ok = book_put(Bookie1, B1, K1, Object, Spec1, ?RIAK_TAG),
|
||||
{ok, F1} = book_get(Bookie1, B1, K1, ?RIAK_TAG),
|
||||
?assertMatch(F1, Object),
|
||||
ok = book_close(Bookie1),
|
||||
{ok, Bookie2} = book_start([{root_path, RootPath}]),
|
||||
{ok, F2} = book_get(Bookie2, B1, K1, ?RIAK_TAG),
|
||||
?assertMatch(F2, Object),
|
||||
ok = book_close(Bookie2),
|
||||
reset_filestructure().
|
||||
|
||||
multi_key_test() ->
|
||||
RootPath = reset_filestructure(),
|
||||
{ok, Bookie1} = book_start([{root_path, RootPath}]),
|
||||
{B1, K1, V1, Spec1, MD1} = {"Bucket",
|
||||
"Key1",
|
||||
"Value1",
|
||||
[],
|
||||
{"MDK1", "MDV1"}},
|
||||
C1 = #r_content{metadata=MD1, value=V1},
|
||||
Obj1 = #r_object{bucket=B1, key=K1, contents=[C1], vclock=[{'a',1}]},
|
||||
{B2, K2, V2, Spec2, MD2} = {"Bucket",
|
||||
"Key2",
|
||||
"Value2",
|
||||
[],
|
||||
{"MDK2", "MDV2"}},
|
||||
C2 = #r_content{metadata=MD2, value=V2},
|
||||
Obj2 = #r_object{bucket=B2, key=K2, contents=[C2], vclock=[{'a',1}]},
|
||||
ok = book_put(Bookie1, B1, K1, Obj1, Spec1, ?RIAK_TAG),
|
||||
ObjL1 = generate_multiple_robjects(20, 3),
|
||||
SW1 = os:timestamp(),
|
||||
lists:foreach(fun({O, S}) ->
|
||||
{B, K} = leveled_codec:riakto_keydetails(O),
|
||||
ok = book_put(Bookie1, B, K, O, S, ?RIAK_TAG)
|
||||
end,
|
||||
ObjL1),
|
||||
io:format("PUT of 20 objects completed in ~w microseconds~n",
|
||||
[timer:now_diff(os:timestamp(),SW1)]),
|
||||
ok = book_put(Bookie1, B2, K2, Obj2, Spec2, ?RIAK_TAG),
|
||||
{ok, F1A} = book_get(Bookie1, B1, K1, ?RIAK_TAG),
|
||||
?assertMatch(F1A, Obj1),
|
||||
{ok, F2A} = book_get(Bookie1, B2, K2, ?RIAK_TAG),
|
||||
?assertMatch(F2A, Obj2),
|
||||
ObjL2 = generate_multiple_robjects(20, 23),
|
||||
SW2 = os:timestamp(),
|
||||
lists:foreach(fun({O, S}) ->
|
||||
{B, K} = leveled_codec:riakto_keydetails(O),
|
||||
ok = book_put(Bookie1, B, K, O, S, ?RIAK_TAG)
|
||||
end,
|
||||
ObjL2),
|
||||
io:format("PUT of 20 objects completed in ~w microseconds~n",
|
||||
[timer:now_diff(os:timestamp(),SW2)]),
|
||||
{ok, F1B} = book_get(Bookie1, B1, K1, ?RIAK_TAG),
|
||||
?assertMatch(F1B, Obj1),
|
||||
{ok, F2B} = book_get(Bookie1, B2, K2, ?RIAK_TAG),
|
||||
?assertMatch(F2B, Obj2),
|
||||
ok = book_close(Bookie1),
|
||||
% Now reopen the file, and confirm that a fetch is still possible
|
||||
{ok, Bookie2} = book_start([{root_path, RootPath}]),
|
||||
{ok, F1C} = book_get(Bookie2, B1, K1, ?RIAK_TAG),
|
||||
?assertMatch(F1C, Obj1),
|
||||
{ok, F2C} = book_get(Bookie2, B2, K2, ?RIAK_TAG),
|
||||
?assertMatch(F2C, Obj2),
|
||||
ObjL3 = generate_multiple_robjects(20, 43),
|
||||
SW3 = os:timestamp(),
|
||||
lists:foreach(fun({O, S}) ->
|
||||
{B, K} = leveled_codec:riakto_keydetails(O),
|
||||
ok = book_put(Bookie2, B, K, O, S, ?RIAK_TAG)
|
||||
end,
|
||||
ObjL3),
|
||||
io:format("PUT of 20 objects completed in ~w microseconds~n",
|
||||
[timer:now_diff(os:timestamp(),SW3)]),
|
||||
{ok, F1D} = book_get(Bookie2, B1, K1, ?RIAK_TAG),
|
||||
?assertMatch(F1D, Obj1),
|
||||
{ok, F2D} = book_get(Bookie2, B2, K2, ?RIAK_TAG),
|
||||
?assertMatch(F2D, Obj2),
|
||||
ok = book_close(Bookie2),
|
||||
reset_filestructure().
|
||||
|
||||
ttl_test() ->
|
||||
RootPath = reset_filestructure(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue