Skip to content

Commit

Permalink
Standardize error handling and name of "function" tuple across key an…
Browse files Browse the repository at this point in the history
…d value gen
  • Loading branch information
dizzyd committed Aug 29, 2010
1 parent 4cf3de6 commit ab613d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/basho_bench_keygen.erl
Expand Up @@ -54,8 +54,13 @@ new({pareto_int, MaxKey}, _Id) ->
new({pareto_int_bin, MaxKey}, _Id) ->
Pareto = pareto(trunc(MaxKey * 0.2), ?PARETO_SHAPE),
fun() -> <<(Pareto()):32/native>> end;
new({external, M, F, A}, Id) ->
apply(M, F, [Id] ++ A);
new({function, Module, Function, Args}, Id) ->
case code:ensure_loaded(Module) of
{module, Module} ->
erlang:apply(Module, Function, [Id] ++ Args);
_Error ->
?FAIL_MSG("Could not find keygen function: ~p:~p\n", [Module, Function])
end;
new(Other, _Id) ->
?FAIL_MSG("Unsupported key generator requested: ~p\n", [Other]).

Expand Down
11 changes: 5 additions & 6 deletions src/basho_bench_valgen.erl
Expand Up @@ -40,13 +40,12 @@ new({uniform_bin, MinSize, MaxSize}, _Id) ->
Source = init_source(),
Diff = MaxSize - MinSize,
fun() -> data_block(Source, MinSize + random:uniform(Diff)) end;
new({function, Module, Function, Args}, _Id) ->
new({function, Module, Function, Args}, Id) ->
case code:ensure_loaded(Module) of
{module, Module} ->
erlang:apply(Module, Function, Args);
_Error ->
error_logger:error_msg("Could not find module: ~p~n", [Module]),
throw({error, module_not_found, Module})
{module, Module} ->
erlang:apply(Module, Function, [Id] ++ Args);
_Error ->
?FAIL_MSG("Could not find valgen function: ~p:~p\n", [Module, Function])
end;
new(Other, _Id) ->
?FAIL_MSG("Unsupported value generator requested: ~p\n", [Other]).
Expand Down

0 comments on commit ab613d7

Please sign in to comment.