Skip to content

Commit

Permalink
statistics: kill in time when to run topnStatsMergeWorker and remove …
Browse files Browse the repository at this point in the history
…useless

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Aug 2, 2023
1 parent 412fa13 commit c8246aa
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions statistics/merge_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,7 @@ func (worker *topnStatsMergeWorker) Run(timeZone *time.Location, isIndex bool,
}
partNum := len(allTopNs)
checkNum := len(checkTopNs)
topNsNum := make([]int, checkNum)
removeVals := make([][]TopNMeta, partNum)
for i, topN := range checkTopNs {
if topN == nil {
topNsNum[i] = 0
continue
}
topNsNum[i] = len(topN.TopN)
}
// Different TopN structures may hold the same value, we have to merge them.
counter := make(map[hack.MutableString]float64)
// datumMap is used to store the mapping from the string type to datum type.
Expand Down Expand Up @@ -136,6 +128,11 @@ func (worker *topnStatsMergeWorker) Run(timeZone *time.Location, isIndex bool,
// 1. Check the topN first.
// 2. If the topN doesn't contain the value corresponding to encodedVal. We should check the histogram.
for j := 0; j < partNum; j++ {
if atomic.LoadUint32(worker.killed) == 1 {
resp.Err = errors.Trace(ErrQueryInterrupted)
worker.respCh <- resp
return
}
if (j == i && version >= 2) || allTopNs[j].findTopN(val.Encoded) != -1 {
continue
}
Expand Down

0 comments on commit c8246aa

Please sign in to comment.