Documentation
Overview ¶
Package slicefunc provides types and code to call user-defined functions with Bigslice.
Index ¶
Constants ¶
Variables ¶
Functions ¶
Types ¶
type Func ¶
type Func struct { // In and Out represent the slicetype of the function's input and output, // respectively. In, Out slicetype.Type // IsVariadic is whether the function's final parameter is variadic. If it // is, In.Out(In.NumOut()-1) returns the parameter's implicit actual slice // type. For example, if this represents func(x int, y ...string): // // fn.In.NumOut() == 2 // fn.In.Out(0) is the reflect.Type for "int" // fn.In.Out(1) is the reflect.Type for "[]string" // fn.IsVariadic == true IsVariadic bool // contains filtered or unexported fields }
Func represents a user-defined function within Bigslice. Currently it's a simple shim that's used to determine whether a context should be supplied to the callee.
TODO(marius): Evolve this abstraction over time to avoid the use of reflection. For example, we can generate (via a template) code for invocations on common types. Having this abstraction in place makes this possible to do without changing any of the callers.
TODO(marius): Another possibility is to exploit the fact that we have already typechecked the data pipeline within Bigslice, and thus can avoid the per-call typechecking overhead that is incurred by reflection. For example, we could allow Funcs to mint a new re-usable call frame that we can write values directly into. This might get us most of the former but with more generality and arguably less complexity. We could even pre-generate call frames for each row in a frame, since that is re-used also.
TODO(marius): consider using this package to allow user-defined funcs to return an error in the last argument.
var Nil Func
Nil is a nil Func.
func Of ¶
Of creates a Func from the provided function, along with a bool indicating whether fn is a valid function. If it is not, the returned Func is invalid.