Sean Cribbs avatar Sean Cribbs committed 1089603

Stop this proliferation of *_bin and *_str generators by making simple wrappers instead.

Comments (0)

Files changed (9)

examples/bitcask.config

 
 {driver, basho_bench_driver_bitcask}.
 
-{key_generator, {uniform_int_bin, 5000000}}.
+{key_generator, {int_to_bin,{uniform_int, 5000000}}}.
 
 {value_generator, {fixed_bin, 10000}}.
 

examples/casbench.config

 
 {driver, basho_bench_driver_cassandra}.
 
-{key_generator, {uniform_int_str, 5000000}}.
+{key_generator, {int_to_str, {uniform_int, 5000000}}}.
 
 {value_generator, {fixed_bin, 10000}}.
 

examples/hibari.config

              ]}.
 
 %{key_generator, {uniform_int_bin, 35000}}.
-{key_generator, {uniform_int_bin, 99000}}.
+{key_generator, {int_to_bin, {uniform_int, 99000}}}.
 
 {value_generator, {fixed_bin, 1000}}.
 %{value_generator, {fixed_bin, 10000}}.

examples/httpraw.config

 
 {driver, basho_bench_driver_http_raw}.
 
-%{code_paths, ["deps/stats",
-%              "deps/ibrowse"]}.
+{code_paths, ["deps/ibrowse"]}.
 
-{key_generator, {external, test, hoss_seq, [10000, 10, 10, 100]}}.
+{key_generator, {function, test, mykeygen_seq, [10000, 10, 10, 100]}}.
 
 {value_generator, {fixed_bin, 10000}}.
 
-{http_raw_port, 8091}.
+{http_raw_port, 8098}.
 
 {operations, [{update, 1}]}.
 

examples/innostore_test.config

 {code_paths, ["deps/stats",
               "../innostore"]}.
 
-{key_generator, {uniform_int_bin, 500000}}.
+{key_generator, {int_to_bin, {uniform_int, 500000}}}.
 
 {value_generator, {fixed_bin, 10000}}.
 

examples/null_test.config

 
 {code_paths, ["deps/stats"]}.
 
-{key_generator, {sequential_int_bin, 5000000}}.
+{key_generator, {int_to_bin, {sequential_int, 5000000}}}.
 
 {value_generator, {fixed_bin, 10248}}.
 

examples/riakc_pb.config

               "deps/riakc",
               "deps/protobuffs"]}.
 
-{key_generator, {uniform_int_str, 10000}}.
+{key_generator, {int_to_bin, {uniform_int, 10000}}}.
 
 {value_generator, {fixed_bin, 10000}}.
 

examples/riakclient.config

               "/Users/jmeredith/basho/riak/apps/riak_kv",
               "/Users/jmeredith/basho/riak/apps/riak_core"]}.
 
-{key_generator, {uniform_int_bin, 35000}}.
+{key_generator, {int_to_bin, {uniform_int, 35000}}}.
 
 {value_generator, {fixed_bin, 10000}}.
 

src/basho_bench_keygen.erl

 %% ====================================================================
 %% API
 %% ====================================================================
-
+new({int_to_bin, InputGen}, Id) ->
+    Gen = new(InputGen, Id),
+    fun() -> <<(Gen()):32/native>> end;
+new({int_to_str, InputGen}, Id) ->
+    Gen = new(InputGen, Id),
+    fun() -> integer_to_list(Gen()) end;
 new({sequential_int, MaxKey}, _Id) ->
     Ref = make_ref(),
     fun() -> sequential_int_generator(Ref, MaxKey) end;
