bigslice: github.com/grailbio/bigslice/slicefunc Index | Files

package slicefunc

import "github.com/grailbio/bigslice/slicefunc"

Package slicefunc provides types and code to call user-defined functions with Bigslice.

Index

Package Files

func.go

type Func Uses

type Func struct {
    // In and Out represent the slicetype of the function's input and output,
    // respectively.
    In, Out slicetype.Type
    // 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 Uses

func Of(fn interface{}) Func

Of creates a Func from the provided function. Of panics if fn is not a func.

func (Func) Call Uses

func (f Func) Call(ctx context.Context, args []reflect.Value) []reflect.Value

Call invokes the function with the provided arguments, and returns the reflected return values.

TODO(marius): using reflect.Value here is not ideal for performance, but there may be more holistic approaches (see above) since we're (almost) always invoking functions from frames.

func (Func) IsNil Uses

func (f Func) IsNil() bool

IsNil returns whether the Func f is nil.

Package slicefunc imports 4 packages (graph) and is imported by 3 packages. Updated 2019-11-19. Refresh now. Tools for package owners.