@@ -5,6 +5,7 @@ package query
55
66import (
77 "context"
8+ "slices"
89 "strings"
910 "sync"
1011 "time"
@@ -78,6 +79,7 @@ func NewQueryableCreator(
7879 maxConcurrentSelects int ,
7980 selectTimeout time.Duration ,
8081 deduplicationFunc string ,
82+ seriesResponseBatchSize int ,
8183) QueryableCreator {
8284 gf := gate .NewGateFactory (extprom .WrapRegistererWithPrefix ("concurrent_selects_" , reg ), maxConcurrentSelects , gate .Selects )
8385
@@ -104,34 +106,36 @@ func NewQueryableCreator(
104106 gateProviderFn : func () gate.Gate {
105107 return gf .New ()
106108 },
107- maxConcurrentSelects : maxConcurrentSelects ,
108- selectTimeout : selectTimeout ,
109- shardInfo : shardInfo ,
110- seriesStatsReporter : seriesStatsReporter ,
109+ maxConcurrentSelects : maxConcurrentSelects ,
110+ selectTimeout : selectTimeout ,
111+ shardInfo : shardInfo ,
112+ seriesStatsReporter : seriesStatsReporter ,
113+ seriesResponseBatchSize : seriesResponseBatchSize ,
111114 }
112115 }
113116}
114117
115118type queryable struct {
116- logger log.Logger
117- deduplicationFunc string
118- replicaLabels []string
119- storeDebugMatchers [][]* labels.Matcher
120- proxy storepb.StoreServer
121- deduplicate bool
122- maxResolutionMillis int64
123- partialResponse bool
124- skipChunks bool
125- gateProviderFn func () gate.Gate
126- maxConcurrentSelects int
127- selectTimeout time.Duration
128- shardInfo * storepb.ShardInfo
129- seriesStatsReporter seriesStatsReporter
119+ logger log.Logger
120+ deduplicationFunc string
121+ replicaLabels []string
122+ storeDebugMatchers [][]* labels.Matcher
123+ proxy storepb.StoreServer
124+ deduplicate bool
125+ maxResolutionMillis int64
126+ partialResponse bool
127+ skipChunks bool
128+ gateProviderFn func () gate.Gate
129+ maxConcurrentSelects int
130+ selectTimeout time.Duration
131+ shardInfo * storepb.ShardInfo
132+ seriesStatsReporter seriesStatsReporter
133+ seriesResponseBatchSize int
130134}
131135
132136// Querier returns a new storage querier against the underlying proxy store API.
133137func (q * queryable ) Querier (mint , maxt int64 ) (storage.Querier , error ) {
134- return newQuerier (q .logger , mint , maxt , q .deduplicationFunc , q .replicaLabels , q .storeDebugMatchers , q .proxy , q .deduplicate , q .maxResolutionMillis , q .partialResponse , q .skipChunks , q .gateProviderFn (), q .selectTimeout , q .shardInfo , q .seriesStatsReporter ), nil
138+ return newQuerier (q .logger , mint , maxt , q .deduplicationFunc , q .replicaLabels , q .storeDebugMatchers , q .proxy , q .deduplicate , q .maxResolutionMillis , q .partialResponse , q .skipChunks , q .gateProviderFn (), q .selectTimeout , q .shardInfo , q .seriesStatsReporter , q . seriesResponseBatchSize ), nil
135139}
136140
137141type querier struct {
@@ -149,6 +153,7 @@ type querier struct {
149153 selectTimeout time.Duration
150154 shardInfo * storepb.ShardInfo
151155 seriesStatsReporter seriesStatsReporter
156+ seriesResponseBatchSize int
152157}
153158
154159// newQuerier creates implementation of storage.Querier that fetches data from the proxy
@@ -169,6 +174,7 @@ func newQuerier(
169174 selectTimeout time.Duration ,
170175 shardInfo * storepb.ShardInfo ,
171176 seriesStatsReporter seriesStatsReporter ,
177+ seriesResponseBatchSize int ,
172178) * querier {
173179 if logger == nil {
174180 logger = log .NewNopLogger ()
@@ -195,6 +201,7 @@ func newQuerier(
195201 skipChunks : skipChunks ,
196202 shardInfo : shardInfo ,
197203 seriesStatsReporter : seriesStatsReporter ,
204+ seriesResponseBatchSize : seriesResponseBatchSize ,
198205 }
199206}
200207
@@ -224,6 +231,16 @@ func (s *seriesServer) Send(r *storepb.SeriesResponse) error {
224231 return nil
225232 }
226233
234+ if r .GetBatch () != nil {
235+ batch := * r .GetBatch ()
236+ s .seriesSet = slices .Grow (s .seriesSet , len (batch .Series ))
237+ for _ , series := range batch .Series {
238+ s .seriesSet = append (s .seriesSet , * series )
239+ s .seriesSetStats .Count (series )
240+ }
241+ return nil
242+ }
243+
227244 // Unsupported field, skip.
228245 return nil
229246}
@@ -353,6 +370,7 @@ func (q *querier) selectFn(ctx context.Context, hints *storage.SelectHints, ms .
353370 ShardInfo : q .shardInfo ,
354371 PartialResponseStrategy : q .partialResponseStrategy ,
355372 SkipChunks : q .skipChunks ,
373+ ResponseBatchSize : int64 (q .seriesResponseBatchSize ),
356374 }
357375 if q .isDedupEnabled () {
358376 // Soft ask to sort without replica labels and push them at the end of labelset.
0 commit comments