Skip to content

Commit

Permalink
cherry pick pingcap#34234 to release-6.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
time-and-fate authored and ti-srebot committed Apr 28, 2022
1 parent 36a9810 commit 44afa8c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions statistics/handle/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (h *Handle) initStatsHistograms(is infoschema.InfoSchema, cache *statsCache
}

func (h *Handle) initStatsTopN4Chunk(cache *statsCache, iter *chunk.Iterator4Chunk) {
affectedIndexes := make(map[int64]*statistics.Index)
affectedIndexes := make(map[*statistics.Index]struct{})
for row := iter.Begin(); row != iter.End(); row = iter.Next() {
table, ok := cache.tables[row.GetInt64(0)]
if !ok {
Expand All @@ -192,12 +192,12 @@ func (h *Handle) initStatsTopN4Chunk(cache *statsCache, iter *chunk.Iterator4Chu
if idx.TopN == nil {
idx.TopN = statistics.NewTopN(32)
}
affectedIndexes[row.GetInt64(1)] = idx
affectedIndexes[idx] = struct{}{}
data := make([]byte, len(row.GetBytes(2)))
copy(data, row.GetBytes(2))
idx.TopN.AppendTopN(data, row.GetUint64(3))
}
for _, idx := range affectedIndexes {
for idx := range affectedIndexes {
idx.TopN.Sort()
}
}
Expand Down

0 comments on commit 44afa8c

Please sign in to comment.