Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <[email protected]>
  • Loading branch information
owen-d committed Mar 29, 2024
1 parent 298cae0 commit b31c2c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/ingester/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (ii *InvertedIndex) validateShard(shard *logql.Shard) (*index.ShardAnnotati
return nil, errors.New("inverted index only supports shard annotations with `PowerOfTwo`")
}

if ii.totalShards%s.Of != 0 || uint32(s.Of) > ii.totalShards {
if ii.totalShards%s.Of != 0 || s.Of > ii.totalShards {
return nil, fmt.Errorf("%w index_shard:%d query_shard:%v", ErrInvalidShardQuery, ii.totalShards, s)
}
return s, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingester/index/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func Test_hash_mapping(t *testing.T) {
ii := NewWithShards(shard)
ii.Add(logproto.FromLabelsToLabelAdapters(lbs), 1)

x := logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: uint32(labelsSeriesIDHash(lbs) % 16), Of: 16})
x := logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: labelsSeriesIDHash(lbs) % 16, Of: 16})
res, err := ii.Lookup([]*labels.Matcher{{Type: labels.MatchEqual, Name: "compose_project", Value: "loki-tsdb-storage-s3"}}, &x)
require.NoError(t, err)
require.Len(t, res, 1)
Expand All @@ -136,7 +136,7 @@ func Test_NoMatcherLookup(t *testing.T) {
// with shard param
ii = NewWithShards(16)
ii.Add(logproto.FromLabelsToLabelAdapters(lbs), 1)
x := logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: uint32(labelsSeriesIDHash(lbs) % 16), Of: 16})
x := logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: labelsSeriesIDHash(lbs) % 16, Of: 16})
ids, err = ii.Lookup(nil, &x)
require.Nil(t, err)
require.Equal(t, model.Fingerprint(1), ids[0])
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingester/index/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestMultiIndex(t *testing.T) {
labels.MustNewMatcher(labels.MatchEqual, "foo", "foo"),
},
logql.NewPowerOfTwoShard(
index.ShardAnnotation{Shard: uint32(expShard), Of: uint32(factor)},
index.ShardAnnotation{Shard: expShard, Of: factor},
).Ptr(),
)

Expand All @@ -146,7 +146,7 @@ func TestMultiIndex(t *testing.T) {
[]*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "foo", "foo"),
},
logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: uint32(expShard), Of: uint32(factor)}).Ptr(),
logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: expShard, Of: factor}).Ptr(),
)

require.Nil(t, err)
Expand Down

0 comments on commit b31c2c9

Please sign in to comment.