bloomy

package module
v0.0.0-...-bdcf011 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

README

bloomy: simple bloom filter in pure go.

Bloomy is a simple bloom filter written in go. A bloom filter is space-efficient data-structure which tests whether an element is a part of a given list of elements. It is important to note that false positives are possible, but false negatives are not.

Usage

Install the project as a dependency:

go get -u github.com/nireo/bloomy
package main

import (
        "fmt"
        "github.com/nireo/bloomy"
)

const itemCount = 20000
const falsePositiveRate = 0.01

func main() {
    bf := bloomy.New(itemCount, falsePositiveRate) 
    bf.Insert([]byte("hello world"))

    if bf.Contains([]byte("hello world")) {
        fmt.Println("found string")
    } else {
        fmt.Println("something went wrong")
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilter

type BloomFilter struct {
	// contains filtered or unexported fields
}

func New

func New(item uint32, falsePositiveRate float64) *BloomFilter

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(value []byte) bool

func (*BloomFilter) Insert

func (bf *BloomFilter) Insert(value []byte)

Jump to

Keyboard shortcuts

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