summaryrefslogtreecommitdiff
path: root/xmake/core/base
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-21 20:36:09 +0800
committerruki <[email protected]>2022-05-21 20:36:09 +0800
commitae7779636e29044be207d26d22a8cd27a223605d (patch)
treecc8da80bddf803579e4218e2102de84b9cc18986 /xmake/core/base
parente4c3aa1c047d68a49de392307075b60f411e1950 (diff)
add bloom filter in core
Diffstat (limited to 'xmake/core/base')
-rw-r--r--xmake/core/base/bloom_filter.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/xmake/core/base/bloom_filter.lua b/xmake/core/base/bloom_filter.lua
index 781cfb4da..fd3bd3a9d 100644
--- a/xmake/core/base/bloom_filter.lua
+++ b/xmake/core/base/bloom_filter.lua
@@ -173,7 +173,7 @@ function _instance:__gc()
end
end
--- new a bloom filter, e.g. {probability = 0.001}
+-- new a bloom filter, e.g. {probability = 0.001, hash_count = 3, item_maxn = 1000000}
function bloom_filter.new(opt)
opt = opt or {}
local probability = opt.probability or 0.001
@@ -186,7 +186,9 @@ function bloom_filter.new(opt)
[0.000001] = bloom_filter.PROBABILITY_0_000001
}
probability = assert(maps[probability], "invalid probability(%f)", probability)
- local handle, errors = bloom_filter._open(probability)
+ local hash_count = opt.hash_count or 3
+ local item_maxn = opt.item_maxn or 1000000
+ local handle, errors = bloom_filter._open(probability, hash_count, item_maxn)
if handle then
return _instance.new(handle)
else