Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/basho_bench_driver_riakc_pb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ run(delete, KeyGen, _ValueGen, State) ->
{error, Reason} ->
{error, Reason, State}
end;
run(delete_create, KeyGen, ValueGen, State) ->
Key = KeyGen(),

PutResult = maybe_put_key(Key, ValueGen, State),
DeleteResult = maybe_delete_key(PutResult, Key),
maybe_put_key(DeleteResult, Key, ValueGen);

run(listkeys, _KeyGen, _ValueGen, State) ->
%% Pass on rw
case riakc_pb_socket:list_keys(State#state.pid, State#state.bucket, State#state.timeout_listkeys) of
Expand Down Expand Up @@ -509,6 +516,44 @@ run(counter_val, KeyGen, _ValueGen, State) ->
%% ====================================================================
%% Internal functions
%% ====================================================================
maybe_delete_key({ok, State}, Key) ->
Result = case riakc_pb_socket:delete(State#state.pid, State#state.bucket, Key,
[{w, all}, {pw, all}, {dw, all}], State#state.timeout_write) of
ok ->
{ok, State};
{error, Reason} ->
{error, Reason, State}
end,
maybe_durable_get(Result, Key);
maybe_delete_key({error, Reason, State}, _Key) ->
{error, Reason, State}.

maybe_durable_get({ok, State}, Key) ->
case riakc_pb_socket:get(State#state.pid, State#state.bucket, Key,
[{r, all}, {pr, all}], State#state.timeout_read) of
{ok, _} ->
{ok, State};
{error, notfound} ->
{ok, State};
{error, Reason} ->
{error, Reason, State}
end;
maybe_durable_get({error, Reason, State}, _Key) ->
{error, Reason, State}.


maybe_put_key({ok, State}, Key, ValueGen) ->
maybe_put_key(Key, ValueGen, State);
maybe_put_key({error, Reason, State}, _Key, _ValueGen) ->
{error, Reason, State};
maybe_put_key(Key, ValueGen, State) ->
Robj = riakc_obj:new(State#state.bucket, Key, ValueGen(), State#state.content_type),
case riakc_pb_socket:put(State#state.pid, Robj, [{w, all}, {dw, all}], State#state.timeout_write) of
ok ->
{ok, State};
{error, Reason} ->
{error, Reason, State}
end.

mapred(State, Input, Query) ->
case riakc_pb_socket:mapred(State#state.pid, Input, Query, State#state.timeout_mapreduce) of
Expand Down