Documentation
¶
Overview ¶
Package ring provides a high performance and thread safe bloom filter.
License ¶
Copyright (c) 2019 Tanner Ryan. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- type Bloom
- func (r *Bloom) Add(data []byte)
- func (r *Bloom) BufferSize() int
- func (r *Bloom) GetHashOpCount() uint64
- func (r *Bloom) GetSize() uint64
- func (r *Bloom) MarshalBinary() ([]byte, error)
- func (r *Bloom) MarshalStorage() ([]byte, error)
- func (r *Bloom) Merge(m *Bloom) error
- func (r *Bloom) Reset()
- func (r *Bloom) Test(data []byte) bool
- func (r *Bloom) UnmarshalBinary(data []byte) error
- func (r *Bloom) UnmarshalStorage(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bloom ¶
type Bloom struct {
// contains filtered or unexported fields
}
Bloom contains the information for a ring data store.
func Init ¶
Init initializes and returns a new ring, or an error. Given a number of elements, it accurately states if data is not added. Within a falsePositive rate, it will indicate if the data has been added.
func InitByParameters ¶
InitByParameters initializes a bloom filter allowing the user to explicitly set the size of the bit array and the amount of hash functions
func (*Bloom) BufferSize ¶
BufferSize returns the size of the buffer the filter is using, in bytes this is the same size as the outputted buffer from Bloom.MarshalStorage
func (*Bloom) GetHashOpCount ¶
Returns the number the hash operations
func (*Bloom) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Bloom) MarshalStorage ¶
MarshalStorage is a marshal function which returns the bit array only, excluding extraneous information of the bloom filter. Included for efficient DB storage purposes
func (*Bloom) Test ¶
Test returns a bool if the data is in the ring. True indicates that the data may be in the ring, while false indicates that the data is not in the ring.
func (*Bloom) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Bloom) UnmarshalStorage ¶
UnmarshalStorage is an unmarshal function which populates passed in data into the bloom filters bit array. The stored data must be sized for this filter and be created with the same filter parameters, misconfigurations will not be caught Included for efficient DB storage purpose.