bloom

package
v0.0.0-...-aa24a56 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package bloom implements Bloom filters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter []byte

Filter is an encoded set of []byte keys.

func NewFilter

func NewFilter(buf []byte, keys [][]byte, bitsPerKey int) Filter

NewFilter returns a new Bloom filter that encodes a set of []byte keys with the given number of bits per key, approximately. The returned Filter may be a sub-slice of buf[:cap(buf)] if it is large enough, otherwise the Filter will be allocated separately.

A good bitsPerKey value is 10, which yields a filter with ~ 1% false positive rate.

func (Filter) MayContain

func (f Filter) MayContain(key []byte) bool

MayContain returns whether the filter may contain given key. False positives are possible, where it returns true for keys not in the original set.

type FilterPolicy

type FilterPolicy int

FilterPolicy implements the db.FilterPolicy interface from the leveldb/db package.

The integer value is the approximate number of bits used per key. A good value is 10, which yields a filter with ~ 1% false positive rate.

It is valid to use the other API in this package (leveldb/bloom) without using this type or the leveldb/db package.

func (FilterPolicy) MayContain

func (p FilterPolicy) MayContain(filter, key []byte) bool

MayContain implements the db.FilterPolicy interface.

func (FilterPolicy) Name

func (p FilterPolicy) Name() string

Name implements the db.FilterPolicy interface.

func (FilterPolicy) NewFilter

func (p FilterPolicy) NewFilter(keys [][]byte) []byte

NewFilter implements the db.FilterPolicy interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL