bloomfilter

package
v0.0.0-...-b0c2144 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFileWithOption

func LoadFileWithOption(filepath string) func(*BloomFilter) error

LoadFileWithOption 通过文件加载过滤器样本

Types

type BloomFilter

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

BloomFilter 定义布隆过滤器

func NewBloom

func NewBloom(ctx context.Context, n uint, fp float64, ops ...BloomOption) (*BloomFilter, error)

NewBloom 实例化布隆过滤器

func (*BloomFilter) Add

func (bf *BloomFilter) Add(data []byte)

Add 向过滤器中增加样本

func (*BloomFilter) ClearAll

func (bf *BloomFilter) ClearAll()

ClearAll 清空过滤器中的所有样本

func (*BloomFilter) DownloadToFile

func (bf *BloomFilter) DownloadToFile(ctx context.Context, filepath string) error

DownloadToFile 将过滤器的样本保存到本地文件

func (*BloomFilter) LoadByFile

func (bf *BloomFilter) LoadByFile(ctx context.Context, filepath string) error

LoadByFile 从文件中加载 先清空过滤后所有样本,重新加载

func (*BloomFilter) Test

func (bf *BloomFilter) Test(data []byte) bool

Test 如果数据位于 BloomFilter 中,则 Test 返回 true,否则返回 false。如果为 true,则结果可能是误报。如果为 false,则数据肯定不在集合中

type BloomOption

type BloomOption func(*BloomFilter) error

Jump to

Keyboard shortcuts

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