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

exec: Bug fixes in vectorized casts #40495

Merged
merged 1 commit into from
Sep 5, 2019
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
33 changes: 25 additions & 8 deletions pkg/sql/exec/cast_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ func _ASSIGN_CAST(to, from interface{}) {
execerror.VectorizedInternalPanic("")
}

// This will be replaced with execgen.GET.
func _FROM_TYPE_GET(to, from interface{}) interface{} {
execerror.VectorizedInternalPanic("")
}

// This will be replaced with execgen.SET.
func _TO_TYPE_SET(to, from interface{}) {
execerror.VectorizedInternalPanic("")
}

// This will be replaced with execgen.SLICE.
func _FROM_TYPE_SLICE(col, i, j interface{}) interface{} {
execerror.VectorizedInternalPanic("")
}

// */}}

// Use execgen package to remove unused import warning.
Expand Down Expand Up @@ -127,39 +142,41 @@ func (c *castOp_FROMTYPE_TOTYPE) Next(ctx context.Context) coldata.Batch {
if vecNulls.NullAt(i) {
projNulls.SetNull(i)
} else {
v := execgen.GET(col, int(i))
v := _FROM_TYPE_GET(col, int(i))
var r _GOTYPE
_ASSIGN_CAST(r, v)
execgen.SET(projCol, int(i), r)
_TO_TYPE_SET(projCol, int(i), r)
}
}
} else {
col = _FROM_TYPE_SLICE(col, 0, int(n))
for execgen.RANGE(i, col) {
if vecNulls.NullAt(uint16(i)) {
projNulls.SetNull(uint16(i))
} else {
v := execgen.GET(col, i)
v := _FROM_TYPE_GET(col, int(i))
var r _GOTYPE
_ASSIGN_CAST(r, v)
execgen.SET(projCol, int(i), r)
_TO_TYPE_SET(projCol, int(i), r)
}
}
}
} else {
if sel := batch.Selection(); sel != nil {
sel = sel[:n]
for _, i := range sel {
v := execgen.GET(col, int(i))
v := _FROM_TYPE_GET(col, int(i))
var r _GOTYPE
_ASSIGN_CAST(r, v)
execgen.SET(projCol, int(i), r)
_TO_TYPE_SET(projCol, int(i), r)
}
} else {
col = _FROM_TYPE_SLICE(col, 0, int(n))
for execgen.RANGE(i, col) {
v := execgen.GET(col, i)
v := _FROM_TYPE_GET(col, int(i))
var r _GOTYPE
_ASSIGN_CAST(r, v)
execgen.SET(projCol, int(i), r)
_TO_TYPE_SET(projCol, int(i), r)
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/sql/exec/execgen/cmd/execgen/cast_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ func genCastOperators(wr io.Writer) error {
s = strings.Replace(s, "_TOTYPE", "{{.ToTyp}}", -1)
s = strings.Replace(s, "_GOTYPE", "{{.ToGoTyp}}", -1)

// replace _FROM_TYPE_SLICE's with execgen.SLICE's of the correct type.
s = strings.Replace(s, "_FROM_TYPE_SLICE", "execgen.SLICE", -1)
s = replaceManipulationFuncs(".FromTyp", s)

// replace the _FROM_TYPE_GET's with execgen.GET's of the correct type.
s = strings.Replace(s, "_FROM_TYPE_GET", "execgen.GET", -1)
s = replaceManipulationFuncs(".FromTyp", s)

// replace the _TO_TYPE_GET's with execgen.SET's of the correct type
s = strings.Replace(s, "_TO_TYPE_SET", "execgen.SET", -1)
s = replaceManipulationFuncs(".ToTyp", s)

isCastFuncSet := func(ov castOverload) bool {
return ov.AssignFunc != nil
}
Expand Down