Documentation ¶
Index ¶
- Constants
- Variables
- func Len(n int, w uint8) int
- type BitBucket
- func (b *BitBucket) Count() int
- func (b *BitBucket) CountN(v uint8) int
- func (b *BitBucket) Get(i int) uint8
- func (b *BitBucket) IncN(i int, v uint8)
- func (b *BitBucket) Len() int
- func (b *BitBucket) Max() uint8
- func (b *BitBucket) ReadFrom(r io.Reader) (int64, error)
- func (b *BitBucket) Reset()
- func (b *BitBucket) Set(i int, v uint8)
- func (b *BitBucket) Width() uint8
- func (b *BitBucket) WriteTo(w io.Writer) (int64, error)
Constants ¶
const (
Version = 1
)
Variables ¶
var ErrIncompatibleVersion = errors.New("bitbucket: incompatible version")
var ErrUnsupportedWidth = errors.New("bitbucket: requested bucket width exceeds maximum of 8")
Functions ¶
Types ¶
type BitBucket ¶
type BitBucket struct {
// contains filtered or unexported fields
}
A BitBucket is a collection of buckets capable of storing values from zero up to maximum specified by the configured number of bits.
func New ¶
New creates a new BitBucket with n buckets each consisting of w bits. When w is 1 then the bitbucket is equivalent to a bitset. Panics if w > 8.
func WithBytes ¶
WithBytes creates a new bit bucket that uses buf as its backing storage, preserving any existing data in the byte slice. Any subsequent writes to the bloom filter will mutate buf. The layout of the byte buffer must match the layout used by the WriteTo method on an equivalent bit bucket.
func (*BitBucket) CountN ¶
CountN returns the number of buckets that have the value v. TODO: optimize CountN by iterating through raw byte slice
func (*BitBucket) IncN ¶
IncN increments the value stored in bucket i by v, capping the result by the maximum value allowed for the bucket size.
func (*BitBucket) ReadFrom ¶
ReadFrom reads a binary representation of the bit bucket from r overwriting any previous configuration. It adheres to the io.ReaderFrom interface protocol. It reads data from r until EOF or error. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned.
func (*BitBucket) Reset ¶
func (b *BitBucket) Reset()
Reset zeroes all buckets in the bit bucket without reallocating the backing buffer.
func (*BitBucket) Set ¶
Set sets the value stored in bucket i to v, capping it by the maximum value allowed for the bucket size.