Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
  • Loading branch information
chaudum committed May 27, 2024
1 parent c6c17ac commit e49f84b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions pkg/storage/bloom/v1/mempool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/bloom/v1/mempool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

Expand All @@ -24,7 +24,7 @@ func TestMemPool(t *testing.T) {
{Size: 1, Capacity: 128},
})
require.Panics(t, func() {
pool.Get(256)
_, _ = pool.Get(256)
})
})

Expand Down
2 changes: 1 addition & 1 deletion tools/bloom/inspector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e49f84b

Please sign in to comment.