Protect against div by 0

Make sure that blooms are always at least 1 slot in size
This commit is contained in:
martinsumner 2017-01-02 18:38:14 +00:00
parent baa644383d
commit b3e189b012

View file

@ -621,7 +621,7 @@ build_table_summary(SlotIndex, AllHashes, Level, FirstKey, L, MaxSQN) ->
false ->
element(2, lists:keyfind(default, 1, ?LEVEL_BLOOM_BITS))
end,
BloomSlots = (length(AllHashes) * BloomBits) div 4096,
BloomSlots = max((length(AllHashes) * BloomBits) div 4096, 1),
BloomAddFun =
fun({H, _K}, Bloom) -> leveled_tinybloom:enter(H, Bloom) end,
Bloom = lists:foldr(BloomAddFun,