Skip to content

Commit

Permalink
addtl linting
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <ow.diehl@gmail.com>
  • Loading branch information
owen-d committed May 31, 2024
1 parent 4625589 commit be6f549
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pkg/bloomcompactor/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (s *SimpleBloomGenerator) populator(ctx context.Context) v1.BloomPopulatorF
Chunks: toAdd,
})

s.tokenizer.Populate(series, srcBlooms, chunkItersWithFP.itr, ch)
s.tokenizer.Populate(srcBlooms, chunkItersWithFP.itr, ch)

if s.reporter != nil {
s.reporter(series.Fingerprint)
Expand Down
6 changes: 2 additions & 4 deletions pkg/storage/bloom/v1/bloom_tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (

"github.com/go-kit/log/level"

"github.com/grafana/loki/pkg/push"
"github.com/grafana/loki/v3/pkg/iter"
"github.com/grafana/loki/v3/pkg/logproto"
"github.com/grafana/loki/v3/pkg/storage/bloom/v1/filter"

"github.com/grafana/loki/pkg/push"

"github.com/grafana/loki/v3/pkg/util/encoding"
util_log "github.com/grafana/loki/v3/pkg/util/log"
)
Expand Down Expand Up @@ -97,7 +98,6 @@ func (bt *BloomTokenizer) newBloom() *Bloom {
}

func (bt *BloomTokenizer) Populate(
series *Series,
blooms SizedIterator[*Bloom],
chks Iterator[ChunkRefWithIter],
ch chan *BloomCreation,
Expand Down Expand Up @@ -163,8 +163,6 @@ func (bt *BloomTokenizer) Populate(
SourceBytesAdded: bytesAdded,
}
close(ch)
return

}

// addChunkToBloom adds the tokens from the given chunk to the given bloom.
Expand Down
31 changes: 2 additions & 29 deletions pkg/storage/bloom/v1/bloom_tokenizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"testing"
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/grafana/dskit/multierror"

"github.com/grafana/loki/pkg/push"
Expand Down Expand Up @@ -101,8 +99,6 @@ func TestTokenizerPopulate(t *testing.T) {
bt := NewBloomTokenizer(DefaultNGramLength, DefaultNGramSkip, 0, metrics)

sbf := filter.NewScalableBloomFilter(1024, 0.01, 0.8)
var lbsList []labels.Labels
lbsList = append(lbsList, labels.FromStrings("foo", "bar"))

memChunk := chunkenc.NewMemChunk(chunkenc.ChunkFormatV4, chunkenc.EncSnappy, chunkenc.ChunkHeadFormatFor(chunkenc.ChunkFormatV4), 256000, 1500000)
_ = memChunk.Append(&push.Entry{
Expand All @@ -121,13 +117,9 @@ func TestTokenizerPopulate(t *testing.T) {
bloom := Bloom{
ScalableBloomFilter: *sbf,
}
series := Series{
Fingerprint: model.Fingerprint(lbsList[0].Hash()),
}

blooms, err := populateAndConsumeBloom(
bt,
series,
NewSliceIter([]*Bloom{&bloom}),
NewSliceIter([]ChunkRefWithIter{{Ref: ChunkRef{},
Itr: itr}}),
Expand All @@ -147,9 +139,6 @@ func TestBloomTokenizerPopulateWithoutPreexistingBloom(t *testing.T) {
var testLine = "this is a log line"
bt := NewBloomTokenizer(DefaultNGramLength, DefaultNGramSkip, 0, metrics)

var lbsList []labels.Labels
lbsList = append(lbsList, labels.FromStrings("foo", "bar"))

memChunk := chunkenc.NewMemChunk(chunkenc.ChunkFormatV4, chunkenc.EncSnappy, chunkenc.ChunkHeadFormatFor(chunkenc.ChunkFormatV4), 256000, 1500000)
_ = memChunk.Append(&push.Entry{
Timestamp: time.Unix(0, 1),
Expand All @@ -164,13 +153,8 @@ func TestBloomTokenizerPopulateWithoutPreexistingBloom(t *testing.T) {
)
require.Nil(t, err)

series := Series{
Fingerprint: model.Fingerprint(lbsList[0].Hash()),
}

blooms, err := populateAndConsumeBloom(
bt,
series,
NewEmptyIter[*Bloom](),
NewSliceIter([]ChunkRefWithIter{{Ref: ChunkRef{},
Itr: itr}}),
Expand Down Expand Up @@ -227,11 +211,6 @@ func TestTokenizerPopulateWontExceedMaxSize(t *testing.T) {
itr, err := chunkRefItrFromLines(line)
require.NoError(t, err)
go bt.Populate(
&Series{
Chunks: ChunkRefs{
{},
},
},
NewSliceIter([]*Bloom{
{
*filter.NewScalableBloomFilter(1024, 0.01, 0.8),
Expand All @@ -258,13 +237,12 @@ func TestTokenizerPopulateWontExceedMaxSize(t *testing.T) {

func populateAndConsumeBloom(
bt *BloomTokenizer,
s Series,
blooms SizedIterator[*Bloom],
chks Iterator[ChunkRefWithIter],
) (res []*Bloom, err error) {
var e multierror.MultiError
ch := make(chan *BloomCreation)
go bt.Populate(&s, blooms, chks, ch)
go bt.Populate(blooms, chks, ch)
for x := range ch {
if x.Err != nil {
e = append(e, x.Err)
Expand All @@ -281,8 +259,6 @@ func BenchmarkPopulateSeriesWithBloom(b *testing.B) {
bt := NewBloomTokenizer(DefaultNGramLength, DefaultNGramSkip, 0, metrics)

sbf := filter.NewScalableBloomFilter(1024, 0.01, 0.8)
var lbsList []labels.Labels
lbsList = append(lbsList, labels.FromStrings("foo", "bar"))

memChunk := chunkenc.NewMemChunk(chunkenc.ChunkFormatV4, chunkenc.EncSnappy, chunkenc.ChunkHeadFormatFor(chunkenc.ChunkFormatV4), 256000, 1500000)
_ = memChunk.Append(&push.Entry{
Expand All @@ -301,12 +277,9 @@ func BenchmarkPopulateSeriesWithBloom(b *testing.B) {
bloom := Bloom{
ScalableBloomFilter: *sbf,
}
series := Series{
Fingerprint: model.Fingerprint(lbsList[0].Hash()),
}

_, err = populateAndConsumeBloom(
bt,
series,
NewSliceIter([]*Bloom{&bloom}),
NewSliceIter([]ChunkRefWithIter{{Ref: ChunkRef{},
Itr: itr}}),
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/bloom/v1/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func (s *SeriesWithOffsets) Decode(
var (
err error
lastEnd model.Time
lastOffset BloomOffset = previousOffset
lastOffset = previousOffset
)
for i := range s.Offsets {
err = s.Offsets[i].Decode(dec, lastOffset)
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/bloom/v1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const (
magicNumber = uint32(0xCA7CAFE5)
// Add new versions below
V1 Version = iota
// V2 supports single series blooms encoded over multipe pages
// to accomodate larger single series
// V2 supports single series blooms encoded over multiple pages
// to accommodate larger single series
V2
)

Expand Down
1 change: 1 addition & 0 deletions pkg/storage/bloom/v1/versioned_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ type SeriesWithBloom struct {
Bloom *Bloom
}

//nolint:revive
type V1Builder struct {
opts BlockOptions

Expand Down

0 comments on commit be6f549

Please sign in to comment.