Skip to content

Commit

Permalink
executor: reduce a place of object allocation for HashAggExec (#37300)
Browse files Browse the repository at this point in the history
close #37299
  • Loading branch information
tiancaiamao authored Aug 24, 2022
1 parent 81a93a6 commit 75c70ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion executor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ func (e *HashAggExec) execute(ctx context.Context) (err error) {

allMemDelta := int64(0)
sel := make([]int, 0, e.childResult.NumRows())
var tmpBuf [1]chunk.Row
for j := 0; j < e.childResult.NumRows(); j++ {
groupKey := string(e.groupKeyBuffer[j]) // do memory copy here, because e.groupKeyBuffer may be reused.
if !e.groupSet.Exist(groupKey) {
Expand All @@ -1037,7 +1038,8 @@ func (e *HashAggExec) execute(ctx context.Context) (err error) {
}
partialResults := e.getPartialResults(groupKey)
for i, af := range e.PartialAggFuncs {
memDelta, err := af.UpdatePartialResult(e.ctx, []chunk.Row{e.childResult.GetRow(j)}, partialResults[i])
tmpBuf[0] = e.childResult.GetRow(j)
memDelta, err := af.UpdatePartialResult(e.ctx, tmpBuf[:], partialResults[i])
if err != nil {
return err
}
Expand Down

0 comments on commit 75c70ec

Please sign in to comment.