-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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, expression: add a tryToMatchOuters for joiner #11922
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11922 +/- ##
===========================================
Coverage 81.5083% 81.5083%
===========================================
Files 449 449
Lines 97390 97390
===========================================
Hits 79381 79381
Misses 12385 12385
Partials 5624 5624 |
/run-all-tests |
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.
LGTM
} | ||
outerRowStatus = append(outerRowStatus, outerRowMatched) | ||
if matched { | ||
chk.AppendPartialRow(0, outer) |
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.
Should we only decrease numToAppend
when this operation is performed?
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.
No~ outers.Next is needed.
executor/joiner.go
Outdated
} | ||
return outerRowStatus, nil | ||
} | ||
for outer, i := outers.Current(), 0; outer != outers.End() && numToAppend > 0; outer, numToAppend, i = outers.Next(), numToAppend-1, i+1 { |
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.
i
is unused.
executor/joiner.go
Outdated
return outerRowStatus, nil | ||
} | ||
|
||
for i := 0; outer != outers.End() && numToAppend > 0; outer, numToAppend, i = outers.Next(), numToAppend-1, i+1 { |
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.
i
is unused
PTAL @zz-jason |
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.
LGTM
task.outerRowStatus[rowIdx] = outerRowHasNull | ||
for _, status := range iw.outerRowStatus { | ||
outerRowIdx := matchedOuterRowIdx[cursor] | ||
if status == outerRowMatched || task.outerRowStatus[outerRowIdx] == outerRowUnmatched { |
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.
can it be replaced with the following condition?
if task.outerRowStatus[outerRowIdx] == outerRowUnMatched {
task.outerRowStatus[outerRowIdx] = status
}
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.
No
If so, when task.outerRowStatus[outerRowIdx] == outerRowHasNull && status == outerRowMatched
is true, it will cause error.
// returns two bool slices, `selected` indicates whether a row passed the | ||
// filters, `isNull` indicates whether the result of the filter is null. | ||
// Filters is executed vectorized. | ||
func VectorizedFilterConsiderNull(ctx sessionctx.Context, filters []Expression, iterator *chunk.Iterator4Chunk, selected []bool, isNil []bool) ([]bool, []bool, error) { |
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.
- s/isNil/isNull/
- Can we refactor
VectorizedFilter()
to callVectorizedFilterConsiderNull()
?
// tryToMatchOuters, the result is built by multiple outer rows and one inner | ||
// row. The returned outerRowStatusFlag slice value indicates the status of | ||
// each outer row (matched/unmatched/hasNull). | ||
func (j *baseJoiner) filterAndCheckOuterRowStatus(input, output *chunk.Chunk, innerColsLen int, outerRowStatus []outerRowStatusFlag) (_ []outerRowStatusFlag, _ error) { |
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.
can we refactor it to call j.Filter()
then update outerRowStatus
?
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.
The code already did this?
} | ||
|
||
outer, numToAppend, outerBatchSize := outers.Current(), chk.RequiredRows()-chk.NumRows(), 0 | ||
for ; outer != outers.End() && numToAppend > 0; outer, numToAppend, outerBatchSize = outers.Next(), numToAppend-1, outerBatchSize+1 { |
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.
Don't need to calculate outerBatchSize
in every loop. We can calculate it when the loop is finished:
outer, numToAppend := outers.Current(), chk.RequiredRows()-chk.NumRows()
for ; outer != outers.End() && numToAppend > 0; outer, numToAppend = outers.Next(), numToAppend-1 {
j.makeJoinRowToChunk(chkForJoin, outer, inner)
}
outerBatchSize := chk.RequiredRows() - chk.NumRows() - numToAppend
// do something
BTW, the for loop looks a little complicated, we can simplify it to:
for outer != outers.End() && numToAppend > 0 {
j.makeJoinRowToChunk(chkForJoin, outer, inner)
outer = outers.Next()
numToAppend = numToAppend - 1
}
/run-all-tests |
@zz-jason This commit is merged... |
What problem does this PR solve?
Add a tryToMatchOuters interface in joiner which joins a batch out outer rows and one inner row every time.
What is changed and how it works?
Check List
Tests
Exist tests.
More test case needs to be added.
Code changes
Side effects
N/A
Related changes
N/A
Release note
N/A