From f2cd9b3f3375020b8bc69f52c2968fb5d951f184 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Sat, 11 Mar 2017 13:04:55 +0000 Subject: [PATCH] Consistency of empty slotlist references Need to return an empty slotlist in a consistent way --- src/leveled_sst.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/leveled_sst.erl b/src/leveled_sst.erl index 7451d01..f5bf7f8 100644 --- a/src/leveled_sst.erl +++ b/src/leveled_sst.erl @@ -68,6 +68,7 @@ -define(SLOT_SIZE, 128). % This is not configurable -define(NOLOOK_MULT, 2). % How much bigger is a slot/block with no lookups -define(NOLOOK_SLOTSIZE, ?SLOT_SIZE * ?NOLOOK_MULT). +-define(EMPTY_SLOTLIST, [{no_lookup, []}]). -define(COMPRESSION_LEVEL, 1). -define(BINARY_SETTINGS, [{compressed, ?COMPRESSION_LEVEL}]). % -define(LEVEL_BLOOM_BITS, [{0, 8}, {1, 10}, {2, 8}, {default, 6}]). @@ -161,7 +162,7 @@ sst_new(RootPath, Filename, Level, KVList, MaxSQN) -> sst_new(RootPath, Filename, KVL1, KVL2, IsBasement, Level, MaxSQN) -> {Rem1, Rem2, SlotList} = merge_lists(KVL1, KVL2, {IsBasement, Level}), case SlotList of - [{_, []}] -> + ?EMPTY_SLOTLIST -> empty; _ -> {ok, Pid} = gen_fsm:start(?MODULE, [], []), @@ -1135,6 +1136,8 @@ merge_lists(KVList1, KVList2, LevelInfo) -> merge_lists(KVList1, KVList2, _LI, SlotList, ?MAX_SLOTS) -> {KVList1, KVList2, lists:reverse(SlotList)}; +merge_lists([], [], _LI, [], _SlotCount) -> + {[], [], ?EMPTY_SLOTLIST}; merge_lists([], [], _LI, SlotList, _SlotCount) -> {[], [], lists:reverse(SlotList)}; merge_lists(KVList1, KVList2, LI, SlotList, SlotCount) -> @@ -1356,7 +1359,7 @@ merge_tombstonelist_test() -> R = merge_lists([SkippingKV1, SkippingKV3, SkippingKV5], [SkippingKV2, SkippingKV4], {true, 9999999}), - ?assertMatch({[], [], []}, R). + ?assertMatch({[], [], ?EMPTY_SLOTLIST}, R). indexed_list_test() -> io:format(user, "~nIndexed list timing test:~n", []),