-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
executor: introduce a new execution framework for aggregate functions #6852
Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
182658b
executor: refactor aggregate functions
zz-jason 01ec369
change type name
zz-jason faa3f7d
Merge branch 'master' into dev/refactor-agg
zz-jason 1ebf4d5
Merge branch 'master' into dev/refactor-agg
zz-jason 038135a
Merge branch 'master' into dev/refactor-agg
zz-jason 7f1fd3a
handle distinct in partial1 and complete mode
zz-jason e5acefb
handle 0 count
zz-jason e25d273
Merge branch 'master' into dev/refactor-agg
zz-jason dca132a
add implementation of SUM
zz-jason 81c812b
Merge branch 'dev/refactor-agg' of https://github.com/zz-jason/tidb i…
zz-jason cacad7c
add missing file
zz-jason d3a1ced
only introduce the framework in this PR
zz-jason cf34a16
remove useless code
zz-jason b1335c3
remove debug log
zz-jason ce821f9
Merge branch 'master' into dev/refactor-agg
zz-jason dbbef24
fix ci
zz-jason 57f57b8
Merge branch 'dev/refactor-agg' of https://github.com/zz-jason/tidb i…
zz-jason 5f17822
address comment
zz-jason aa71782
address comment
zz-jason f3b005f
address comment
zz-jason c7f7144
Merge branch 'master' into dev/refactor-agg
lysu 66801be
Merge branch 'master' into dev/refactor-agg
zz-jason 0d859db
addres comment
zz-jason 7f8134c
Merge branch 'master' into dev/refactor-agg
coocood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ func (e *avgDedup4Decimal) UpdatePartialResult(sctx sessionctx.Context, rowsInGr | |
|
||
type avgOriginal4Decimal struct { | ||
baseAvgDecimal | ||
deDuper map[types.MyDecimal]bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deDuper should be initialized |
||
} | ||
|
||
func (e *avgOriginal4Decimal) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, partialBytes []byte) error { | ||
|
@@ -109,7 +110,7 @@ func (e *avgOriginal4Decimal) UpdatePartialResult(sctx sessionctx.Context, rowsI | |
input, isNull, err := e.input[0].EvalDecimal(sctx, row) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} else if isNull { | ||
} else if isNull || (e.deDuper != nil && e.deDuper[*input]) { | ||
continue | ||
} | ||
err = types.DecimalAdd(&partialResult.sum, input, newSum) | ||
|
@@ -118,6 +119,9 @@ func (e *avgOriginal4Decimal) UpdatePartialResult(sctx sessionctx.Context, rowsI | |
} | ||
partialResult.sum = *newSum | ||
partialResult.count++ | ||
if e.deDuper != nil { | ||
e.deDuper[*input] = true | ||
} | ||
} | ||
return nil | ||
} | ||
|
@@ -207,6 +211,7 @@ func (e *avgDedup4Float64) UpdatePartialResult(sctx sessionctx.Context, rowsInGr | |
|
||
type avgOriginal4Float64 struct { | ||
baseAvgFloat64 | ||
deDuper map[float64]bool | ||
} | ||
|
||
func (e *avgOriginal4Float64) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, partialBytes []byte) error { | ||
|
@@ -215,11 +220,14 @@ func (e *avgOriginal4Float64) UpdatePartialResult(sctx sessionctx.Context, rowsI | |
input, isNull, err := e.input[0].EvalReal(sctx, row) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} else if isNull { | ||
} else if isNull || (e.deDuper != nil && e.deDuper[input]) { | ||
continue | ||
} | ||
partialResult.sum += input | ||
partialResult.count++ | ||
if e.deDuper != nil { | ||
e.deDuper[input] = true | ||
} | ||
} | ||
return nil | ||
} | ||
|
@@ -303,6 +311,7 @@ func (e *avgDedup4Float32) UpdatePartialResult(sctx sessionctx.Context, rowsInGr | |
|
||
type avgOriginal4Float32 struct { | ||
baseAvgFloat32 | ||
deDuper map[float32]bool | ||
} | ||
|
||
func (e *avgOriginal4Float32) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, partialBytes []byte) error { | ||
|
@@ -311,11 +320,14 @@ func (e *avgOriginal4Float32) UpdatePartialResult(sctx sessionctx.Context, rowsI | |
input, isNull, err := e.input[0].EvalReal(sctx, row) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} else if isNull { | ||
} else if isNull || (e.deDuper != nil && e.deDuper[float32(input)]) { | ||
continue | ||
} | ||
partialResult.sum += float32(input) | ||
partialResult.count++ | ||
if e.deDuper != nil { | ||
e.deDuper[float32(input)] = true | ||
} | ||
} | ||
return nil | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should consider all the input types,
use EvalType here may be better?