MCPcopy Create free account
hub / github.com/pingcap/tidb / fetchAllInners

Method fetchAllInners

pkg/executor/parallel_apply.go:281–348  ·  view source on GitHub ↗

fetchAllInners reads all data from the inner table and stores them in a List.

(ctx context.Context, id int)

Source from the content-addressed store, hash-verified

279
280// fetchAllInners reads all data from the inner table and stores them in a List.
281func (e *ParallelNestedLoopApplyExec) fetchAllInners(ctx context.Context, id int) (err error) {
282 var key []byte
283 for _, col := range e.corCols[id] {
284 *col.Data = e.outerRow[id].GetDatum(col.Index, col.RetType)
285 if e.useCache {
286 key, err = codec.EncodeKey(e.Ctx().GetSessionVars().StmtCtx.TimeZone(), key, *col.Data)
287 err = e.Ctx().GetSessionVars().StmtCtx.HandleError(err)
288 if err != nil {
289 return err
290 }
291 }
292 }
293 if e.useCache { // look up the cache
294 atomic.AddInt64(&e.cacheAccessCounter, 1)
295 failpoint.Inject("parallelApplyGetCachePanic", nil)
296 value, err := e.cache.Get(key)
297 if err != nil {
298 return err
299 }
300 if value != nil {
301 e.innerList[id] = value
302 atomic.AddInt64(&e.cacheHitCounter, 1)
303 return nil
304 }
305 }
306
307 err = exec.Open(ctx, e.innerExecs[id])
308 defer func() { terror.Log(exec.Close(e.innerExecs[id])) }()
309 if err != nil {
310 return err
311 }
312
313 if e.useCache {
314 // create a new one in this case since it may be in the cache
315 e.innerList[id] = chunk.NewList(exec.RetTypes(e.innerExecs[id]), e.InitCap(), e.MaxChunkSize())
316 } else {
317 e.innerList[id].Reset()
318 }
319
320 innerIter := chunk.NewIterator4Chunk(e.innerChunk[id])
321 for {
322 err := exec.Next(ctx, e.innerExecs[id], e.innerChunk[id])
323 if err != nil {
324 return err
325 }
326 if e.innerChunk[id].NumRows() == 0 {
327 break
328 }
329
330 e.innerSelected[id], err = expression.VectorizedFilter(e.Ctx().GetExprCtx().GetEvalCtx(), e.Ctx().GetSessionVars().EnableVectorizedExpression, e.innerFilter[id], innerIter, e.innerSelected[id])
331 if err != nil {
332 return err
333 }
334 for row := innerIter.Begin(); row != innerIter.End(); row = innerIter.Next() {
335 if e.innerSelected[id][row.Idx()] {
336 e.innerList[id].AppendRow(row)
337 }
338 }

Callers 1

fillInnerChunkMethod · 0.95

Calls 15

BeginMethod · 0.95
EndMethod · 0.95
NextMethod · 0.95
EncodeKeyFunction · 0.92
OpenFunction · 0.92
LogFunction · 0.92
CloseFunction · 0.92
NewListFunction · 0.92
RetTypesFunction · 0.92
NewIterator4ChunkFunction · 0.92
NextFunction · 0.92
VectorizedFilterFunction · 0.92

Tested by

no test coverage detected