@@ -62,14 +62,16 @@ new({concat_binary, OneGen, TwoGen}, Id) ->
6262 fun () ->
6363 <<(Gen1 ())/binary , (Gen2 ())/binary >>
6464 end ;
65- new ({sequential_int , MaxKey }, Id ) ->
65+ new ({sequential_int , MaxKey }, Id )
66+ when is_integer (MaxKey ), MaxKey > 0 ->
6667 Ref = make_ref (),
6768 DisableProgress =
6869 basho_bench_config :get (disable_sequential_int_progress_report , false ),
6970 fun () -> sequential_int_generator (Ref , MaxKey , Id , DisableProgress ) end ;
7071new ({partitioned_sequential_int , MaxKey }, Id ) ->
7172 new ({partitioned_sequential_int , 0 , MaxKey }, Id );
72- new ({partitioned_sequential_int , StartKey , NumKeys }, Id ) ->
73+ new ({partitioned_sequential_int , StartKey , NumKeys }, Id )
74+ when is_integer (StartKey ), is_integer (NumKeys ), NumKeys > 0 ->
7375 Workers = basho_bench_config :get (concurrent ),
7476 Range = NumKeys div Workers ,
7577 MinValue = StartKey + Range * (Id - 1 ),
@@ -81,18 +83,22 @@ new({partitioned_sequential_int, StartKey, NumKeys}, Id) ->
8183 basho_bench_config :get (disable_sequential_int_progress_report , false ),
8284 ? DEBUG (" ID ~p generating range ~p to ~p \n " , [Id , MinValue , MaxValue ]),
8385 fun () -> sequential_int_generator (Ref , MaxValue - MinValue , Id , DisableProgress ) + MinValue end ;
84- new ({uniform_int , MaxKey }, _Id ) ->
86+ new ({uniform_int , MaxKey }, _Id )
87+ when is_integer (MaxKey ), MaxKey > 0 ->
8588 fun () -> random :uniform (MaxKey ) end ;
86- new ({uniform_int , StartKey , NumKeys }, _Id ) ->
89+ new ({uniform_int , StartKey , NumKeys }, _Id )
90+ when is_integer (StartKey ), is_integer (NumKeys ), NumKeys > 0 ->
8791 fun () -> random :uniform (NumKeys ) + StartKey - 1 end ;
88- new ({pareto_int , MaxKey }, _Id ) ->
92+ new ({pareto_int , MaxKey }, _Id )
93+ when is_integer (MaxKey ), MaxKey > 0 ->
8994 pareto (trunc (MaxKey * 0.2 ), ? PARETO_SHAPE );
9095new ({truncated_pareto_int , MaxKey }, Id ) ->
9196 Pareto = new ({pareto_int , MaxKey }, Id ),
9297 fun () -> erlang :min (MaxKey , Pareto ()) end ;
9398new (uuid_v4 , _Id ) ->
9499 fun () -> uuid :v4 () end ;
95- new ({function , Module , Function , Args }, Id ) ->
100+ new ({function , Module , Function , Args }, Id )
101+ when is_atom (Module ), is_atom (Function ), is_list (Args ) ->
96102 case code :ensure_loaded (Module ) of
97103 {module , Module } ->
98104 erlang :apply (Module , Function , [Id ] ++ Args );
@@ -106,7 +112,7 @@ new({valgen, ValGen}, Id) ->
106112new (Bin , _Id ) when is_binary (Bin ) ->
107113 fun () -> Bin end ;
108114new (Other , _Id ) ->
109- ? FAIL_MSG (" Unsupported key generator requested: ~p \n " , [Other ]).
115+ ? FAIL_MSG (" Invalid key generator requested: ~p \n " , [Other ]).
110116
111117dimension ({int_to_str , InputGen }) ->
112118 dimension (InputGen );
0 commit comments