-new({sequential_int_bin, MaxKey}, _Id) ->
-    Ref = make_ref(),
-    fun() -> Key = sequential_int_generator(Ref, MaxKey), <<Key:32/native>> end;
-new({sequential_int_str, MaxKey}, _Id) ->
-    Ref = make_ref(),
-    fun() -> Key = sequential_int_generator(Ref, MaxKey), integer_to_list(Key) end;
 new({partitioned_sequential_int, MaxKey}, Id) ->
     new({partitioned_sequential_int, 0, MaxKey}, Id);
 new({partitioned_sequential_int, StartKey, NumKeys}, Id) ->
     Ref = make_ref(),
     ?DEBUG("ID ~p generating range ~p to ~p\n", [Id, MinValue, MaxValue]),
     fun() -> sequential_int_generator(Ref,Range) + MinValue end;
-new({partitioned_sequential_int_bin, MaxKey}, Id) ->
-    Gen = new({partitioned_sequential_int, MaxKey}, Id),
-    fun() -> <<(Gen()):32/native>> end;
-new({partitioned_sequential_int_bin, StartKey, NumKeys}, Id) ->
-    Gen = new({partitioned_sequential_int, StartKey, NumKeys}, Id),
-    fun() -> <<(Gen()):32/native>> end;
-new({partitioned_sequential_int_str, MaxKey}, Id) ->
-    Gen = new({partitioned_sequential_int, MaxKey}, Id),
-    fun() -> integer_to_list(Gen()) end;
-new({partitioned_sequential_int_str, StartKey, NumKeys}, Id) ->
-    Gen = new({partitioned_sequential_int, StartKey, NumKeys}, Id),
-    fun() -> integer_to_list(Gen()) end;
-new({uniform_int_bin, MaxKey}, _Id) ->
-    fun() -> Key = random:uniform(MaxKey), <<Key:32/native>> end;
-new({uniform_int_str, MaxKey}, _Id) ->
-    fun() -> Key = random:uniform(MaxKey), integer_to_list(Key) end;
 new({uniform_int, MaxKey}, _Id) ->
     fun() -> random:uniform(MaxKey) end;
 new({pareto_int, MaxKey}, _Id) ->
     pareto(trunc(MaxKey * 0.2), ?PARETO_SHAPE);
-new({pareto_int_bin, MaxKey}, _Id) ->
-    Pareto = pareto(trunc(MaxKey * 0.2), ?PARETO_SHAPE),
-    fun() -> <<(Pareto()):32/native>> end;
-new({pareto_int_str, MaxKey}, _Id) ->
-    Pareto = pareto(trunc(MaxKey * 0.2), ?PARETO_SHAPE),
-    fun() -> integer_to_list(Pareto()) end;
 new({truncated_pareto_int, MaxKey}, Id) ->
     Pareto = new({pareto_int, MaxKey}, Id),
     fun() -> erlang:min(MaxKey, Pareto()) end;
-new({truncated_pareto_int_bin, MaxKey}, Id) ->
-    TPareto = new({truncated_pareto_int, MaxKey}, Id),
-    fun() -> <<(TPareto()):32/native>> end;
 new({function, Module, Function, Args}, Id) ->
     case code:ensure_loaded(Module) of
         {module, Module} ->
 new(Other, _Id) ->
     ?FAIL_MSG("Unsupported key generator requested: ~p\n", [Other]).
 
-
+dimension({Converter, InputGen}) when Converter == int_to_str orelse Converter == int_to_bin ->
+    dimension(InputGen);
 dimension({sequential_int, MaxKey}) ->
     MaxKey;
-dimension({sequential_int_bin, MaxKey}) ->
-    MaxKey;
-dimension({sequential_int_str, MaxKey}) ->
-    MaxKey;
 dimension({partitioned_sequential_int, MaxKey}) ->
     MaxKey;
-dimension({partitioned_sequential_int_bin, MaxKey}) ->
-    MaxKey;
-dimension({partitioned_sequential_int_str, MaxKey}) ->
-    MaxKey;
-dimension({uniform_int_bin, MaxKey}) ->
-    MaxKey;
-dimension({uniform_int_str, MaxKey}) ->
-    MaxKey;
 dimension({uniform_int, MaxKey}) ->
     MaxKey;
 dimension(Other) ->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.