ops

package
v0.0.0-...-715bb7b Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MaybeOp

type MaybeOp[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Provides functionality similar to the Maybe monad in Haskell. This is used to represent the result of an operation that can either be an error or a valid operation.

func ErrorOp

func ErrorOp[S packer.Number, T packer.Number](err error) *MaybeOp[S, T]

Create a new MaybeOp that represents an error.

func JustOp

func JustOp[S packer.Number, T packer.Number](op Op[S, T]) *MaybeOp[S, T]

Create a new MaybeOp that represents a valid operation.

func NewOpAdd

func NewOpAdd[S packer.Number, T packer.Number]() *MaybeOp[S, T]

Create a new OpAdd operator

func NewOpMax

func NewOpMax[T packer.Number](windowSize int) *MaybeOp[T, T]

Create a new OpMin operator with the specified windowSize.

func NewOpMin

func NewOpMin[T packer.Number](windowSize int) *MaybeOp[T, T]

Create a new OpMin operator with the specified windowSize.

func NewOpMul

func NewOpMul[S packer.Number, T packer.Number]() *MaybeOp[S, T]

Create a new OpMul operator

func NewOpMulAdd

func NewOpMulAdd[S packer.Number, T packer.Number](c T) *MaybeOp[S, T]

Create a new OpMulAdd operation with the specified constant C that can be applied on two time series A and B to generate a new time series which is the equavalent of C * A + B

func NewOpMulAddT

func NewOpMulAddT[T packer.Number](c T) *MaybeOp[T, T]

func NewOpPct

func NewOpPct[T packer.Number](windowSize int, percentile float64) *MaybeOp[T, T]

Create an new OpPct operator that has the specified windowSize and percentile

func NewOpSum

func NewOpSum[T packer.Number](initialValue T, windowSize int) *MaybeOp[T, T]

Create a new OpSum operator with the specified initiatl size and windowSize.

func (*MaybeOp[S, T]) Apply

func (op *MaybeOp[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the operation on the specified transformable and return a new operator that can either represent the resulting values of this operation or be further curried.

func (*MaybeOp[S, T]) Error

func (op *MaybeOp[S, T]) Error() error

Return the error if the operation failed, otherwise returns nil

func (*MaybeOp[S, T]) Op

func (op *MaybeOp[S, T]) Op() Op[S, T]

Return the underlying operator

func (*MaybeOp[S, T]) Values

func (op *MaybeOp[S, T]) Values() *TxIdentity[T, T]

Return the final values produced by the operator, otherwise returns nil

type Op

type Op[S packer.Number, T packer.Number] interface {

	// Applies this frame operator on the specified args and returns an
	// operator that can either represent the retulting values of this
	// operation or be curried further.
	Apply(args Transformable[S, T]) *MaybeOp[S, T]

	// Return the final values produced by the operator, otherwise returns nil
	Values() *TxIdentity[T, T]
}

Defines an interface for functional frame operations on vector valued transformable data.

type OpAdd

type OpAdd[S packer.Number, T packer.Number] struct {
}

Represents an add operation that can be applied on two time series. OpAdd invokation takes one time series as an input and return an instance of OpAdd1 which can be curried further with another time series to generate final sum.

func (*OpAdd[S, T]) Apply

func (op *OpAdd[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpAdd operator on the specified args and return an operator that can be curreried further.

func (*OpAdd[S, T]) Error

func (op *OpAdd[S, T]) Error() error

Returns nil error.

func (*OpAdd[S, T]) Values

func (op *OpAdd[S, T]) Values() *TxIdentity[T, T]

Returns a nil TxIdentity. Add operation require two time series. OpAdd Apply() results in an operator which needs to be further applied on another time series before producing results.

type OpAdd1

type OpAdd1[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Represents an add operation that can be applied on two time series. OpAdd1 is an internal representation of OpAdd which contains the first time series and can take the second operand to generate the final sum.

func (*OpAdd1[S, T]) Apply

func (op1 *OpAdd1[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpAdd1 operator on the specified args and returns the final result (sum of two series) as an operator.

func (*OpAdd1[S, T]) Error

func (op *OpAdd1[S, T]) Error() error

Returns nil error.

func (*OpAdd1[S, T]) Values

func (op *OpAdd1[S, T]) Values() *TxIdentity[T, T]

Returns a nil TxIdentity. Add operation require two time series. OpAdd1 is a curried operator which needs to be further applied on another time series before producing results.

type OpMax

type OpMax[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Return an operation that return the maximum value of a time series over a specified window size.

func (*OpMax[S, T]) Apply

func (op *OpMax[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpMin operator on the specified args and return an operator that contains the minimum value of the values over the specified windowSize.

func (*OpMax[S, T]) Error

func (op *OpMax[S, T]) Error() error

Returns nil error.

func (*OpMax[S, T]) Values

func (op *OpMax[S, T]) Values() *TxIdentity[T, T]

Returns a nil TxIdentity. Min operation is the result of the Apply function. The result is returned as an operator from the Apply invocation.

type OpMin

type OpMin[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Return an operation that return the minimum value of a time series over a specified window size.

func (*OpMin[S, T]) Apply

func (op *OpMin[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpMin operator on the specified args and return an operator that contains the minimum value of the values over the specified windowSize.

func (*OpMin[S, T]) Error

func (op *OpMin[S, T]) Error() error

Returns nil error.

func (*OpMin[S, T]) Values

func (op *OpMin[S, T]) Values() *TxIdentity[T, T]

Returns a nil TxIdentity. Min operation is the result of the Apply function. The result is returned as an operator from the Apply invocation.

type OpMul

type OpMul[S packer.Number, T packer.Number] struct {
}

Represents a multiply operation that can be applied on two time series. OpMul invokation takes one time series as an input and return an instance of OpMul1 which can be curried further with another time series to generate final product.

func (*OpMul[S, T]) Apply

func (op *OpMul[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpMul operator on the specified args and return an operator that can be curreried further.

func (*OpMul[S, T]) Error

func (op *OpMul[S, T]) Error() error

Returns nil error.

func (*OpMul[S, T]) Values

func (op *OpMul[S, T]) Values() *TxIdentity[T, T]

Returns a nil TxIdentity. Mul operation require two time series. OpMula Apply() results in an operator which needs to be further applied on anothera time series before producing results.

type OpMul1

type OpMul1[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Represents a multiply operation that can be applied on two time series. OpMul1 is an internal representation of OpAdd which contains the first time series and can take the second operand to generate the final product.

func (*OpMul1[S, T]) Apply

func (op1 *OpMul1[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpMul1 operator on the specified args and returns the final result (product of the two series) as an operator.

func (*OpMul1[S, T]) Error

func (op *OpMul1[S, T]) Error() error

Returns nil error.

func (*OpMul1[S, T]) Values

func (op *OpMul1[S, T]) Values() *TxIdentity[T, T]

Returns a nil TxIdentity. Mul operation require two time series. OpMul a curried operator which needs to be further applied on another time series before producing results.

type OpMulAdd

type OpMulAdd[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

func (*OpMulAdd[S, T]) Apply

func (op *OpMulAdd[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the operation on the specified values and return true if the value has been modified inplace. Otherwise, return false.

func (*OpMulAdd[S, T]) Error

func (op *OpMulAdd[S, T]) Error() error

func (*OpMulAdd[S, T]) Values

func (op *OpMulAdd[S, T]) Values() *TxIdentity[T, T]

type OpMulAdd1

type OpMulAdd1[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

func (*OpMulAdd1[S, T]) Apply

func (op1 *OpMulAdd1[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

func (*OpMulAdd1[S, T]) Error

func (op *OpMulAdd1[S, T]) Error() error

func (*OpMulAdd1[S, T]) Values

func (op *OpMulAdd1[S, T]) Values() *TxIdentity[T, T]

type OpPct

type OpPct[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Represents a percentile operation that can be applied on a transformable array. The percentile is computed over a window of values.

func (*OpPct[S, T]) Apply

func (op *OpPct[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpPct operator on the specified args and return an operator that contains the percentiles computed over the specified windowSize.

func (*OpPct[S, T]) Error

func (op *OpPct[S, T]) Error() error

Returns nil error.

func (*OpPct[S, T]) Values

func (op *OpPct[S, T]) Values() *TxIdentity[T, T]

Return a nil TxIdentity. Pct operation require a time series. OpPct Apply() can be called to get the result of the operation.

type OpResult

type OpResult[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

func (*OpResult[S, T]) Apply

func (result *OpResult[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

func (*OpResult[S, T]) Error

func (result *OpResult[S, T]) Error() error

func (*OpResult[S, T]) Values

func (result *OpResult[S, T]) Values() *TxIdentity[T, T]

type OpSum

type OpSum[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Represents an operation that can be applied on a time series to generate windowed sum of the values.

func (*OpSum[S, T]) Apply

func (op *OpSum[S, T]) Apply(args Transformable[S, T]) *MaybeOp[S, T]

Apply the OpSum operator on the specified args and return an operator that contains the sum of the values over the specified windowSize.

func (*OpSum[S, T]) Error

func (op *OpSum[S, T]) Error() error

Returns a nil error.

func (*OpSum[S, T]) Values

func (op *OpSum[S, T]) Values() *TxIdentity[T, T]

Returns a nil TxIdentity. Sum operation is the result of the Apply function. The result is returned as an operator from the Apply invocation.

type Transformable

type Transformable[S packer.Number, T packer.Number] interface {

	// Tranform the values of the underlying transformable array and return the
	// value at the specified index.
	ValueAt(idx int) T

	// Return the time at the specified index.
	TimeAt(idx int) uint64

	// Return true if the underlying transformable array is empty.
	IsEmpty() bool

	// Return the length of the underlying transformable array.
	Length() int
}

Defines an interface for representing transformable data.

func NewTxNegate

func NewTxNegate[T packer.Number](values []T) Transformable[T, T]

type TxConst

type TxConst[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

func NewTxConst

func NewTxConst[T packer.Number](c T, t uint64, size int) *TxConst[T, T]

func (*TxConst[S, T]) IsEmpty

func (tx *TxConst[S, T]) IsEmpty() bool

func (*TxConst[S, T]) Length

func (tx *TxConst[S, T]) Length() int

func (*TxConst[S, T]) TimeAt

func (tx *TxConst[S, T]) TimeAt(idx int) uint64

func (*TxConst[S, T]) ValueAt

func (tx *TxConst[S, T]) ValueAt(idx int) T

type TxIdentity

type TxIdentity[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

Defines a struct for representing an identity transformation of an array of values in type T.

func NewTxIdentity

func NewTxIdentity[T packer.Number](values []T) *TxIdentity[T, T]

Create a new TxIdentity struct with the specified values.

func NewTxIdentityWithTime

func NewTxIdentityWithTime[T packer.Number](values []T, time []uint64) *TxIdentity[T, T]

Create a new TxIdentity struct with the specified values and time.

func (*TxIdentity[S, T]) IsEmpty

func (tx *TxIdentity[S, T]) IsEmpty() bool

Return true if the underlying transformable array is empty.

func (*TxIdentity[S, T]) Length

func (tx *TxIdentity[S, T]) Length() int

Return the length of the underlying transformable array.

func (*TxIdentity[S, T]) TimeAt

func (tx *TxIdentity[S, T]) TimeAt(idx int) uint64

Return the time at the specified index.

func (*TxIdentity[S, T]) ValueAt

func (tx *TxIdentity[S, T]) ValueAt(idx int) T

Return the value at the specified index.

type TxNegate

type TxNegate[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

func (*TxNegate[S, T]) IsEmpty

func (tx *TxNegate[S, T]) IsEmpty() bool

func (*TxNegate[S, T]) Length

func (tx *TxNegate[S, T]) Length() int

func (*TxNegate[S, T]) TimeAt

func (tx *TxNegate[S, T]) TimeAt(idx int) uint64

func (*TxNegate[S, T]) ValueAt

func (tx *TxNegate[S, T]) ValueAt(idx int) T

type TxSeries

type TxSeries[S packer.Number, T packer.Number] struct {
	// contains filtered or unexported fields
}

func NewTxSeries

func NewTxSeries[T packer.Number](s *series.Series[T]) *TxSeries[T, T]

func (*TxSeries[S, T]) IsEmpty

func (tx *TxSeries[S, T]) IsEmpty() bool

func (*TxSeries[S, T]) Length

func (tx *TxSeries[S, T]) Length() int

func (*TxSeries[S, T]) Offset

func (tx *TxSeries[S, T]) Offset(offset int) *TxSeries[T, T]

func (*TxSeries[S, T]) TimeAt

func (tx *TxSeries[S, T]) TimeAt(idx int) uint64

func (*TxSeries[S, T]) ValueAt

func (tx *TxSeries[S, T]) ValueAt(idx int) T

Jump to

Keyboard shortcuts

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