Consistency of empty slotlist references

Need to return an empty slotlist in a consistent way
This commit is contained in:
martinsumner 2017-03-11 13:04:55 +00:00
parent 1f8de798bd
commit f2cd9b3f33

View file

@ -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", []),