Skip to content
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: vectorize the merge join executor by vecGroupChecker #14458

Merged
merged 5 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions executor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ func (e *vecGroupChecker) splitIntoGroups(chk *chunk.Chunk) (isFirstGroupSameAsP
e.nextGroupID = 0
if len(e.GroupByItems) == 0 {
e.groupOffset = append(e.groupOffset, numRows)
e.groupCount = 1
return true, nil
}

Expand Down
17 changes: 8 additions & 9 deletions executor/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1280,17 +1280,16 @@ func prepare4MergeJoin(tc *mergeJoinTestCase, leftExec, rightExec *mockDataSourc
isOuterJoin: false,
}

e.outerIdx = 0

e.innerTable = &mergeJoinInnerTable{
reader: rightExec,
joinKeys: innerJoinKeys,
e.innerTable = &mergeJoinTable{
isInner: true,
childIndex: 1,
joinKeys: innerJoinKeys,
}

e.outerTable = &mergeJoinOuterTable{
reader: leftExec,
filter: nil,
keys: outerJoinKeys,
e.outerTable = &mergeJoinTable{
childIndex: 0,
filters: nil,
joinKeys: outerJoinKeys,
}

return e
Expand Down
38 changes: 15 additions & 23 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,37 +985,29 @@ func (b *executorBuilder) buildMergeJoin(v *plannercore.PhysicalMergeJoin) Execu
desc: v.Desc,
}

leftKeys := v.LeftJoinKeys
rightKeys := v.RightJoinKeys

e.outerIdx = 0
innerFilter := v.RightConditions

e.innerTable = &mergeJoinInnerTable{
reader: rightExec,
joinKeys: rightKeys,
leftTable := &mergeJoinTable{
childIndex: 0,
joinKeys: v.LeftJoinKeys,
filters: v.LeftConditions,
}

e.outerTable = &mergeJoinOuterTable{
reader: leftExec,
filter: v.LeftConditions,
keys: leftKeys,
rightTable := &mergeJoinTable{
childIndex: 1,
joinKeys: v.RightJoinKeys,
filters: v.RightConditions,
}

if v.JoinType == plannercore.RightOuterJoin {
e.outerIdx = 1
e.outerTable.reader = rightExec
e.outerTable.filter = v.RightConditions
e.outerTable.keys = rightKeys

innerFilter = v.LeftConditions
e.innerTable.reader = leftExec
e.innerTable.joinKeys = leftKeys
e.innerTable = leftTable
e.outerTable = rightTable
} else {
e.innerTable = rightTable
e.outerTable = leftTable
}
e.innerTable.isInner = true

// optimizer should guarantee that filters on inner table are pushed down
// to tikv or extracted to a Selection.
if len(innerFilter) != 0 {
if len(e.innerTable.filters) != 0 {
b.err = errors.Annotate(ErrBuildExecutor, "merge join's inner filter should be empty.")
return nil
}
Expand Down
Loading