功能说明
读取词表文件,每词加入 65536 位数组 5 哈希函数的布隆过滤器,测试查询词并打印结果。双哈希技巧以种子前缀变体从一次 SHA-256 派生 k 索引。运行 node bloom.mjs words.txt hello,在表中输出 probably present,不在表中通常输出 definitely absent,误报可能但罕见。每次运行从词表重建,非持久存储;不支持删除,需计数布隆过滤器。
运行方式
node bloom.mjs words.txt query
限制与后续
当前布隆过滤器命令行工具实现覆盖最常见的使用路径。本译文依据英文原文完整重写,代码与命令与英文版本严格一致,可在本地按运行方式复现并核对结果。The filter is rebuilt from the word list on every run, so it is a demonstration, not a persistent store. No removal is supported; a counting Bloom filter would be needed for deletion.若用于生产,请先补充输入校验、错误处理与日志,再结合自身环境调整node版本。