wilhg / lxiv-filter

a high performance bloom filter, using uint64 array & murmurhash3.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lxiv-filter

LXIV is the number 64 in Roman number.

A Bloom filter is a representation of a set of n items, where the main requirement is to make membership queries; i.e., whether an item may be a member of a set.

This bloom filter implementation is backed by uint64 array.

And the hashing functions used is murmur3, a fast and good hashing function.

WARNING: Before you using any implementation of bloom filter, please have a view of this article, to know how to config your parameters.

Installation

go get -u github.com/cuebyte/lxiv-filter

Usage

import "github.com/cuebyte/lxiv-filter"

lf := lxivFilter.NewDefault() // == lf.New(1<<32, 5)

// The size has to be a power of 2, and greater than 64.
lf.Size()                           // Return 1 << 32
lf.K()                              // Return 5

lf.MayExist([]byte("Hello World!")) // Return false

lf.Add([]byte("Hello World!"))

lf.MayExist([]byte("Hello World!")) // Return true

lf.Reset()                          // Clean the bit-map

However, before calling Add(), we don't need to check whether the data is existed.

About

a high performance bloom filter, using uint64 array & murmurhash3.

License:MIT License


Languages

Language:Go 100.0%