Commit d834fb63 authored by Jordan Lewis's avatar Jordan Lewis

colexec: replace execgen.LEN with a type method

No need for //gcassert:inline here because we don't call Len() in any
loops.

Release note: None
parent b3697c03
......@@ -64,3 +64,27 @@ func (c Times) Get(idx int) time.Time { return c[idx] }
// Get returns the element at index idx of the vector.
func (c Durations) Get(idx int) duration.Duration { return c[idx] }
// Len returns the length of the vector.
func (c Bools) Len() int { return len(c) }
// Len returns the length of the vector.
func (c Int16s) Len() int { return len(c) }
// Len returns the length of the vector.
func (c Int32s) Len() int { return len(c) }
// Len returns the length of the vector.
func (c Int64s) Len() int { return len(c) }
// Len returns the length of the vector.
func (c Float64s) Len() int { return len(c) }
// Len returns the length of the vector.
func (c Decimals) Len() int { return len(c) }
// Len returns the length of the vector.
func (c Times) Len() int { return len(c) }
// Len returns the length of the vector.
func (c Durations) Len() int { return len(c) }
......@@ -64,11 +64,6 @@ var dataManipulationReplacementInfos = []dataManipulationReplacementInfo{
numArgs: 2,
replaceWith: "AppendVal",
},
{
templatePlaceholder: "execgen.LEN",
numArgs: 1,
replaceWith: "Len",
},
{
templatePlaceholder: "execgen.WINDOW",
numArgs: 3,
......
......@@ -606,17 +606,6 @@ func (b *argWidthOverloadBase) AppendVal(target, v string) string {
return fmt.Sprintf("%[1]s = append(%[1]s, %[2]s)", target, v)
}
// Len is a function that should only be used in templates.
// WARNING: combination of Slice and Len might not work correctly for Bytes
// type.
func (b *argWidthOverloadBase) Len(target string) string {
switch b.CanonicalTypeFamily {
case types.BytesFamily, typeconv.DatumVecCanonicalTypeFamily:
return fmt.Sprintf("%s.Len()", target)
}
return fmt.Sprintf("len(%s)", target)
}
// Window is a function that should only be used in templates.
func (b *argWidthOverloadBase) Window(target, start, end string) string {
switch b.CanonicalTypeFamily {
......@@ -644,7 +633,6 @@ var (
_ = awob.CopySlice
_ = awob.AppendSlice
_ = awob.AppendVal
_ = awob.Len
_ = awob.Window
)
......
This diff was suppressed by a .gitattributes entry.
......@@ -165,7 +165,7 @@ func _SET_PROJECTION(_HAS_NULLS bool) {
// incorrect value. In order to keep bounds check elimination for all other
// types, we simply omit this code snippet for Bytes. */}}
col1 = execgen.SLICE(col1, 0, n)
colLen := execgen.LEN(col1)
colLen := col1.Len()
_ = _RETURN_UNSAFEGET(projCol, colLen-1)
_ = _R_UNSAFEGET(col2, colLen-1)
// {{end}}
......
This diff was suppressed by a .gitattributes entry.
......@@ -135,7 +135,7 @@ func (s *sort_TYPE_DIR_HANDLES_NULLSOp) init(col coldata.Vec, order []int) {
}
func (s *sort_TYPE_DIR_HANDLES_NULLSOp) sort(ctx context.Context) {
n := execgen.LEN(s.sortCol)
n := s.sortCol.Len()
s.quickSort(ctx, 0, n, maxDepth(n))
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment