bloom: ensure min values.
This commit is contained in:
parent
8c1002e1da
commit
40ff06f11f
@ -272,6 +272,7 @@ Bloom.fromRate = function fromRate(items, rate, update) {
|
||||
assert(rate >= 0 && rate <= 1, '`rate` must be between 0.0 and 1.0.');
|
||||
|
||||
size = (-1 / LN2SQUARED * items * Math.log(rate)) | 0;
|
||||
size = Math.max(8, size);
|
||||
|
||||
if (update !== -1)
|
||||
size = Math.min(size, Bloom.MAX_BLOOM_FILTER_SIZE * 8);
|
||||
@ -433,6 +434,7 @@ RollingFilter.prototype.fromRate = function fromRate(items, rate) {
|
||||
|
||||
items = ((size + 63) / 64 | 0) << 1;
|
||||
items >>>= 0;
|
||||
items = Math.max(1, items);
|
||||
|
||||
tweak = (Math.random() * 0x100000000) >>> 0;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user