@@ -450,11 +450,10 @@ func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool
450
450
span , ctx := opentracing .StartSpanFromContext (ctx , "parquetQuerierWithFallback.Select" )
451
451
defer span .Finish ()
452
452
453
- newMatchers , shardMatcher , err := querysharding .ExtractShardingMatchers (matchers )
453
+ newMatchers , shardInfo , err := querysharding .ExtractShardingInfo (matchers )
454
454
if err != nil {
455
455
return storage .ErrSeriesSet (err )
456
456
}
457
- defer shardMatcher .Close ()
458
457
459
458
hints := storage.SelectHints {
460
459
Start : q .minT ,
@@ -501,8 +500,8 @@ func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool
501
500
span , _ := opentracing .StartSpanFromContext (ctx , "parquetQuerier.Select" )
502
501
defer span .Finish ()
503
502
parquetCtx := InjectBlocksIntoContext (ctx , parquet ... )
504
- if shardMatcher != nil {
505
- parquetCtx = injectShardMatcherIntoContext (parquetCtx , shardMatcher )
503
+ if shardInfo != nil {
504
+ parquetCtx = injectShardInfoIntoContext (parquetCtx , shardInfo )
506
505
}
507
506
p <- q .parquetQuerier .Select (parquetCtx , sortSeries , & hints , newMatchers ... )
508
507
}()
@@ -604,11 +603,15 @@ func (f *shardMatcherLabelsFilter) Close() {
604
603
}
605
604
606
605
func materializedLabelsFilterCallback (ctx context.Context , _ * storage.SelectHints ) (search.MaterializedLabelsFilter , bool ) {
607
- shardMatcher , exists := extractShardMatcherFromContext (ctx )
608
- if ! exists || ! shardMatcher . IsSharded () {
606
+ shardInfo , exists := extractShardInfoFromContext (ctx )
607
+ if ! exists {
609
608
return nil , false
610
609
}
611
- return & shardMatcherLabelsFilter {shardMatcher : shardMatcher }, true
610
+ sm := shardInfo .Matcher (& querysharding .Buffers )
611
+ if ! sm .IsSharded () {
612
+ return nil , false
613
+ }
614
+ return & shardMatcherLabelsFilter {shardMatcher : sm }, true
612
615
}
613
616
614
617
type cacheInterface [T any ] interface {
@@ -698,16 +701,16 @@ func (n noopCache[T]) Set(_ string, _ T) {
698
701
}
699
702
700
703
var (
701
- shardMatcherCtxKey contextKey = 1
704
+ shardInfoCtxKey contextKey = 1
702
705
)
703
706
704
- func injectShardMatcherIntoContext (ctx context.Context , sm * storepb.ShardMatcher ) context.Context {
705
- return context .WithValue (ctx , shardMatcherCtxKey , sm )
707
+ func injectShardInfoIntoContext (ctx context.Context , si * storepb.ShardInfo ) context.Context {
708
+ return context .WithValue (ctx , shardInfoCtxKey , si )
706
709
}
707
710
708
- func extractShardMatcherFromContext (ctx context.Context ) (* storepb.ShardMatcher , bool ) {
709
- if sm := ctx .Value (shardMatcherCtxKey ); sm != nil {
710
- return sm .(* storepb.ShardMatcher ), true
711
+ func extractShardInfoFromContext (ctx context.Context ) (* storepb.ShardInfo , bool ) {
712
+ if si := ctx .Value (shardInfoCtxKey ); si != nil {
713
+ return si .(* storepb.ShardInfo ), true
711
714
}
712
715
713
716
return nil , false
0 commit comments