Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 committed Feb 23, 2021
1 parent 001b34e commit 38b77d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions executor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ func getGroupKey(ctx sessionctx.Context, input *chunk.Chunk, groupKey [][]byte,
func (w *baseHashAggWorker) getPartialResult(sc *stmtctx.StatementContext, groupKey [][]byte, mapper aggPartialResultMapper) [][]aggfuncs.PartialResult {
n := len(groupKey)
partialResults := make([][]aggfuncs.PartialResult, n)
allMemDelta := int64(0)
for i := 0; i < n; i++ {
var ok bool
if partialResults[i], ok = mapper[string(groupKey[i])]; ok {
Expand All @@ -531,16 +532,17 @@ func (w *baseHashAggWorker) getPartialResult(sc *stmtctx.StatementContext, group
for _, af := range w.aggFuncs {
partialResult, memDelta := af.AllocPartialResult()
partialResults[i] = append(partialResults[i], partialResult)
w.memTracker.Consume(memDelta)
allMemDelta += memDelta
}
mapper[string(groupKey[i])] = partialResults[i]
w.memTracker.Consume(int64(len(groupKey[i])))
allMemDelta += int64(len(groupKey[i]))
// Map will expand when count > bucketNum * loadFactor. The memory usage will doubled.
if len(mapper) > (1<<w.BInMap)*loadFactorNum/loadFactorDen {
w.memTracker.Consume(defBucketMemoryUsage * (1 << w.BInMap))
w.BInMap++
}
}
w.memTracker.Consume(allMemDelta)
return partialResults
}

Expand Down

0 comments on commit 38b77d3

Please sign in to comment.