-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stdlib): create a version of map that is columnar
The columnar version of map will run map over an entire table chunk rather than running it and then appending per row. This version of map should be more efficient in the normal cases and be more amenable to vectorized functions. Related to #4186.
- Loading branch information
1 parent
ed2e64a
commit a99745c
Showing
9 changed files
with
520 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// Generated by tmpl | ||
// https://github.com/benbjohnson/tmpl | ||
// | ||
// DO NOT EDIT! | ||
// Source: map2.gen.go.tmpl | ||
|
||
package universe | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/influxdata/flux/array" | ||
) | ||
|
||
func (m *mapTransformation2) isConstant(arr array.Interface) bool { | ||
switch arr := arr.(type) { | ||
case *array.Int: | ||
return m.isIntConstant(arr) | ||
case *array.Uint: | ||
return m.isUintConstant(arr) | ||
case *array.Float: | ||
return m.isFloatConstant(arr) | ||
case *array.String: | ||
return m.isStringConstant(arr) | ||
case *array.Boolean: | ||
return m.isBooleanConstant(arr) | ||
|
||
default: | ||
panic(fmt.Errorf("unsupported array datat ype: %s", arr.DataType())) | ||
} | ||
} | ||
|
||
func (m *mapTransformation2) isIntConstant(arr *array.Int) bool { | ||
// If all values are null, then that is still constant. | ||
if arr.NullN() == arr.Len() { | ||
return true | ||
} else if arr.NullN() > 0 { | ||
// At least one value is null, but not all so | ||
// not constant by definition. | ||
return false | ||
} | ||
|
||
// All values are non-null so check if they are all the same. | ||
v := arr.Value(0) | ||
for i, n := 1, arr.Len(); i < n; i++ { | ||
if arr.Value(i) != v { | ||
return false | ||
} | ||
} | ||
return true | ||
|
||
} | ||
|
||
func (m *mapTransformation2) isUintConstant(arr *array.Uint) bool { | ||
// If all values are null, then that is still constant. | ||
if arr.NullN() == arr.Len() { | ||
return true | ||
} else if arr.NullN() > 0 { | ||
// At least one value is null, but not all so | ||
// not constant by definition. | ||
return false | ||
} | ||
|
||
// All values are non-null so check if they are all the same. | ||
v := arr.Value(0) | ||
for i, n := 1, arr.Len(); i < n; i++ { | ||
if arr.Value(i) != v { | ||
return false | ||
} | ||
} | ||
return true | ||
|
||
} | ||
|
||
func (m *mapTransformation2) isFloatConstant(arr *array.Float) bool { | ||
// If all values are null, then that is still constant. | ||
if arr.NullN() == arr.Len() { | ||
return true | ||
} else if arr.NullN() > 0 { | ||
// At least one value is null, but not all so | ||
// not constant by definition. | ||
return false | ||
} | ||
|
||
// All values are non-null so check if they are all the same. | ||
v := arr.Value(0) | ||
for i, n := 1, arr.Len(); i < n; i++ { | ||
if arr.Value(i) != v { | ||
return false | ||
} | ||
} | ||
return true | ||
|
||
} | ||
|
||
func (m *mapTransformation2) isStringConstant(arr *array.String) bool { | ||
// If all values are null, then that is still constant. | ||
if arr.NullN() == arr.Len() { | ||
return true | ||
} else if arr.NullN() > 0 { | ||
// At least one value is null, but not all so | ||
// not constant by definition. | ||
return false | ||
} | ||
|
||
return arr.IsConstant() | ||
|
||
} | ||
|
||
func (m *mapTransformation2) isBooleanConstant(arr *array.Boolean) bool { | ||
// If all values are null, then that is still constant. | ||
if arr.NullN() == arr.Len() { | ||
return true | ||
} else if arr.NullN() > 0 { | ||
// At least one value is null, but not all so | ||
// not constant by definition. | ||
return false | ||
} | ||
|
||
// All values are non-null so check if they are all the same. | ||
v := arr.Value(0) | ||
for i, n := 1, arr.Len(); i < n; i++ { | ||
if arr.Value(i) != v { | ||
return false | ||
} | ||
} | ||
return true | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package universe | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/influxdata/flux/array" | ||
) | ||
|
||
func (m *mapTransformation2) isConstant(arr array.Interface) bool { | ||
switch arr := arr.(type) { | ||
{{range .}}case *array.{{.Name}}: | ||
return m.is{{.Name}}Constant(arr) | ||
{{end}} | ||
default: | ||
panic(fmt.Errorf("unsupported array datat ype: %s", arr.DataType())) | ||
} | ||
} | ||
|
||
{{range .}} | ||
func (m *mapTransformation2) is{{.Name}}Constant(arr *array.{{.Name}}) bool { | ||
// If all values are null, then that is still constant. | ||
if arr.NullN() == arr.Len() { | ||
return true | ||
} else if arr.NullN() > 0 { | ||
// At least one value is null, but not all so | ||
// not constant by definition. | ||
return false | ||
} | ||
|
||
{{if eq .Name "String"}} | ||
return arr.IsConstant() | ||
{{else}} | ||
// All values are non-null so check if they are all the same. | ||
v := arr.Value(0) | ||
for i, n := 1, arr.Len(); i < n; i++ { | ||
if arr.Value(i) != v { | ||
return false | ||
} | ||
} | ||
return true | ||
{{end}} | ||
} | ||
{{end}} |
Oops, something went wrong.