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

colexecjoin: optimize merge/cross joins #68921

Merged
merged 4 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2,505 changes: 1,213 additions & 1,292 deletions pkg/sql/colexec/colexecjoin/crossjoiner.eg.go

Large diffs are not rendered by default.

406 changes: 209 additions & 197 deletions pkg/sql/colexec/colexecjoin/crossjoiner.go

Large diffs are not rendered by default.

339 changes: 132 additions & 207 deletions pkg/sql/colexec/colexecjoin/crossjoiner_tmpl.go

Large diffs are not rendered by default.

52 changes: 24 additions & 28 deletions pkg/sql/colexec/colexecjoin/mergejoinbase.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions pkg/sql/colexec/colexecjoin/mergejoinbase_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,13 @@ func _ASSIGN_EQ(_, _, _, _, _, _ interface{}) int {
// */}}

// isBufferedGroupFinished checks to see whether or not the buffered group
// corresponding to input continues in batch.
// corresponding to the first tuple continues in batch.
func (o *mergeJoinBase) isBufferedGroupFinished(
input *mergeJoinInput, batch coldata.Batch, rowIdx int,
input *mergeJoinInput, firstTuple []coldata.Vec, batch coldata.Batch, rowIdx int,
) bool {
if batch.Length() == 0 {
return true
}
bufferedGroup := o.bufferedGroup.left
if input == &o.right {
bufferedGroup = o.bufferedGroup.right
}
tupleToLookAtIdx := rowIdx
sel := batch.Selection()
if sel != nil {
Expand All @@ -89,7 +85,7 @@ func (o *mergeJoinBase) isBufferedGroupFinished(
// right side being an input) this check will always return false since
// nulls couldn't be buffered up though.
// TODO(yuzefovich): consider templating this.
bufferedNull := bufferedGroup.firstTuple[colIdx].MaybeHasNulls() && bufferedGroup.firstTuple[colIdx].Nulls().NullAt(0)
bufferedNull := firstTuple[colIdx].MaybeHasNulls() && firstTuple[colIdx].Nulls().NullAt(0)
incomingNull := batch.ColVec(int(colIdx)).MaybeHasNulls() && batch.ColVec(int(colIdx)).Nulls().NullAt(tupleToLookAtIdx)
if o.joinType.IsSetOpJoin() {
if bufferedNull && incomingNull {
Expand All @@ -100,7 +96,7 @@ func (o *mergeJoinBase) isBufferedGroupFinished(
if bufferedNull || incomingNull {
return true
}
bufferedCol := bufferedGroup.firstTuple[colIdx].TemplateType()
bufferedCol := firstTuple[colIdx].TemplateType()
prevVal := bufferedCol.Get(0)
col := batch.ColVec(int(colIdx)).TemplateType()
curVal := col.Get(tupleToLookAtIdx)
Expand Down
Loading