Add compatibility for old and new random / rand functions
This commit is contained in:
parent
a49d3bbfec
commit
25389893cf
22 changed files with 125 additions and 74 deletions
|
@ -424,4 +424,4 @@ restart_from_blankledger(BookOpts, B_SpcL) ->
|
|||
end,
|
||||
B_SpcL),
|
||||
ok = leveled_bookie:book_close(Book1),
|
||||
ok.
|
||||
ok.
|
||||
|
|
|
@ -298,7 +298,7 @@ generate_compressibleobjects(Count, KeyNumber) ->
|
|||
|
||||
|
||||
get_compressiblevalue_andinteger() ->
|
||||
{random:uniform(1000), get_compressiblevalue()}.
|
||||
{leveled_rand:uniform(1000), get_compressiblevalue()}.
|
||||
|
||||
get_compressiblevalue() ->
|
||||
S1 = "111111111111111",
|
||||
|
@ -313,7 +313,7 @@ get_compressiblevalue() ->
|
|||
{5, S5}, {6, S6}, {7, S7}, {8, S8}],
|
||||
L = lists:seq(1, 1024),
|
||||
lists:foldl(fun(_X, Acc) ->
|
||||
{_, Str} = lists:keyfind(random:uniform(8), 1, Selector),
|
||||
{_, Str} = lists:keyfind(leveled_rand:uniform(8), 1, Selector),
|
||||
Acc ++ Str end,
|
||||
"",
|
||||
L).
|
||||
|
@ -340,7 +340,7 @@ generate_objects(Count, binary_uuid, ObjL, Value, IndexGen, Bucket) ->
|
|||
IndexGen),
|
||||
generate_objects(Count - 1,
|
||||
binary_uuid,
|
||||
ObjL ++ [{random:uniform(), Obj1, Spec1}],
|
||||
ObjL ++ [{leveled_rand:uniform(), Obj1, Spec1}],
|
||||
Value,
|
||||
IndexGen,
|
||||
Bucket);
|
||||
|
@ -351,7 +351,7 @@ generate_objects(Count, uuid, ObjL, Value, IndexGen, Bucket) ->
|
|||
IndexGen),
|
||||
generate_objects(Count - 1,
|
||||
uuid,
|
||||
ObjL ++ [{random:uniform(), Obj1, Spec1}],
|
||||
ObjL ++ [{leveled_rand:uniform(), Obj1, Spec1}],
|
||||
Value,
|
||||
IndexGen,
|
||||
Bucket);
|
||||
|
@ -362,7 +362,7 @@ generate_objects(Count, KeyNumber, ObjL, Value, IndexGen, Bucket) ->
|
|||
IndexGen),
|
||||
generate_objects(Count - 1,
|
||||
KeyNumber + 1,
|
||||
ObjL ++ [{random:uniform(), Obj1, Spec1}],
|
||||
ObjL ++ [{leveled_rand:uniform(), Obj1, Spec1}],
|
||||
Value,
|
||||
IndexGen,
|
||||
Bucket).
|
||||
|
@ -392,11 +392,11 @@ set_object(Bucket, Key, Value, IndexGen, Indexes2Remove) ->
|
|||
|
||||
generate_vclock() ->
|
||||
lists:map(fun(X) ->
|
||||
{_, Actor} = lists:keyfind(random:uniform(10),
|
||||
{_, Actor} = lists:keyfind(leveled_rand:uniform(10),
|
||||
1,
|
||||
actor_list()),
|
||||
{Actor, X} end,
|
||||
lists:seq(1, random:uniform(8))).
|
||||
lists:seq(1, leveled_rand:uniform(8))).
|
||||
|
||||
|
||||
actor_list() ->
|
||||
|
@ -469,14 +469,14 @@ name_list() ->
|
|||
|
||||
get_randomname() ->
|
||||
NameList = name_list(),
|
||||
N = random:uniform(16),
|
||||
N = leveled_rand:uniform(16),
|
||||
{N, Name} = lists:keyfind(N, 1, NameList),
|
||||
Name.
|
||||
|
||||
get_randomdate() ->
|
||||
LowTime = 60000000000,
|
||||
HighTime = 70000000000,
|
||||
RandPoint = LowTime + random:uniform(HighTime - LowTime),
|
||||
RandPoint = LowTime + leveled_rand:uniform(HighTime - LowTime),
|
||||
Date = calendar:gregorian_seconds_to_datetime(RandPoint),
|
||||
{{Year, Month, Day}, {Hour, Minute, Second}} = Date,
|
||||
lists:flatten(io_lib:format("~4..0w~2..0w~2..0w~2..0w~2..0w~2..0w",
|
||||
|
|
|
@ -1039,4 +1039,4 @@ get_tictactree_fun(Bookie, Bucket, TreeSize) ->
|
|||
"~w microseconds~n",
|
||||
[LMD, timer:now_diff(os:timestamp(), SW)]),
|
||||
leveled_tictac:merge_trees(R, Acc)
|
||||
end.
|
||||
end.
|
||||
|
|
|
@ -41,7 +41,7 @@ go_dict(_, 0, _) ->
|
|||
{erlang:memory(), statistics(garbage_collection)};
|
||||
go_dict(D, N, M) ->
|
||||
% Lookup a random key - which may not be present
|
||||
LookupKey = lists:concat(["key-", random:uniform(M)]),
|
||||
LookupKey = lists:concat(["key-", leveled_rand:uniform(M)]),
|
||||
LookupHash = hash(LookupKey),
|
||||
dict:find(LookupHash, D),
|
||||
|
||||
|
@ -71,7 +71,7 @@ go_ets(_, 0, _) ->
|
|||
{erlang:memory(), statistics(garbage_collection)};
|
||||
go_ets(Ets, N, M) ->
|
||||
% Lookup a random key - which may not be present
|
||||
LookupKey = lists:concat(["key-", random:uniform(M)]),
|
||||
LookupKey = lists:concat(["key-", leveled_rand:uniform(M)]),
|
||||
LookupHash = hash(LookupKey),
|
||||
ets:lookup(Ets, LookupHash),
|
||||
|
||||
|
@ -95,7 +95,7 @@ go_gbtree(_, 0, _) ->
|
|||
{erlang:memory(), statistics(garbage_collection)};
|
||||
go_gbtree(Tree, N, M) ->
|
||||
% Lookup a random key - which may not be present
|
||||
LookupKey = lists:concat(["key-", random:uniform(M)]),
|
||||
LookupKey = lists:concat(["key-", leveled_rand:uniform(M)]),
|
||||
LookupHash = hash(LookupKey),
|
||||
gb_trees:lookup(LookupHash, Tree),
|
||||
|
||||
|
@ -134,7 +134,7 @@ go_arrayofdict(_, 0, _) ->
|
|||
{erlang:memory(), statistics(garbage_collection)};
|
||||
go_arrayofdict(Array, N, M) ->
|
||||
% Lookup a random key - which may not be present
|
||||
LookupKey = lists:concat(["key-", random:uniform(M)]),
|
||||
LookupKey = lists:concat(["key-", leveled_rand:uniform(M)]),
|
||||
LookupHash = hash(LookupKey),
|
||||
LookupIndex = hash_to_index(LookupHash),
|
||||
dict:find(LookupHash, array:get(LookupIndex, Array)),
|
||||
|
@ -177,7 +177,7 @@ go_arrayofgbtree(_, 0, _) ->
|
|||
{erlang:memory(), statistics(garbage_collection)};
|
||||
go_arrayofgbtree(Array, N, M) ->
|
||||
% Lookup a random key - which may not be present
|
||||
LookupKey = lists:concat(["key-", random:uniform(M)]),
|
||||
LookupKey = lists:concat(["key-", leveled_rand:uniform(M)]),
|
||||
LookupHash = hash(LookupKey),
|
||||
LookupIndex = hash_to_index(LookupHash),
|
||||
gb_trees:lookup(LookupHash, array:get(LookupIndex, Array)),
|
||||
|
@ -212,7 +212,7 @@ go_arrayofdict_withcache(_, 0, _) ->
|
|||
{erlang:memory(), statistics(garbage_collection)};
|
||||
go_arrayofdict_withcache({MArray, CArray}, N, M) ->
|
||||
% Lookup a random key - which may not be present
|
||||
LookupKey = lists:concat(["key-", random:uniform(M)]),
|
||||
LookupKey = lists:concat(["key-", leveled_rand:uniform(M)]),
|
||||
LookupHash = hash(LookupKey),
|
||||
LookupIndex = hash_to_index(LookupHash),
|
||||
dict:find(LookupHash, array:get(LookupIndex, CArray)),
|
||||
|
@ -263,10 +263,10 @@ create_block(N, BlockType, KeyStruct) ->
|
|||
20 ->
|
||||
Key = lists:concat(["key-20-special"]);
|
||||
_ ->
|
||||
Key = lists:concat(["key-", N, "-", random:uniform(1000)])
|
||||
Key = lists:concat(["key-", N, "-", leveled_rand:uniform(1000)])
|
||||
end,
|
||||
SequenceNumber = random:uniform(1000000000),
|
||||
Indexes = [{<<"DateOfBirth_int">>, random:uniform(10000)}, {<<"index1_bin">>, lists:concat([random:uniform(1000), "SomeCommonText"])}, {<<"index2_bin">>, <<"RepetitionRepetitionRepetition">>}],
|
||||
SequenceNumber = leveled_rand:uniform(1000000000),
|
||||
Indexes = [{<<"DateOfBirth_int">>, leveled_rand:uniform(10000)}, {<<"index1_bin">>, lists:concat([leveled_rand:uniform(1000), "SomeCommonText"])}, {<<"index2_bin">>, <<"RepetitionRepetitionRepetition">>}],
|
||||
case BlockType of
|
||||
keylist ->
|
||||
Term = {o, Bucket, Key, {Indexes, SequenceNumber}},
|
||||
|
@ -320,4 +320,4 @@ findkey(Key, Tree, keygbtree) ->
|
|||
_ ->
|
||||
true
|
||||
end.
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ check_positive(KeyList, Bloom, LoopCount) ->
|
|||
|
||||
|
||||
produce_keylist(KeyCount) ->
|
||||
KeyPrefix = lists:concat(["PositiveKey-", random:uniform(KeyCount)]),
|
||||
KeyPrefix = lists:concat(["PositiveKey-", leveled_rand:uniform(KeyCount)]),
|
||||
produce_keylist(KeyCount, [], KeyPrefix).
|
||||
|
||||
produce_keylist(0, KeyList, _) ->
|
||||
|
@ -46,7 +46,7 @@ check_negative(KeyCount, CheckCount) ->
|
|||
check_negative(Bloom, 0, FalsePos) ->
|
||||
{byte_size(Bloom), FalsePos};
|
||||
check_negative(Bloom, CheckCount, FalsePos) ->
|
||||
Key = lists:concat(["NegativeKey-", CheckCount, random:uniform(CheckCount)]),
|
||||
Key = lists:concat(["NegativeKey-", CheckCount, leveled_rand:uniform(CheckCount)]),
|
||||
case leveled_rice:check_key(Key, Bloom) of
|
||||
true -> check_negative(Bloom, CheckCount - 1, FalsePos + 1);
|
||||
false -> check_negative(Bloom, CheckCount - 1, FalsePos)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue