incrutil

package
v0.0.0-...-bc49051 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeTypeVar                   = "var"
	NodeTypeTable                 = "table"
	NodeTypeObserver              = "observer"
	NodeTypeCutoffExpression      = "cutoff_expression"
	NodeTypeCutoffEpsilon         = "cutoff_epsilon"
	NodeTypeCutoffUnchanged       = "cutoff_unchanged"
	NodeTypeExpression            = "expression"
	NodeTypeFilterTableExpression = "filter_table_expression"
	NodeTypeAlways                = "always"

	NodeTypeFetchCSV  = "fetch_csv"
	NodeTypeFetchJSON = "fetch_json"

	NodeTypeTimeseriesChart = "timeseries_chart"
	NodeTypeScatterChart    = "scatter_chart"

	NodeTypeCurrentTimestamp = "current_timestamp"

	NodeTypeCast             = "cast"
	NodeTypeFirst            = "first"
	NodeTypeIndex            = "index"
	NodeTypeLast             = "last"
	NodeTypeLength           = "length"
	NodeTypeMax              = "max"
	NodeTypeMean             = "mean"
	NodeTypeMedian           = "median"
	NodeTypeMedianSorted     = "median_sorted"
	NodeTypeMerge            = "merge"
	NodeTypeMin              = "min"
	NodeTypePercentile       = "percentile"
	NodeTypePercentileSorted = "percentile_sorted"
	NodeTypeReverse          = "reverse"
	NodeTypeSort             = "sort"
	NodeTypeSum              = "sum"

	NodeTypeTableColumn = "table_column"
)
View Source
const (
	ValueTypeBool      = "bool"
	ValueTypeInt64     = "int64"
	ValueTypeFloat64   = "float64"
	ValueTypeString    = "string"
	ValueTypeTimestamp = "time.Time"
	ValueTypeDuration  = "time.Duration"
)
View Source
const TimeFormatRFC3339Esque = "2006-01-02T15:04:05.999999999"
View Source
const TimeFormatYearTime = "2006-01-02 15:04"

Variables

View Source
var ValueArrayTypes = iter.Apply(ValueScalarTypes, func(v string) string {
	return "[]" + v
})

ValueArrayTypes are the scalar types as arrays, basically.

ValueScalarTypes are the integral non-array types.

This list is used, for example, by `nodegen` to generate generic type parameters for functions. They need to be go types for this reason, but we can translate them to the abstracted api types separately.

View Source
var ValueTypeAny = "any"

ValueTypeAny is a special type that can be any value.

It is only used, really, for expressions.

View Source
var ValueTypeAnyArray = "[]any"

ValueTypeAnyArray is a special type that can be any value.

It is only used, really, for expressions.

View Source
var ValueTypeSVG = "types.SVG"

ValueTypeSVG is a special type that can hold an svg.

View Source
var ValueTypeTable = "*types.Table"

ValueTypeTable is a special type that can hold rows and columns of data.

ValueTypes are all the legal values types we can use as inputs or outputs for nodes.

ValueTypesFull are all the legal value types we can use as inputs and outputs for nodes including the table and svg types.

Functions

func APIValueTypeForGoType

func APIValueTypeForGoType(t string) string

APIValueTypeForGoType is the api type for a given go value type.

func ApplyNodeTableOps

func ApplyNodeTableOps(g *incr.Graph, n incr.INode, ops ...types.TableOp) error

ApplyNodeTableOps applies node table operations.

This is only valid for incr types of table.

func CastAny

func CastAny(input, output any) error

CastAny casts an input to an output as non-generic references.

func CastValue

func CastValue[Output any](input any) (output Output, err error)

CastValue casts a value as an output given an ambiguous input.

func GetNodeValue

func GetNodeValue(n incr.INode) any

GetNodeValue gets the raw value of a node.

func LabelOrID

func LabelOrID(n incr.INode) string

LabelOrID returns either the node's label or it's short id.

func LinkNodes

func LinkNodes(child incr.INode, inputs ...incr.INode) error

LinkNodes adds inputs to a given child, associating the two nodes in the graph.

func ParseTime

func ParseTime(input string) (output time.Time, err error)

ParseTime parses a timestamp from a string.

func SetNodeValueDuringDeserialization

func SetNodeValueDuringDeserialization(n incr.INode, value any) error

SetNodeValueDuringDeserialization sets the underlying value for the node but does _not_ mark the node as stale if it's a var!

func SetNodeValueOnline

func SetNodeValueOnline(n incr.INode, value any) error

SetNodeValueOnline calls set on a given node with the appropriate type.

If the node is a var node, it will be marked as stale.

func UnlinkNodes

func UnlinkNodes(child incr.INode, inputs ...incr.INode)

Unlink nodes removes the metadata association between two nodes but does _not_ remove node type specific input tracking.

func ValueTypeIsMath

func ValueTypeIsMath(typeName string) bool

ValueTypeIsMath returns if a given value type is operatable.

Types

type AlwaysIncr

type AlwaysIncr[A any] interface {
	incr.AlwaysIncr[A]
	ISetInput
	IRemoveInput
	IInputs
}

AlwaysIncr is an incremental that implements the always interface.

func Always

func Always[A any](scope incr.Scope) AlwaysIncr[A]

Always yields an incremental that is always stale.

The way to use this effectively is to place this node above a tree of nodes that should always be recomputed, but specifically you'll likely want to pair this with a cutoff _below_ the immediate child of the always node such that you don't just always recompute an entire subgraph.

type Cutoff2ContextFunc

type Cutoff2ContextFunc[A, B any] func(context.Context, A, B, B) (bool, error)

Cutoff2ContextFunc is a function that implements cutoff checking and takes a context.

type Cutoff2Func

type Cutoff2Func[A, B any] func(A, B, B) bool

Cutoff2Func is a function that implements cutoff checking.

type Cutoff2Incr

type Cutoff2Incr[A, B any] interface {
	incr.Incr[B]
	incr.IStabilize
	incr.ICutoff
	ISetInput
	IRemoveInput
	IInputs
	IRawValue
	ISetRawValue
	IRawFunction
	ISetRawFunction
}

CutoffIncr is an incremental node that implements the ICutoff interface.

func Cutoff2

func Cutoff2[A, B any](scope incr.Scope, fn Cutoff2Func[A, B]) Cutoff2Incr[A, B]

Cutoff returns a new wrapping cutoff incremental.

The goal of the cutoff incremental is to stop recomputation at a given node if the difference between the previous and latest values are not significant enough to warrant a full recomputation of the children of this node.

func Cutoff2Context

func Cutoff2Context[A, B any](scope incr.Scope, fn Cutoff2ContextFunc[A, B]) Cutoff2Incr[A, B]

CutoffContext returns a new wrapping cutoff incremental.

The goal of the cutoff incremental is to stop recomputation at a given node if the difference between the previous and latest values are not significant enough to warrant a full recomputation of the children of this node.

type CutoffIncr

type CutoffIncr[A any] interface {
	incr.Incr[A]
	incr.IStabilize
	incr.ICutoff
	IInputs
	ISetInput
	IRemoveInput
	IRawValue
	ISetRawValue
	IRawFunction
	ISetRawFunction
}

CutoffIncr is an incremental node that implements the ICutoff interface.

func Cutoff

func Cutoff[A any](scope incr.Scope, fn incr.CutoffFunc[A]) CutoffIncr[A]

Cutoff returns a new wrapping cutoff incremental.

The goal of the cutoff incremental is to stop recomputation at a given node if the difference between the previous and latest values are not significant enough to warrant a full recomputation of the children of this node.

func CutoffContext

func CutoffContext[A any](scope incr.Scope, fn incr.CutoffContextFunc[A]) CutoffIncr[A]

CutoffContext returns a new wrapping cutoff incremental.

The goal of the cutoff incremental is to stop recomputation at a given node if the difference between the previous and latest values are not significant enough to warrant a full recomputation of the children of this node.

type FuncIncr

type FuncIncr[Output any] interface {
	incr.AlwaysIncr[Output]
}

func Func

func Func[Output any](scope incr.Scope, fn Funcfn[Output]) FuncIncr[Output]

Func is a node that runs a function for every stabilization pass.

type Funcfn

type Funcfn[Output any] func(context.Context) (Output, error)

type IAddInput

type IAddInput interface {
	AddInput(incr.INode) error
}

IAddInput is an interface that allows nodes to add nodes without an associated name, e.g. for MapN.

type IInputs

type IInputs interface {
	Inputs() map[string]incr.INode
}

IInputs is an interface types can implement to get node inputs.

type IRawFunction

type IRawFunction interface {
	RawFunction() any
}

IRawFunction is an interface for getting the raw function.

type IRawValue

type IRawValue interface {
	RawValue() any
}

IRawValue is an interface for just the remove input function.

type IRemoveInput

type IRemoveInput interface {
	RemoveInput(string) error
}

IRemoveInput is an interface that allows nodes to remove an input by an associated name.

type IRemoveInputByID

type IRemoveInputByID interface {
	RemoveInputByID(incr.Identifier) error
}

IRemoveInputByID is an interface that allows nodes to remove an input by parent node id.

type IRemoveInputByNodeID

type IRemoveInputByNodeID interface {
	RemoveInputByNodeID(incr.Identifier)
}

IRemoveInputByID is an interface for just the remove input function.

type ISetInput

type ISetInput interface {
	SetInput(inputName string, inputNode incr.INode, isDeserialize bool) error
}

ISetInput is an interface for just the add untyped input function.

type ISetRawFunction

type ISetRawFunction interface {
	SetRawFunction(fn any) error
}

ISetRawFunction is an interface for setting the raw function.

type ISetRawValue

type ISetRawValue interface {
	SetRawValue(any) error
}

ISetRawValue is an interface for just the add untyped input function.

type ISetRawVarValue

type ISetRawVarValue interface {
	SetRawVarValue(any) error
}

ISetRawVarValue is an interface for just the add untyped input function.

type Inputs

type Inputs[A any] struct {
	// contains filtered or unexported fields
}

Inputs is a helper type to organize inputs to nodes for common functions like expressions.

func NewInputs

func NewInputs[A any](nodes ...incr.Incr[A]) (output *Inputs[A])

NewInputs returns an inputs collection for the given nodes.

func (Inputs[A]) ByIndex

func (i Inputs[A]) ByIndex(index int) (value A, ok bool)

ByIndex gets the input by index e.g. when it was added to the inputs list.

func (Inputs[A]) ByNodeLabel

func (i Inputs[A]) ByNodeLabel(nodeLabel string) (value A, ok bool)

ByNodeLabel returns the input by the label of the node it was sourced from.

func (Inputs[A]) Values

func (i Inputs[A]) Values() []A

Values returns the underlying array of values.

type Map2Func

type Map2Func[A, B, C any] func(context.Context, A, B) (C, error)

Map2Func is the function that the ApplyN incremental applies.

type Map2Incr

type Map2Incr[A, B, C any] interface {
	incr.Incr[C]
	ISetInput
	IRemoveInput
	IInputs
	IRawFunction
	ISetRawFunction
	IRawValue
	ISetRawValue
}

MapNIncr is a type of incremental that can add inputs over time.

func Map2

func Map2[A, B, C any](scope incr.Scope, fn Map2Func[A, B, C]) Map2Incr[A, B, C]

MapN applies a function to given list of input incrementals and returns a new incremental of the output type of that function.

type Map2NFunc

type Map2NFunc[A, B, C any] func(context.Context, A, *Inputs[B]) (C, error)

Map2NFunc is the function that the MapN incremental applies.

type Map2NIncr

type Map2NIncr[A, B, C any] interface {
	incr.Incr[C]
	IInputs
	ISetInput
	IRemoveInputByID
	IRawValue
	ISetRawValue
	IRawFunction
	ISetRawFunction
}

MapNIncr is a type of incremental that can add inputs over time.

func Map2N

func Map2N[A, B, C any](scope incr.Scope, fn Map2NFunc[A, B, C]) Map2NIncr[A, B, C]

Map2N applies a function to a known input and a variable list of input incrementals and returns a new incremental of the output type of that function.

type Map3Func

type Map3Func[A, B, C, D any] func(context.Context, A, B, C) (D, error)

Map3Func is the function that the ApplyN incremental applies.

type Map3Incr

type Map3Incr[A, B, C, D any] interface {
	incr.Incr[D]
	ISetInput
	IRemoveInput
	IInputs
	IRawFunction
	ISetRawFunction
	IRawValue
	ISetRawValue
}

MapNIncr is a type of incremental that can add inputs over time.

func Map3

func Map3[A, B, C, D any](scope incr.Scope, fn Map3Func[A, B, C, D]) Map3Incr[A, B, C, D]

MapN applies a function to given list of input incrementals and returns a new incremental of the output type of that function.

type MapFunc

type MapFunc[A, B any] func(context.Context, A) (B, error)

MapNFunc is the function that the ApplyN incremental applies.

type MapIncr

type MapIncr[A, B any] interface {
	incr.Incr[B]
	ISetInput
	IRemoveInput
	IInputs
	IRawValue
	ISetRawValue
	IRawFunction
	ISetRawFunction
	AddInput(incr.Incr[A])
}

MapNIncr is a type of incremental that can add inputs over time.

func Map

func Map[A, B any](scope incr.Scope, fn MapFunc[A, B]) MapIncr[A, B]

MapN applies a function to given list of input incrementals and returns a new incremental of the output type of that function.

type MapNFunc

type MapNFunc[A, B any] func(context.Context, *Inputs[A]) (B, error)

MapNFunc is the function that the MapN incremental applies.

type MapNIncr

type MapNIncr[A, B any] interface {
	incr.Incr[B]
	IInputs
	IAddInput
	IRemoveInputByID
	IRawValue
	ISetRawValue
	IRawFunction
	ISetRawFunction
}

MapNIncr is a type of incremental that can add inputs over time.

func MapN

func MapN[A, B any](scope incr.Scope, fn MapNFunc[A, B], inputs ...incr.Incr[A]) MapNIncr[A, B]

MapN applies a function to given list of input incrementals and returns a new incremental of the output type of that function.

type ObserveIncr

type ObserveIncr[A any] interface {
	incr.Incr[A]
	fmt.Stringer
	ISetInput
	IRemoveInput
	IInputs
	IRawValue
	ISetRawValue
	incr.IObserver
}

ObserveIncr is a type that implements the observer.

func Observe

func Observe[A any](graph *incr.Graph) ObserveIncr[A]

Observe returns a observe increment.

type VarIncr

type VarIncr[A any] interface {
	incr.VarIncr[A]
	IRawValue
	ISetRawValue
}

func Var

func Var[A any](scope incr.Scope, value A) VarIncr[A]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL