MCPcopy
hub / github.com/pingcap/tidb / scanFirstKVForEachRange

Method scanFirstKVForEachRange

pkg/executor/sample.go:300–327  ·  view source on GitHub ↗
(ranges []kv.KeyRange,
	fn func(handle kv.Handle, value []byte) error)

Source from the content-addressed store, hash-verified

298}
299
300func (s *tableRegionSampler) scanFirstKVForEachRange(ranges []kv.KeyRange,
301 fn func(handle kv.Handle, value []byte) error) error {
302 ver := kv.Version{Ver: s.startTS}
303 snap := s.ctx.GetStore().GetSnapshot(ver)
304 setOptionForTopSQL(s.ctx.GetSessionVars().StmtCtx, snap)
305 concurrency := s.ctx.GetSessionVars().ExecutorConcurrency
306 if len(ranges) < concurrency {
307 concurrency = len(ranges)
308 }
309
310 fetchers := make([]*sampleFetcher, concurrency)
311 for i := 0; i < concurrency; i++ {
312 fetchers[i] = &sampleFetcher{
313 workerID: i,
314 concurrency: concurrency,
315 kvChan: make(chan *sampleKV),
316 snapshot: snap,
317 ranges: ranges,
318 }
319 go fetchers[i].run()
320 }
321 syncer := sampleSyncer{
322 fetchers: fetchers,
323 totalCount: len(ranges),
324 consumeFn: fn,
325 }
326 return syncer.sync()
327}
328
329func (s *tableRegionSampler) resetRowMap() {
330 if s.rowMap == nil {

Callers 1

writeChunkFromRangesMethod · 0.95

Calls 6

syncMethod · 0.95
setOptionForTopSQLFunction · 0.85
GetSnapshotMethod · 0.65
GetStoreMethod · 0.65
GetSessionVarsMethod · 0.65
runMethod · 0.65

Tested by

no test coverage detected