@@ -450,11 +450,10 @@ func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool
450450 span , ctx := opentracing .StartSpanFromContext (ctx , "parquetQuerierWithFallback.Select" )
451451 defer span .Finish ()
452452
453- newMatchers , shardMatcher , err := querysharding .ExtractShardingMatchers (matchers )
453+ newMatchers , shardInfo , err := querysharding .ExtractShardingInfo (matchers )
454454 if err != nil {
455455 return storage .ErrSeriesSet (err )
456456 }
457- defer shardMatcher .Close ()
458457
459458 hints := storage.SelectHints {
460459 Start : q .minT ,
@@ -501,8 +500,8 @@ func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool
501500 span , _ := opentracing .StartSpanFromContext (ctx , "parquetQuerier.Select" )
502501 defer span .Finish ()
503502 parquetCtx := InjectBlocksIntoContext (ctx , parquet ... )
504- if shardMatcher != nil {
505- parquetCtx = injectShardMatcherIntoContext (parquetCtx , shardMatcher )
503+ if shardInfo != nil {
504+ parquetCtx = injectShardInfoIntoContext (parquetCtx , shardInfo )
506505 }
507506 p <- q .parquetQuerier .Select (parquetCtx , sortSeries , & hints , newMatchers ... )
508507 }()
@@ -604,11 +603,15 @@ func (f *shardMatcherLabelsFilter) Close() {
604603}
605604
606605func 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 {
609608 return nil , false
610609 }
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
612615}
613616
614617type cacheInterface [T any ] interface {
@@ -698,16 +701,16 @@ func (n noopCache[T]) Set(_ string, _ T) {
698701}
699702
700703var (
701- shardMatcherCtxKey contextKey = 1
704+ shardInfoCtxKey contextKey = 1
702705)
703706
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 )
706709}
707710
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
711714 }
712715
713716 return nil , false
0 commit comments