@ably/bloomit 中文文档教程
@ably/bloomit
bloomit 包的一个分支,用于修复一些问题(例如 https://github.com/kblauhut/bloomit/issues/4 )并从 xxhash 切换到 农场哈希。
原始自述文件如下。
bloomit
bloomit 是一个空间高效的布隆过滤器,基于 bloom-filters npm 包。
这个包的主要动机是减少 bloom 的内存使用 使用位图而不是 javascript 数字数组进行过滤。 这应该 导致理论内存减少 64 倍。
我还编辑了导出以使用 Uint8Array 编码所有需要的 值,并可用于有效地通过网络发送它。
Methods
add(element: string) -> void
: add an element into the filter.has(element: string) -> boolean
: Test an element for membership, returning False if the element is definitively not in the filter and True is the element might be in the filter.equals(other: BloomFilter) -> boolean
: Test if two filters are equals.rate() -> number
: compute the filter's false positive rate (or error rate).export() -> Uint8Array
: export the filter as an Uint8Arrayinport(filterUint8Array: Uint8Array) -> BloomFilter
: Create a filter from a exporterd Uint8Array
const { BloomFilter } = require('bloomit');
// create a Bloom Filter with a size of 10 and 4 hash functions
let filter = new BloomFilter(10, 4);
// insert data
filter.add('paul');
filter.add('kolja');
filter.add('carl');
// lookup for some data
console.log(filter.has('paul')); // output: true
console.log(filter.has('xiaomei')); // output: false
// print the error rate
console.log(filter.rate());
// alternatively, create a bloom filter optimal for a number of items and a desired error rate
const items = ['paul', 'kolja', 'carl'];
const errorRate = 0.04; // 4 % error rate
filter = BloomFilter.create(items.length, errorRate);
// or create a bloom filter optimal for a collections of items and a desired error rate
filter = BloomFilter.from(items, errorRate);
// Export the filter
const exportedFilter = filter.export();
// Import the filter
filter = BloomFilter.import(exportedFilter);
@ably/bloomit
A fork of the bloomit package to fix a few issues (eg https://github.com/kblauhut/bloomit/issues/4 ) and switch from xxhash to farmhash.
Original readme follows below.
bloomit
bloomit is a Space efficient bloom filter based on the bloom-filters npm package.
The main motivation for this package was to reduce the memory usage of the bloom filter by using a bitmap instead of an array of javascript numbers. This should result in a theoretical memory reduction by a factor of 64.
I have also edited the export to use a Uint8Array which encodes all needed values and can be used to send it over the web efficiently.
Methods
add(element: string) -> void
: add an element into the filter.has(element: string) -> boolean
: Test an element for membership, returning False if the element is definitively not in the filter and True is the element might be in the filter.equals(other: BloomFilter) -> boolean
: Test if two filters are equals.rate() -> number
: compute the filter's false positive rate (or error rate).export() -> Uint8Array
: export the filter as an Uint8Arrayinport(filterUint8Array: Uint8Array) -> BloomFilter
: Create a filter from a exporterd Uint8Array
const { BloomFilter } = require('bloomit');
// create a Bloom Filter with a size of 10 and 4 hash functions
let filter = new BloomFilter(10, 4);
// insert data
filter.add('paul');
filter.add('kolja');
filter.add('carl');
// lookup for some data
console.log(filter.has('paul')); // output: true
console.log(filter.has('xiaomei')); // output: false
// print the error rate
console.log(filter.rate());
// alternatively, create a bloom filter optimal for a number of items and a desired error rate
const items = ['paul', 'kolja', 'carl'];
const errorRate = 0.04; // 4 % error rate
filter = BloomFilter.create(items.length, errorRate);
// or create a bloom filter optimal for a collections of items and a desired error rate
filter = BloomFilter.from(items, errorRate);
// Export the filter
const exportedFilter = filter.export();
// Import the filter
filter = BloomFilter.import(exportedFilter);
你可能也喜欢
- @0xc/invisihash 中文文档教程
- @21epub/react-rxjs-store 中文文档教程
- @6river/nestjs-prom 中文文档教程
- @6river/strap-core 中文文档教程
- @aabegg/websocket 中文文档教程
- @aadityasiva/n-c-c 中文文档教程
- @aavenel/ckeditor5-build-classic-source-editing 中文文档教程
- @abdullahceylan/eslint-config 中文文档教程
- @abkap02/number-formatter 中文文档教程
- @aboutdavid/easypwa 中文文档教程