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
- 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(bytes []byte) error
- func (p *PackedTable) DeleteTagFromBucket(i uint, tag uint32) bool
- func (p *PackedTable) Encode() []byte
- func (p *PackedTable) FindTagInBucket(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)
- 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) 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(bytes []byte) error
- func (t *SingleTable) DeleteTagFromBucket(i uint, tag uint32) bool
- func (t *SingleTable) Encode() []byte
- func (t *SingleTable) FindTagInBucket(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)
- func (t *SingleTable) InsertTagToBucket(i uint, tag uint32, kickOut bool, oldTag *uint32) bool
- func (t *SingleTable) NumBuckets() uint
- func (t *SingleTable) NumTagsInBucket(i uint) uint
- func (t *SingleTable) ReadTag(i, j uint) uint32
- func (t *SingleTable) Reset()
- func (t *SingleTable) SizeInBytes() uint
- func (t *SingleTable) SizeInTags() uint
- func (t *SingleTable) WriteTag(i, j uint, n uint32)
- type Table
- type VictimCache
Constants ¶
const ( TableTypeSingle = 0 TableTypePacked = 1 )
const DEBUG = false
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func NewFilter ¶
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) BitsPerItem ¶
func (*Filter) FalsePositiveRate ¶
FalsePositiveRate return the False Positive Rate of filter Notice that this will reset filter
func (*Filter) LoadFactor ¶
func (*Filter) SizeInBytes ¶
type PackedTable ¶
type PackedTable struct {
// contains filtered or unexported fields
}
Using Permutation encoding to save 1 bit per tag
func NewPackedTable ¶
func NewPackedTable() *PackedTable
func (*PackedTable) BitsPerItem ¶
func (p *PackedTable) BitsPerItem() uint
func (*PackedTable) Decode ¶
func (p *PackedTable) Decode(bytes []byte) error
Decode parse a byte slice into a TableBucket
func (*PackedTable) DeleteTagFromBucket ¶
func (p *PackedTable) DeleteTagFromBucket(i uint, tag uint32) bool
func (*PackedTable) Encode ¶
func (p *PackedTable) Encode() []byte
Encode returns a byte slice representing a TableBucket
func (*PackedTable) FindTagInBucket ¶
func (p *PackedTable) FindTagInBucket(i uint, tag uint32) bool
func (*PackedTable) FindTagInBuckets ¶
func (p *PackedTable) FindTagInBuckets(i1, i2 uint, tag uint32) bool
func (*PackedTable) Info ¶
func (p *PackedTable) Info() string
func (*PackedTable) Init ¶
func (p *PackedTable) Init(_, bitsPerTag, num uint)
func (*PackedTable) InsertTagToBucket ¶
func (*PackedTable) NumBuckets ¶
func (p *PackedTable) NumBuckets() uint
func (*PackedTable) PrintBucket ¶
func (p *PackedTable) PrintBucket(i uint)
func (*PackedTable) PrintTags ¶
func (p *PackedTable) PrintTags(tags [tagsPerPTable]uint32)
func (*PackedTable) ReadBucket ¶
func (p *PackedTable) ReadBucket(i uint, tags *[tagsPerPTable]uint32)
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) Reset ¶
func (p *PackedTable) Reset()
func (*PackedTable) SizeInBytes ¶
func (p *PackedTable) SizeInBytes() uint
func (*PackedTable) SizeInTags ¶
func (p *PackedTable) SizeInTags() uint
func (*PackedTable) WriteBucket ¶
func (p *PackedTable) WriteBucket(i uint, tags [tagsPerPTable]uint32)
Tag = 4 low bits + x high bits * L L L L H H H H ...
type PermEncoding ¶
type PermEncoding struct { DecTable []uint16 EncTable []uint16 // contains filtered or unexported fields }
func (*PermEncoding) Decode ¶
func (p *PermEncoding) Decode(codeword uint16, lowBits *[tagsPerPTable]uint8)
func (*PermEncoding) Encode ¶
func (p *PermEncoding) Encode(lowBits [tagsPerPTable]uint8) uint16
func (*PermEncoding) Init ¶
func (p *PermEncoding) Init()
type SingleTable ¶
type SingleTable struct {
// contains filtered or unexported fields
}
the most naive table implementation: one huge bit array
func NewSingleTable ¶
func NewSingleTable() *SingleTable
func (*SingleTable) BitsPerItem ¶
func (t *SingleTable) BitsPerItem() uint
func (*SingleTable) Decode ¶
func (t *SingleTable) Decode(bytes []byte) error
Decode parse a byte slice into a TableBucket
func (*SingleTable) DeleteTagFromBucket ¶
func (t *SingleTable) DeleteTagFromBucket(i uint, tag uint32) bool
func (*SingleTable) Encode ¶
func (t *SingleTable) Encode() []byte
Encode returns a byte slice representing a TableBucket
func (*SingleTable) FindTagInBucket ¶
func (t *SingleTable) FindTagInBucket(i uint, tag uint32) bool
func (*SingleTable) FindTagInBuckets ¶
func (t *SingleTable) FindTagInBuckets(i1, i2 uint, tag uint32) bool
func (*SingleTable) Info ¶
func (t *SingleTable) Info() string
func (*SingleTable) Init ¶
func (t *SingleTable) Init(tagsPerBucket, bitsPerTag, num uint)
func (*SingleTable) InsertTagToBucket ¶
func (*SingleTable) NumBuckets ¶
func (t *SingleTable) NumBuckets() uint
func (*SingleTable) NumTagsInBucket ¶
func (t *SingleTable) NumTagsInBucket(i uint) uint
func (*SingleTable) ReadTag ¶
func (t *SingleTable) ReadTag(i, j uint) uint32
read tag from pos(i,j)
func (*SingleTable) Reset ¶
func (t *SingleTable) Reset()
func (*SingleTable) SizeInBytes ¶
func (t *SingleTable) SizeInBytes() uint
func (*SingleTable) SizeInTags ¶
func (t *SingleTable) SizeInTags() uint
func (*SingleTable) WriteTag ¶
func (t *SingleTable) WriteTag(i, j uint, n uint32)
write tag to pos(i,j)
type Table ¶
type Table interface { Init(tagsPerBucket, bitsPerTag, num uint) NumBuckets() uint FindTagInBuckets(i1, i2 uint, tag uint32) bool DeleteTagFromBucket(i uint, tag uint32) bool InsertTagToBucket(i uint, tag uint32, kickOut bool, oldTag *uint32) bool SizeInTags() uint SizeInBytes() uint Info() string BitsPerItem() uint Encode() []byte Decode([]byte) error Reset() }
type VictimCache ¶
type VictimCache struct {
// contains filtered or unexported fields
}