From b855401696028e8792612fdbe338a8eae5fa87eb Mon Sep 17 00:00:00 2001 From: martinsumner Date: Thu, 29 Dec 2016 14:11:05 +0000 Subject: [PATCH] Experiment Want to experiemnt with different datatypes for the slot - maybe use a raw list but with a mini hashtree index like the CDB file --- src/leveled_sst.erl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/leveled_sst.erl b/src/leveled_sst.erl index f1466c4..f281ba1 100644 --- a/src/leveled_sst.erl +++ b/src/leveled_sst.erl @@ -981,6 +981,41 @@ generate_randomkeys(Seqn, Count, Acc, BucketLow, BRange) -> BRange). +experimental_test() -> + io:format(user, "~nExperimental timing test:~n", []), + N = 128, + KVL1 = lists:ukeysort(1, generate_randomkeys(1, N, 1, 2)), + ExtractHashFun = + fun({K, V}) -> + {_SQN, H} = leveled_codec:strip_to_seqnhashonly({K, V}), + {{hash, H}, K} end, + HashList = lists:map(ExtractHashFun, KVL1), + + SWA0 = os:timestamp(), + Tree = gb_trees:from_orddict(KVL1), + BloomAddFun = + fun({H, K}, Bloom) -> leveled_tinybloom:tiny_enter(H, K, Bloom) end, + _Bloom = lists:foldr(BloomAddFun, + leveled_tinybloom:tiny_empty(), + HashList), + SlotBin = term_to_binary(Tree, [{compressed, ?COMPRESSION_LEVEL}]), + io:format(user, + "Created slot in ~w microseconds~n", + [timer:now_diff(os:timestamp(), SWA0)]), + + % {TestK1, TestV1} = lists:nth(16, KVL1), + {TestK2, TestV2} = lists:nth(64, KVL1), + % {TestK3, TestV3} = lists:nth(96, KVL1), + SWA1 = os:timestamp(), + Slot0 = binary_to_term(SlotBin), + {value, TestV2} = gb_trees:lookup(TestK2, Slot0), + io:format(user, + "Looked in slot in ~w microseconds~n", + [timer:now_diff(os:timestamp(), SWA1)]). + + + + merge_test() -> N = 3000, KVL1 = lists:ukeysort(1, generate_randomkeys(N + 1, N, 1, 20)),