44 "context"
55 "fmt"
66 "github.com/cortexproject/cortex/pkg/engine/distributed_execution"
7- "github.com/cortexproject/cortex/pkg/scheduler/plan_fragments"
87 "net/http"
98 "strconv"
109 "time"
@@ -141,10 +140,10 @@ func (q *QueryAPI) RangeQueryHandler(r *http.Request) (result apiFuncResult) {
141140 ctx = httputil .ContextFromRequest (ctx , r )
142141
143142 // TODO: if distributed exec enabled
144- isRoot , queryID , fragmentID , _ := plan_fragments .ExtractFragmentMetaData (ctx )
143+ isRoot , queryID , fragmentID , _ , _ := distributed_execution .ExtractFragmentMetaData (ctx )
145144 if ! isRoot {
146145 key := distributed_execution .MakeFragmentKey (queryID , fragmentID )
147- q .queryResultCache .InitWriting (key )
146+ q .queryResultCache .InitWriting (* key )
148147 }
149148
150149 res := qry .Exec (ctx )
@@ -190,10 +189,10 @@ func (q *QueryAPI) InstantQueryHandler(r *http.Request) (result apiFuncResult) {
190189 ctx = querier .AddBlockStoreTypeToContext (ctx , r .Header .Get (querier .BlockStoreTypeHeader ))
191190
192191 // TODO: if distributed exec enabled
193- isRoot , queryID , fragmentID , _ := plan_fragments .ExtractFragmentMetaData (ctx )
192+ isRoot , queryID , fragmentID , _ , _ := distributed_execution .ExtractFragmentMetaData (ctx )
194193 if ! isRoot {
195194 key := distributed_execution .MakeFragmentKey (queryID , fragmentID )
196- q .queryResultCache .InitWriting (key )
195+ q .queryResultCache .InitWriting (* key )
197196 }
198197
199198 var qry promql.Query
@@ -205,15 +204,15 @@ func (q *QueryAPI) InstantQueryHandler(r *http.Request) (result apiFuncResult) {
205204 if err != nil {
206205 if ! isRoot {
207206 key := distributed_execution .MakeFragmentKey (queryID , fragmentID )
208- q .queryResultCache .SetError (key )
207+ q .queryResultCache .SetError (* key )
209208 }
210209 return apiFuncResult {nil , & apiError {errorInternal , fmt .Errorf ("invalid logical plan: %v" , err )}, nil , nil }
211210 }
212211 qry , err = q .queryEngine .MakeInstantQueryFromPlan (ctx , q .queryable , opts , logicalPlan , tsTime , r .FormValue ("query" ))
213212 if err != nil {
214213 if ! isRoot {
215214 key := distributed_execution .MakeFragmentKey (queryID , fragmentID )
216- q .queryResultCache .SetError (key )
215+ q .queryResultCache .SetError (* key )
217216 }
218217 return apiFuncResult {nil , & apiError {errorInternal , fmt .Errorf ("failed to create instant query from logical plan: %v" , err )}, nil , nil }
219218 }
@@ -267,14 +266,14 @@ func (q *QueryAPI) Wrap(f apiFunc) http.HandlerFunc {
267266 if result .data != nil {
268267 // TODO: if distributed exec enabled
269268 ctx := httputil .ContextFromRequest (r .Context (), r )
270- isRoot , queryID , fragmentID , _ := plan_fragments .ExtractFragmentMetaData (ctx )
269+ isRoot , queryID , fragmentID , _ , _ := distributed_execution .ExtractFragmentMetaData (ctx )
271270 if ! isRoot {
272271 key := distributed_execution .MakeFragmentKey (queryID , fragmentID )
273272 result := distributed_execution.FragmentResult {
274273 Data : result .data ,
275274 Expiration : time .Now ().Add (time .Hour ),
276275 }
277- q .queryResultCache .SetComplete (key , result )
276+ q .queryResultCache .SetComplete (* key , result )
278277 return
279278 }
280279 q .respond (w , r , result .data , result .warnings , r .FormValue ("query" ))
0 commit comments