brave/bloom-filter-cpp

Name: bloom-filter-cpp

Owner: Brave Software

Description: null

Created: 2016-01-21 21:55:36.0

Updated: 2018-03-25 02:14:01.0

Pushed: 2018-03-25 02:14:00.0

Homepage: null

Size: 53

Language: C++

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

BloomFilter.cpp

C++ Native node module Bloom filter written in C++ for use in node or any other C++ project.

The Bloom filter tests whether an element belongs to a set. False positive matches are possible but not common, false negatives are not possible. The Bloom filter library also implements Rabin?Karp algorithm with Rabin fingerprint hashes for multiple substring searches.

This is a port of a similar lib I prototyped in JS.

To include bloom-filter-cpp in your project:
install --save bloom-filter-cpp
JS Usage
BloomFilter = require('bloom-filter-cpp').BloomFilter

b1 = new BloomFilter()

ole.log('b1 ading hello')
dd('hello')

ole.log('b1 exists hello? ', b1.exists('hello'))
ole.log('b1 exists hello2? ', b1.exists('hello2'))

b2 = new BloomFilter()
ole.log('b2 exists hello? ', b2.exists('hello'))
ole.log('b2 exists hello2? ', b2.exists('hello2'))
C++ Usage
lude "BloomFilter.h"
lude <iostream>

g namespace std;

main(int argc, char**argv) {
oomFilter b;
add("Brian");
add("Ronald");
add("Bondy");

 Prints true
ut << (b.exists("Brian") ? "true" : "false") << endl;

 Prints false
ut << (b.exists("Brian Ronald") ? "true" : "false") << endl;

 Create a new BloomerFilter form a previous serialization
oomFilter b2(b.getBuffer(), b.getByteBufferSize());

 Prints the same as above
ut << (b2.exists("Brian") ? "true" : "false") << endl;
ut << (b2.exists("Brian Ronald") ? "true" : "false") << endl;

 And you can check if any substring of a passed string exists
 Prints true
ut << (b.substringExists("Hello my name is Brian", 5) ? "true" : "false") << endl;
 Prints false
ut << (b.substringExists("Hello my name is Bri", 3) ? "true" : "false") << endl;

turn 0;

Developing bloom-filter-cpp
clone bloom-filter-cpp
install
Build everything in release

Running sample
 sample
Running tests
 test
Clearing build files
 clean

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.