Documentation ¶
Index ¶
- Constants
- type Filter
- func (f *Filter) Add(item []byte) bool
- func (f *Filter) AddUnique(item []byte) bool
- func (f *Filter) BitsPerItem() float64
- func (f *Filter) Contain(key []byte) bool
- func (f *Filter) Delete(key []byte) bool
- func (f *Filter) Encode() ([]byte, error)
- func (f *Filter) EncodeReader() (io.Reader, uint)
- func (f *Filter) FalsePositiveRate() float64
- func (f *Filter) Info() string
- func (f *Filter) LoadFactor() float64
- func (f *Filter) Reset()
- func (f *Filter) Size() uint
- func (f *Filter) SizeInBytes() uint
- type PackedTable
- func (p *PackedTable) BitsPerItem() uint
- func (p *PackedTable) Decode(b []byte) error
- func (p *PackedTable) DeleteTagFromBucket(i uint, tag uint32) bool
- func (p *PackedTable) FindTagInBuckets(i1, i2 uint, tag uint32) bool
- func (p *PackedTable) Info() string
- func (p *PackedTable) Init(_, bitsPerTag, num uint, initialBucketsHint []byte) error
- func (p *PackedTable) InsertTagToBucket(i uint, tag uint32, kickOut bool, oldTag *uint32) bool
- func (p *PackedTable) NumBuckets() uint
- func (p *PackedTable) PrintBucket(i uint)
- func (p *PackedTable) PrintTags(tags [tagsPerPTable]uint32)
- func (p *PackedTable) ReadBucket(i uint, tags *[tagsPerPTable]uint32)
- func (p *PackedTable) Reader() (io.Reader, uint)
- func (p *PackedTable) Reset()
- func (p *PackedTable) SizeInBytes() uint
- func (p *PackedTable) SizeInTags() uint
- func (p *PackedTable) WriteBucket(i uint, tags [tagsPerPTable]uint32)
- type PermEncoding
- type SingleTable
- func (t *SingleTable) BitsPerItem() uint
- func (t *SingleTable) Decode(b []byte) error
- func (t *SingleTable) DeleteTagFromBucket(i uint, tag uint32) bool
- func (t *SingleTable) FindTagInBuckets(i1, i2 uint, tag uint32) bool
- func (t *SingleTable) Info() string
- func (t *SingleTable) Init(tagsPerBucket, bitsPerTag, num uint, initialBucketsHint []byte) error
- func (t *SingleTable) InsertTagToBucket(i uint, tag uint32, kickOut bool, oldTag *uint32) bool
- func (t *SingleTable) NumBuckets() uint
- func (t *SingleTable) ReadTag(i, j uint) uint32
- func (t *SingleTable) Reader() (io.Reader, uint)
- func (t *SingleTable) Reset()
- func (t *SingleTable) SizeInBytes() uint
- func (t *SingleTable) SizeInTags() uint
- func (t *SingleTable) WriteTag(i, j uint, n uint32)
Constants ¶
const ( // TableTypeSingle normal single table TableTypeSingle = 0 // TableTypePacked packed table, use semi-sort to save 1 bit per item TableTypePacked = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter cuckoo filter type struct
func DecodeFrom ¶ added in v0.4.0
DecodeFrom returns a Cuckoo Filter using the exact provided byte slice (no copy).
func NewFilter ¶
NewFilter return a new initialized filter
tagsPerBucket: num of tags for each bucket, which is b in paper. tag is fingerprint, which is f in paper. bitPerItem: num of bits for each item, which is length of tag(fingerprint) maxNumKeys: num of keys that filter will store. this value should close to and lower nextPow2(maxNumKeys/tagsPerBucket) * maxLoadFactor. cause table.NumBuckets is always a power of two
func (*Filter) AddUnique ¶
AddUnique add an item into filter, return false when filter already contains it or filter is full
func (*Filter) BitsPerItem ¶
BitsPerItem return bits occupancy per item of filter's table
func (*Filter) EncodeReader ¶ added in v0.4.0
EncodeReader returns a reader representing a Cuckoo filter
func (*Filter) FalsePositiveRate ¶
FalsePositiveRate return the False Positive Rate of filter Notice that this will reset filter
func (*Filter) LoadFactor ¶
LoadFactor return current filter's loadFactor
func (*Filter) SizeInBytes ¶
SizeInBytes return bytes occupancy of filter's table
type PackedTable ¶
type PackedTable struct {
// contains filtered or unexported fields
}
PackedTable using Permutation encoding to save 1 bit per tag
func (*PackedTable) BitsPerItem ¶
func (p *PackedTable) BitsPerItem() uint
BitsPerItem return bits occupancy per item of table
func (*PackedTable) Decode ¶
func (p *PackedTable) Decode(b []byte) error
Decode parse a byte slice into a TableBucket
func (*PackedTable) DeleteTagFromBucket ¶
func (p *PackedTable) DeleteTagFromBucket(i uint, tag uint32) bool
DeleteTagFromBucket delete tag from bucket i
func (*PackedTable) FindTagInBuckets ¶
func (p *PackedTable) FindTagInBuckets(i1, i2 uint, tag uint32) bool
FindTagInBuckets find if tag in bucket i1 i2
func (*PackedTable) Init ¶
func (p *PackedTable) Init(_, bitsPerTag, num uint, initialBucketsHint []byte) error
Init init table
func (*PackedTable) InsertTagToBucket ¶
InsertTagToBucket insert tag into bucket i
func (*PackedTable) NumBuckets ¶
func (p *PackedTable) NumBuckets() uint
NumBuckets return num of table buckets
func (*PackedTable) PrintBucket ¶
func (p *PackedTable) PrintBucket(i uint)
PrintBucket print a bucket
func (*PackedTable) PrintTags ¶
func (p *PackedTable) PrintTags(tags [tagsPerPTable]uint32)
PrintTags print tags
func (*PackedTable) ReadBucket ¶
func (p *PackedTable) ReadBucket(i uint, tags *[tagsPerPTable]uint32)
ReadBucket read and decode the bucket i, pass the 4 decoded tags to the 2nd arg bucket bits = 12 codeword bits + dir bits of tag1 + dir bits of tag2 ...
func (*PackedTable) Reader ¶ added in v0.4.0
func (p *PackedTable) Reader() (io.Reader, uint)
Encode returns a byte slice representing a TableBucket
func (*PackedTable) SizeInBytes ¶
func (p *PackedTable) SizeInBytes() uint
SizeInBytes return bytes occupancy of table
func (*PackedTable) SizeInTags ¶
func (p *PackedTable) SizeInTags() uint
SizeInTags return num of tags that table can store
func (*PackedTable) WriteBucket ¶
func (p *PackedTable) WriteBucket(i uint, tags [tagsPerPTable]uint32)
WriteBucket write tags into bucket i
type PermEncoding ¶
type PermEncoding struct { DecTable []uint16 EncTable []uint16 // contains filtered or unexported fields }
PermEncoding permutation table
func (*PermEncoding) Decode ¶
func (p *PermEncoding) Decode(codeword uint16, lowBits *[tagsPerPTable]uint8)
Decode decode codeword to lowBits
func (*PermEncoding) Encode ¶
func (p *PermEncoding) Encode(lowBits [tagsPerPTable]uint8) uint16
Encode encode lowBits to codeword
type SingleTable ¶
type SingleTable struct {
// contains filtered or unexported fields
}
SingleTable the most naive table implementation: one huge bit array
func (*SingleTable) BitsPerItem ¶
func (t *SingleTable) BitsPerItem() uint
BitsPerItem return bits occupancy per item of table
func (*SingleTable) Decode ¶
func (t *SingleTable) Decode(b []byte) error
Decode parse a byte slice into a TableBucket
func (*SingleTable) DeleteTagFromBucket ¶
func (t *SingleTable) DeleteTagFromBucket(i uint, tag uint32) bool
DeleteTagFromBucket delete tag from bucket i
func (*SingleTable) FindTagInBuckets ¶
func (t *SingleTable) FindTagInBuckets(i1, i2 uint, tag uint32) bool
FindTagInBuckets find if tag in bucket i1 i2
func (*SingleTable) Init ¶
func (t *SingleTable) Init(tagsPerBucket, bitsPerTag, num uint, initialBucketsHint []byte) error
Init init table
func (*SingleTable) InsertTagToBucket ¶
InsertTagToBucket insert tag into bucket i
func (*SingleTable) NumBuckets ¶
func (t *SingleTable) NumBuckets() uint
NumBuckets return num of table buckets
func (*SingleTable) ReadTag ¶
func (t *SingleTable) ReadTag(i, j uint) uint32
ReadTag read tag from bucket(i,j)
func (*SingleTable) Reader ¶ added in v0.4.0
func (t *SingleTable) Reader() (io.Reader, uint)
Encode returns a byte slice representing a TableBucket
func (*SingleTable) SizeInBytes ¶
func (t *SingleTable) SizeInBytes() uint
SizeInBytes return bytes occupancy of table
func (*SingleTable) SizeInTags ¶
func (t *SingleTable) SizeInTags() uint
SizeInTags return num of tags that table can store
func (*SingleTable) WriteTag ¶
func (t *SingleTable) WriteTag(i, j uint, n uint32)
WriteTag write tag into bucket(i,j)