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) 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
Click to show internal directories.
Click to hide internal directories.