Skip to content

Commit

Permalink
Merge #40595
Browse files Browse the repository at this point in the history
40595: exec: don't template asc vs desc in mj r=jordanlewis a=jordanlewis

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
  • Loading branch information
craig[bot] and jordanlewis committed Sep 9, 2019
2 parents 55294cf + 8a1878a commit 3256e02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
5 changes: 2 additions & 3 deletions pkg/sql/exec/execgen/cmd/execgen/mergejoiner_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func genMergeJoinOps(wr io.Writer, jti joinTypeInfo) error {
s = strings.Replace(s, "_HAS_NULLS", "$.HasNulls", -1)
s = strings.Replace(s, "_HAS_SELECTION", "$.HasSelection", -1)
s = strings.Replace(s, "_SEL_PERMUTATION", "$.SelPermutation", -1)
s = strings.Replace(s, "_ASC_DIRECTION", "$.AscDirection", -1)

leftUnmatchedGroupSwitch := makeFunctionRegex("_LEFT_UNMATCHED_GROUP_SWITCH", 1)
s = leftUnmatchedGroupSwitch.ReplaceAllString(s, `{{template "leftUnmatchedGroupSwitch" buildDict "Global" $ "JoinType" $1}}`)
Expand All @@ -111,8 +110,8 @@ func genMergeJoinOps(wr io.Writer, jti joinTypeInfo) error {
processNotLastGroupInColumnSwitch := makeFunctionRegex("_PROCESS_NOT_LAST_GROUP_IN_COLUMN_SWITCH", 1)
s = processNotLastGroupInColumnSwitch.ReplaceAllString(s, `{{template "processNotLastGroupInColumnSwitch" buildDict "Global" $ "JoinType" $1}}`)

probeSwitch := makeFunctionRegex("_PROBE_SWITCH", 6)
s = probeSwitch.ReplaceAllString(s, `{{template "probeSwitch" buildDict "Global" $ "JoinType" $1 "FilterInfo" $2 "SelPermutation" $3 "lHasNulls" $4 "rHasNulls" $5 "AscDirection" $6}}`)
probeSwitch := makeFunctionRegex("_PROBE_SWITCH", 5)
s = probeSwitch.ReplaceAllString(s, `{{template "probeSwitch" buildDict "Global" $ "JoinType" $1 "FilterInfo" $2 "SelPermutation" $3 "lHasNulls" $4 "rHasNulls" $5}}`)

sourceFinishedSwitch := makeFunctionRegex("_SOURCE_FINISHED_SWITCH", 1)
s = sourceFinishedSwitch.ReplaceAllString(s, `{{template "sourceFinishedSwitch" buildDict "Global" $ "JoinType" $1}}`)
Expand Down
31 changes: 6 additions & 25 deletions pkg/sql/exec/mergejoiner_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func _PROBE_SWITCH(
_SEL_PERMUTATION selPermutation,
_L_HAS_NULLS bool,
_R_HAS_NULLS bool,
_ASC_DIRECTION bool,
) { // */}}
// {{define "probeSwitch"}}
// {{ $sel := $.SelPermutation }}
Expand Down Expand Up @@ -270,11 +269,9 @@ func _PROBE_SWITCH(
}
} else { // mismatch
var incrementLeft bool
// {{ if _ASC_DIRECTION }}
_ASSIGN_LT("incrementLeft", "lVal", "rVal")
// {{ else }}
_ASSIGN_GT("incrementLeft", "lVal", "rVal")
// {{ end }}
// Switch the direction of increment if we're sorted descendingly.
incrementLeft = incrementLeft == (o.left.directions[eqColIdx] == distsqlpb.Ordering_Column_ASC)
if incrementLeft {
curLIdx++
// {{ if _L_HAS_NULLS }}
Expand Down Expand Up @@ -588,31 +585,15 @@ EqLoop:
colType := o.left.sourceTypes[int(o.left.eqCols[eqColIdx])]
if lVec.MaybeHasNulls() {
if rVec.MaybeHasNulls() {
if o.left.directions[eqColIdx] == distsqlpb.Ordering_Column_ASC {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, true, true, true)
} else {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, true, true, false)
}
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, true, true)
} else {
if o.left.directions[eqColIdx] == distsqlpb.Ordering_Column_ASC {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, true, false, true)
} else {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, true, false, false)
}
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, true, false)
}
} else {
if rVec.MaybeHasNulls() {
if o.left.directions[eqColIdx] == distsqlpb.Ordering_Column_ASC {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, false, true, true)
} else {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, false, true, false)
}
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, false, true)
} else {
if o.left.directions[eqColIdx] == distsqlpb.Ordering_Column_ASC {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, false, false, true)
} else {
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, false, false, false)
}
_PROBE_SWITCH(_JOIN_TYPE, _FILTER_INFO, _SEL_ARG, false, false)
}
}
// Look at the groups associated with the next equality column by moving
Expand Down

0 comments on commit 3256e02

Please sign in to comment.