-
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: remove Next function for HashAggExec #5987
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d4ba984
Remove HashAggExec Next method of executor/aggregate.go
lwhile 5e71985
Remove HashAggExec innerNext method of executor/aggregate.go
lwhile 60fcb18
Merge branch 'master' into patch-3
zz-jason 6365057
Merge branch 'master' into patch-3
shenli d609b73
Merge branch 'master' into patch-3
lwhile 8d0a515
Merge branch 'master' into patch-3
lwhile 9b9d5ab
run gofmt tool
lwhile 0672337
Merge branch 'master' into patch-3
lwhile 84f2d3c
Merge branch 'master' into patch-3
lwhile 0572b00
Merge branch 'master' into patch-3
lwhile 273e2f2
Remove Next function totally
lwhile 7b422c6
Merge branch 'master' into patch-3
lwhile 26f12ca
Merge branch 'master' into patch-3
zz-jason 05d5dfd
Merge branch 'master' into patch-3
lwhile 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,37 +143,7 @@ func (e *HashAggExec) execute(ctx context.Context) (err error) { | |
|
||
// Next implements the Executor Next interface. | ||
func (e *HashAggExec) Next(ctx context.Context) (Row, error) { | ||
// In this stage we consider all data from src as a single group. | ||
if !e.executed { | ||
for { | ||
hasMore, err := e.innerNext(ctx) | ||
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. can we remove 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. I think so, let me remove it. |
||
if err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
if !hasMore { | ||
break | ||
} | ||
} | ||
if (e.groupMap.Len() == 0) && len(e.GroupByItems) == 0 { | ||
// If no groupby and no data, we should add an empty group. | ||
// For example: | ||
// "select count(c) from t;" should return one row [0] | ||
// "select count(c) from t group by c1;" should return empty result set. | ||
e.groupMap.Put([]byte{}, []byte{}) | ||
} | ||
e.executed = true | ||
} | ||
|
||
groupKey, _ := e.groupIterator.Next() | ||
if groupKey == nil { | ||
return nil, nil | ||
} | ||
retRow := make([]types.Datum, 0, len(e.AggFuncs)) | ||
aggCtxs := e.getContexts(groupKey) | ||
for i, af := range e.AggFuncs { | ||
retRow = append(retRow, af.GetResult(aggCtxs[i])) | ||
} | ||
return retRow, nil | ||
return nil, nil | ||
} | ||
|
||
func (e *HashAggExec) getGroupKey(row types.Row) ([]byte, error) { | ||
|
@@ -196,34 +166,6 @@ func (e *HashAggExec) getGroupKey(row types.Row) ([]byte, error) { | |
return e.groupKey, nil | ||
} | ||
|
||
// innerNext fetches a single row from src and update each aggregate function. | ||
// If the first return value is false, it means there is no more data from src. | ||
func (e *HashAggExec) innerNext(ctx context.Context) (ret bool, err error) { | ||
srcRow, err := e.children[0].Next(ctx) | ||
if err != nil { | ||
return false, errors.Trace(err) | ||
} | ||
if srcRow == nil { | ||
return false, nil | ||
} | ||
e.executed = true | ||
groupKey, err := e.getGroupKey(srcRow) | ||
if err != nil { | ||
return false, errors.Trace(err) | ||
} | ||
if len(e.groupMap.Get(groupKey, e.groupVals[:0])) == 0 { | ||
e.groupMap.Put(groupKey, []byte{}) | ||
} | ||
aggCtxs := e.getContexts(groupKey) | ||
for i, af := range e.AggFuncs { | ||
err = af.Update(aggCtxs[i], e.sc, srcRow) | ||
if err != nil { | ||
return false, errors.Trace(err) | ||
} | ||
} | ||
return true, nil | ||
} | ||
|
||
func (e *HashAggExec) getContexts(groupKey []byte) []*aggregation.AggEvaluateContext { | ||
groupKeyString := string(groupKey) | ||
aggCtxs, ok := e.aggCtxsMap[groupKeyString] | ||
|
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 can remore
Next
function totally now.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.
removed