-
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): add an optimized version of the shift transformation (#…
…4337) This optimizes shift to use arrow tables and the narrow transformation transport.
- Loading branch information
1 parent
d2a9887
commit 348928b
Showing
12 changed files
with
709 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
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.