From e49f84b4128d5a4af93d1953f4b26dd99f8ef66b Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Mon, 27 May 2024 15:22:40 +0200 Subject: [PATCH] Fix linter Signed-off-by: Christian Haudum --- pkg/storage/bloom/v1/mempool/pool.go | 12 ++++++------ pkg/storage/bloom/v1/mempool/pool_test.go | 4 ++-- tools/bloom/inspector/main.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/storage/bloom/v1/mempool/pool.go b/pkg/storage/bloom/v1/mempool/pool.go index e53b337c8bd77..945cb2e2537aa 100644 --- a/pkg/storage/bloom/v1/mempool/pool.go +++ b/pkg/storage/bloom/v1/mempool/pool.go @@ -70,16 +70,16 @@ func (s *slab) put(buf []byte) { s.buffer <- ptr } -// mempool is an Allocator implementation that uses a fixed size memory pool +// MemPool is an Allocator implementation that uses a fixed size memory pool // that is split into multiple slabs of different buffer sizes. // Buffers are re-cycled and need to be returned back to the pool, otherwise // the pool runs out of available buffers. -type mempool struct { +type MemPool struct { slabs []*slab } -func New(buckets []Bucket) *mempool { - a := &mempool{ +func New(buckets []Bucket) *MemPool { + a := &MemPool{ slabs: make([]*slab, 0, len(buckets)), } for _, b := range buckets { @@ -91,7 +91,7 @@ func New(buckets []Bucket) *mempool { // Get satisfies Allocator interface // Allocating a buffer from an exhausted pool/slab will return an error. // Allocating a buffer that exceeds the largest slab size will cause a panic. -func (a *mempool) Get(size int) ([]byte, error) { +func (a *MemPool) Get(size int) ([]byte, error) { for i := 0; i < len(a.slabs); i++ { if a.slabs[i].size < size { continue @@ -104,7 +104,7 @@ func (a *mempool) Get(size int) ([]byte, error) { // Put satisfies Allocator interface // Every buffer allocated with Get(size int) needs to be returned to the pool // using Put(buffer []byte) so it can be re-cycled. -func (a *mempool) Put(buffer []byte) bool { +func (a *MemPool) Put(buffer []byte) bool { size := cap(buffer) for i := 0; i < len(a.slabs); i++ { if a.slabs[i].size < size { diff --git a/pkg/storage/bloom/v1/mempool/pool_test.go b/pkg/storage/bloom/v1/mempool/pool_test.go index 532aa871f0831..e3f90bf1bd36c 100644 --- a/pkg/storage/bloom/v1/mempool/pool_test.go +++ b/pkg/storage/bloom/v1/mempool/pool_test.go @@ -15,7 +15,7 @@ func TestMemPool(t *testing.T) { t.Run("empty pool", func(t *testing.T) { pool := New([]Bucket{}) require.Panics(t, func() { - pool.Get(128) + _, _ = pool.Get(128) }) }) @@ -24,7 +24,7 @@ func TestMemPool(t *testing.T) { {Size: 1, Capacity: 128}, }) require.Panics(t, func() { - pool.Get(256) + _, _ = pool.Get(256) }) }) diff --git a/tools/bloom/inspector/main.go b/tools/bloom/inspector/main.go index dfcc7c79cd86d..13bf1158da7dd 100644 --- a/tools/bloom/inspector/main.go +++ b/tools/bloom/inspector/main.go @@ -18,7 +18,7 @@ func main() { r := v1.NewDirectoryBlockReader(path) b := v1.NewBlock(r, v1.NewMetrics(nil)) - q := v1.NewBlockQuerier(b, true, v1.DefaultMaxPageSize) + q := v1.NewBlockQuerier(b, v1.HeapAllocator, v1.DefaultMaxPageSize) md, err := q.Metadata() if err != nil {