Skip to content

Commit 5e9ac61

Browse files
committed
Add delete_unique as an option
1 parent a36a367 commit 5e9ac61

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

examples/riakc_nhs_general.config

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{mode, max}.
22

3-
{duration, 1440}.
3+
{duration, 2880}.
44

55
{report_interval, 10}.
66

@@ -18,18 +18,20 @@
1818
%% For alwaysget operations what is:
1919
%% - the maximum number of keys per worker (max number of keys = this * concurrent)
2020
%% - whether the inserts should be in key_order
21-
{alwaysget, {240000, 100000, skew_order}}.
21+
{alwaysget, {1000000, 300000, skew_order}}.
2222
{unique, {8000, skew_order}}.
2323

2424
{pb_ips, [{127,0,0,1}]}.
2525
{http_ips, [{127,0,0,1}]}.
2626

2727
{riakc_pb_replies, 1}.
2828

29-
{operations, [{alwaysget_pb, 651}, {alwaysget_updatewith2i, 120},
30-
{put_unique, 95}, {get_unique, 130},
29+
{operations, [{alwaysget_pb, 621}, {alwaysget_updatewith2i, 130},
30+
{put_unique, 90}, {get_unique, 130}, {delete_unique, 25},
3131
{postcodequery_http, 3}, {dobquery_http, 1}]}.
3232

33+
%
34+
3335
%% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013).
3436
%% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options.
3537
{pb_connect_options, [{auto_reconnect, true}]}.

rebar.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
{folsom, ".*", {git, "git://github.com/basho/folsom.git", {branch, "boundary-0.7.1+basho-bench-float"}}},
2020
{lager, "2.*", {git, "git://github.com/basho/lager", {tag, "2.1.0"}}},
2121
{ibrowse, ".*",
22-
{git, "git://github.com/cmullaparthi/ibrowse.git", {tag, "v4.0.2"}}},
22+
{git, "git://github.com/basho/ibrowse.git", {branch, "develop-2.9"}}},
2323
{riakc, ".*",
24-
{git, "git://github.com/basho/riak-erlang-client", {branch, "master"}}},
25-
{mochiweb, "2.9.*",
26-
{git, "git://github.com/basho/mochiweb", {tag, "v2.9.0"}}},
24+
{git, "git://github.com/basho/riak-erlang-client", {branch, "develop-2.9"}}},
25+
{mochiweb, ".*",
26+
{git, "git://github.com/basho/mochiweb", {branch, "develop-2.9"}}},
2727
{getopt, ".*",
2828
{git, "git://github.com/jcomellas/getopt", {tag, "v0.8.2"}}},
2929

src/basho_bench_driver_nhs.erl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
% ID 1 is nominated to do special work
5555
singleton_pid :: pid() | undefined,
5656
unique_key_count = 1 :: non_neg_integer(),
57+
unique_key_lowcount = 1 :: non_neg_integer(),
5758
alwaysget_key_count = 1 :: non_neg_integer(),
5859
keyid :: binary(),
5960
last_forceaae = os:timestamp() :: erlang:timestamp()
@@ -432,7 +433,8 @@ run(get_unique, _KeyGen, _ValueGen, State) ->
432433
Pid = State#state.pb_pid,
433434
Bucket = State#state.documentBucket,
434435
UKC = State#state.unique_key_count,
435-
Key = generate_uniquekey(random:uniform(UKC),
436+
LKC = State#state.unique_key_lowcount,
437+
Key = generate_uniquekey(LKC + random:uniform(UKC - LKC),
436438
State#state.keyid,
437439
State#state.unique_keyorder),
438440
case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of
@@ -443,6 +445,28 @@ run(get_unique, _KeyGen, _ValueGen, State) ->
443445
{error, Reason} ->
444446
{error, Reason, State}
445447
end;
448+
run(delete_unique, _KeyGen, _ValueGen, State) ->
449+
%% Delete one of the unique keys, assuming that the deletions have not
450+
%% caught up with the PUTs
451+
Pid = State#state.pb_pid,
452+
B = State#state.documentBucket,
453+
UKC = State#state.unique_key_count,
454+
LKC = State#state.unique_key_lowcount,
455+
case LKC < UKC of
456+
true ->
457+
Key = generate_uniquekey(LKC,
458+
State#state.keyid,
459+
State#state.unique_keyorder),
460+
R = riakc_pb_socket:delete(Pid, B, Key, State#state.pb_timeout),
461+
case R of
462+
ok ->
463+
{ok, State#state{unique_key_lowcount = LKC + 1}};
464+
{error, Reason} ->
465+
{error, Reason, State#state{unique_key_lowcount = LKC + 1}}
466+
end;
467+
false ->
468+
{ok, State}
469+
end;
446470

447471
%% Query results via the HTTP interface.
448472
run(postcodequery_http, _KeyGen, _ValueGen, State) ->

0 commit comments

Comments
 (0)