Skip to content

Commit 12fce8a

Browse files
committed
fix some linting / test
1 parent 5fb95c5 commit 12fce8a

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

pkg/cortexpb/slicesPool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type byteSlicePools struct {
99
pools []sync.Pool
1010
}
1111

12-
func NewSlicePool(pools int) *byteSlicePools {
12+
func newSlicePool(pools int) *byteSlicePools {
1313
sp := byteSlicePools{}
1414
sp.init(pools)
1515
return &sp
@@ -39,7 +39,7 @@ func (sp *byteSlicePools) getSlice(size int) []byte {
3939
}
4040

4141
func (sp *byteSlicePools) reuseSlice(s []byte) {
42-
index := int(math.Ceil(math.Log2(float64(cap(s)))))
42+
index := int(math.Floor(math.Log2(float64(cap(s)))))
4343

4444
if index < 0 || index >= len(sp.pools) {
4545
return

pkg/cortexpb/slicesPool_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import (
77
)
88

99
func TestByteSlicePools(t *testing.T) {
10-
sut := NewSlicePool(20)
11-
10+
sut := newSlicePool(20)
1211
for i := 0; i < 1024*1024; i = i + 128 {
1312
s := sut.getSlice(i)
1413
assert.Equal(t, len(s), i)
1514
sut.reuseSlice(s)
1615
}
17-
1816
}

pkg/cortexpb/timeseries.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var (
4545
}
4646
},
4747
}
48-
bytePool = NewSlicePool(20)
48+
bytePool = newSlicePool(20)
4949
)
5050

5151
// PreallocConfig configures how structures will be preallocated to optimise
@@ -82,11 +82,11 @@ func (p *PreallocTimeseries) Unmarshal(dAtA []byte) error {
8282
return p.TimeSeries.Unmarshal(dAtA)
8383
}
8484

85-
func (m *PreallocWriteRequest) Marshal() (dAtA []byte, err error) {
86-
size := m.Size()
85+
func (p *PreallocWriteRequest) Marshal() (dAtA []byte, err error) {
86+
size := p.Size()
8787
dAtA = bytePool.getSlice(size)
88-
m.data = dAtA
89-
n, err := m.MarshalToSizedBuffer(dAtA[:size])
88+
p.data = dAtA
89+
n, err := p.MarshalToSizedBuffer(dAtA[:size])
9090
if err != nil {
9191
return nil, err
9292
}

pkg/distributor/distributor_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,10 @@ func (i *mockIngester) Close() error {
26882688
return nil
26892689
}
26902690

2691+
func (i *mockIngester) PushPreAlloc(ctx context.Context, in *cortexpb.PreallocWriteRequest, opts ...grpc.CallOption) (*cortexpb.WriteResponse, error) {
2692+
return i.Push(ctx, &in.WriteRequest, opts...)
2693+
}
2694+
26912695
func (i *mockIngester) Push(ctx context.Context, req *cortexpb.WriteRequest, opts ...grpc.CallOption) (*cortexpb.WriteResponse, error) {
26922696
i.Lock()
26932697
defer i.Unlock()

0 commit comments

Comments
 (0)