Skip to content

Commit

Permalink
z: Add TotalSize method on bloom filter (#197)
Browse files Browse the repository at this point in the history
This PR adds a TotalSize function which returns the total size of the bloom filter.
  • Loading branch information
Ibrahim Jarif authored Sep 30, 2020
1 parent 646c5f3 commit e1609c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions z/bbloom.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ func (bl *Bloom) AddIfNotHas(hash uint64) bool {
return true
}

// TotalSize returns the total size of the bloom filter.
func (bl *Bloom) TotalSize() int {
// The bl struct has 5 members and each one is 8 byte. The bitset is a
// uint64 byte slice.
return len(bl.bitset)*8 + 5*8
}

// Size makes Bloom filter with as bitset of size sz.
func (bl *Bloom) Size(sz uint64) {
bl.bitset = make([]uint64, sz>>6)
Expand Down

0 comments on commit e1609c8

Please sign in to comment.