From ba9485a8f21827cb18da0db55a9bd9859b04e2c5 Mon Sep 17 00:00:00 2001 From: Ibrahim Jarif Date: Mon, 28 Sep 2020 22:57:32 +0530 Subject: [PATCH 1/3] z: Add totalSize method on bloom filter --- z/bbloom.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/z/bbloom.go b/z/bbloom.go index c80559d2..41553721 100644 --- a/z/bbloom.go +++ b/z/bbloom.go @@ -131,6 +131,11 @@ func (bl *Bloom) AddIfNotHas(hash uint64) bool { return true } +// TotalSize returns the total size of the bloom filter. +func (bl *Bloom) TotalSize() uint64 { + return uint64(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) From c22de119ad76bcaf48907f6fc1f8bf6adc28fcaa Mon Sep 17 00:00:00 2001 From: Ibrahim Jarif Date: Mon, 28 Sep 2020 22:59:27 +0530 Subject: [PATCH 2/3] change uint64 to int --- z/bbloom.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/z/bbloom.go b/z/bbloom.go index 41553721..9b95fc57 100644 --- a/z/bbloom.go +++ b/z/bbloom.go @@ -132,8 +132,8 @@ func (bl *Bloom) AddIfNotHas(hash uint64) bool { } // TotalSize returns the total size of the bloom filter. -func (bl *Bloom) TotalSize() uint64 { - return uint64(len(bl.bitset)*8) + 5*8 +func (bl *Bloom) TotalSize() int { + return len(bl.bitset)*8 + 5*8 } // Size makes Bloom filter with as bitset of size sz. From 596a17f9120ed9caa0295a65ba61937191596e65 Mon Sep 17 00:00:00 2001 From: Ibrahim Jarif Date: Wed, 30 Sep 2020 20:32:44 +0530 Subject: [PATCH 3/3] Add comment about bloom filter size --- z/bbloom.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/z/bbloom.go b/z/bbloom.go index 9b95fc57..3e2137ff 100644 --- a/z/bbloom.go +++ b/z/bbloom.go @@ -133,6 +133,8 @@ func (bl *Bloom) AddIfNotHas(hash uint64) bool { // 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 }