agg

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupNotMatch = 0
)

Variables

View Source
var (
	ErrInvalidLengthTypes        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTypes          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)
View Source
var IsWinOrderFun func(overloadID int64) bool

IsWinOrderFun check if the function is a window function.

View Source
var NewAgg func(overloadID int64, isDistinct bool, inputTypes []types.Type) (Agg[any], error)

NewAgg generate the aggregation related struct from the function overload id.

View Source
var NewAggWithConfig func(overloadID int64, isDistinct bool, inputTypes []types.Type, config any) (Agg[any], error)

NewAggWithConfig generate the aggregation related struct from the function overload id and deliver a config information.

Functions

func InitAggFramework added in v1.0.0

func InitAggFramework(
	newAgg func(overloadID int64, isDistinct bool, inputTypes []types.Type) (Agg[any], error),
	newAggWithConfig func(overloadID int64, isDistinct bool, inputTypes []types.Type, config any) (Agg[any], error),
	isWinOrderFun func(overloadID int64) bool)

Types

type Agg

type Agg[T any] interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	// OutputType return the result type of the agg.
	OutputType() types.Type

	// InputTypes return the input types of the agg.
	InputTypes() []types.Type

	// Free the agg.
	Free(pool *mpool.MPool)

	// Grows allocates n groups for the agg.
	Grows(n int, pool *mpool.MPool) error

	// Eval method calculates and returns the final result of the aggregate function.
	Eval(pool *mpool.MPool) (*vector.Vector, error)

	// Fill use the one row of vector to fill agg.
	Fill(groupIndex int64, rowIndex int64, vectors []*vector.Vector) error

	// BulkFill use whole vector to fill agg.
	BulkFill(groupIndex int64, vectors []*vector.Vector) error

	// BatchFill use part rows of the vector to fill agg.
	// the rows are start from offset and end at offset+len(groupStatus)
	// groupOfRows[i] is 1 means that the (i+offset)th row matched the first group and 0 means not matched.
	BatchFill(offset int64, groupStatus []uint8, groupOfRows []uint64, vectors []*vector.Vector) error

	// Merge will merge a couple of group between 2 aggregate function structures.
	// It merges the groupIndex1-group of agg1 and
	// groupIndex2-group of agg2
	Merge(agg2 Agg[any], groupIndex1 int64, groupIndex2 int64) error

	// BatchMerge merges multi groups of agg1 and agg2
	// groupIdxes[i] is 1 means that the (offset + i)th group of agg2 matched the first group and 0 means not matched.
	BatchMerge(agg2 Agg[any], offset int64, groupStatus []uint8, groupIdxes []uint64) error

	// GetOperatorId get types of aggregate's aggregate id.
	GetOperatorId() int64

	IsDistinct() bool

	Dup(m *mpool.MPool) Agg[any]

	// WildAggReAlloc reallocate for agg structure from memory pool.
	// todo: remove this method.
	WildAggReAlloc(m *mpool.MPool) error

	SetPartialResult(PartialResult any)
}

Agg interface which return type is T.

func NewUnaryAgg

func NewUnaryAgg[T1, T2 any](
	overloadID int64,
	aggPrivateStructure AggStruct,
	isCount bool, inputTypes,
	outputType types.Type,
	grows func(int),
	eval func([]T2) ([]T2, error),
	merge func(int64, int64, T2, T2, bool, bool, any) (T2, bool, error),
	fill func(int64, T1, T2, int64, bool, bool) (T2, bool, error)) Agg[*UnaryAgg[T1, T2]]

func NewUnaryDistAgg

func NewUnaryDistAgg[T1, T2 any](
	op int64,
	priv AggStruct,
	isCount bool,
	ityp, otyp types.Type,
	grows func(int),
	eval func([]T2) ([]T2, error),
	merge func(int64, int64, T2, T2, bool, bool, any) (T2, bool, error),
	fill func(int64, T1, T2, int64, bool, bool) (T2, bool, error)) Agg[*UnaryDistAgg[T1, T2]]

type AggStruct added in v0.6.0

type AggStruct interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	Dup() AggStruct
}

type Aggregate added in v0.6.0

type Aggregate struct {
	Op     int64
	Dist   bool
	E      *plan.Expr
	Config []byte
}

type EncodeAgg added in v0.6.0

type EncodeAgg struct {
	Op      int64
	Private []byte
	Es      []bool
	Da      []byte

	InputTypes []byte
	OutputType []byte
	IsCount    bool
}

func (*EncodeAgg) Descriptor added in v0.8.0

func (*EncodeAgg) Descriptor() ([]byte, []int)

func (*EncodeAgg) GetDa added in v0.8.0

func (m *EncodeAgg) GetDa() []byte

func (*EncodeAgg) GetEs added in v0.8.0

func (m *EncodeAgg) GetEs() []bool

func (*EncodeAgg) GetInputTypes added in v0.8.0

func (m *EncodeAgg) GetInputTypes() []byte

func (*EncodeAgg) GetIsCount added in v0.8.0

func (m *EncodeAgg) GetIsCount() bool

func (*EncodeAgg) GetOp added in v0.8.0

func (m *EncodeAgg) GetOp() int64

func (*EncodeAgg) GetOutputType added in v0.8.0

func (m *EncodeAgg) GetOutputType() []byte

func (*EncodeAgg) GetPrivate added in v0.8.0

func (m *EncodeAgg) GetPrivate() []byte

func (*EncodeAgg) Marshal added in v0.8.0

func (m *EncodeAgg) Marshal() (dAtA []byte, err error)

func (*EncodeAgg) MarshalTo added in v0.8.0

func (m *EncodeAgg) MarshalTo(dAtA []byte) (int, error)

func (*EncodeAgg) MarshalToSizedBuffer added in v0.8.0

func (m *EncodeAgg) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*EncodeAgg) ProtoMessage added in v0.8.0

func (*EncodeAgg) ProtoMessage()

func (*EncodeAgg) ProtoSize added in v0.8.0

func (m *EncodeAgg) ProtoSize() (n int)

func (*EncodeAgg) Reset added in v0.8.0

func (m *EncodeAgg) Reset()

func (*EncodeAgg) String added in v0.8.0

func (m *EncodeAgg) String() string

func (*EncodeAgg) Unmarshal added in v0.8.0

func (m *EncodeAgg) Unmarshal(dAtA []byte) error

func (*EncodeAgg) XXX_DiscardUnknown added in v0.8.0

func (m *EncodeAgg) XXX_DiscardUnknown()

func (*EncodeAgg) XXX_Marshal added in v0.8.0

func (m *EncodeAgg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EncodeAgg) XXX_Merge added in v0.8.0

func (m *EncodeAgg) XXX_Merge(src proto.Message)

func (*EncodeAgg) XXX_Size added in v0.8.0

func (m *EncodeAgg) XXX_Size() int

func (*EncodeAgg) XXX_Unmarshal added in v0.8.0

func (m *EncodeAgg) XXX_Unmarshal(b []byte) error

type EncodeAggDistinct added in v0.6.0

type EncodeAggDistinct[T any] struct {
	Op      int64
	Private []byte
	Es      []bool
	Da      []byte

	InputTypes []types.Type
	OutputType types.Type

	IsCount bool
	Srcs    [][]T
}

func (*EncodeAggDistinct[T]) MarshalBinary added in v0.8.0

func (m *EncodeAggDistinct[T]) MarshalBinary() ([]byte, error)

func (*EncodeAggDistinct[T]) UnmarshalBinary added in v0.8.0

func (m *EncodeAggDistinct[T]) UnmarshalBinary(data []byte) error

type EncodeAggDistinctPB added in v0.8.0

type EncodeAggDistinctPB struct {
	Op         int64                                                        `protobuf:"varint,1,opt,name=Op,proto3,casttype=int64" json:"Op,omitempty"`
	Private    []byte                                                       `protobuf:"bytes,2,opt,name=Private,proto3" json:"Private,omitempty"`
	Es         []bool                                                       `protobuf:"varint,3,rep,packed,name=Es,proto3" json:"Es,omitempty"`
	Da         []byte                                                       `protobuf:"bytes,4,opt,name=Da,proto3" json:"Da,omitempty"`
	InputTypes []github_com_matrixorigin_matrixone_pkg_container_types.Type `` /* 133-byte string literal not displayed */
	OutputType github_com_matrixorigin_matrixone_pkg_container_types.Type   `` /* 133-byte string literal not displayed */
	IsCount    bool                                                         `protobuf:"varint,7,opt,name=IsCount,proto3" json:"IsCount,omitempty"`
}

func (*EncodeAggDistinctPB) Descriptor added in v0.8.0

func (*EncodeAggDistinctPB) Descriptor() ([]byte, []int)

func (*EncodeAggDistinctPB) GetDa added in v0.8.0

func (m *EncodeAggDistinctPB) GetDa() []byte

func (*EncodeAggDistinctPB) GetEs added in v0.8.0

func (m *EncodeAggDistinctPB) GetEs() []bool

func (*EncodeAggDistinctPB) GetIsCount added in v0.8.0

func (m *EncodeAggDistinctPB) GetIsCount() bool

func (*EncodeAggDistinctPB) GetOp added in v0.8.0

func (m *EncodeAggDistinctPB) GetOp() int64

func (*EncodeAggDistinctPB) GetPrivate added in v0.8.0

func (m *EncodeAggDistinctPB) GetPrivate() []byte

func (*EncodeAggDistinctPB) Marshal added in v0.8.0

func (m *EncodeAggDistinctPB) Marshal() (dAtA []byte, err error)

func (*EncodeAggDistinctPB) MarshalTo added in v0.8.0

func (m *EncodeAggDistinctPB) MarshalTo(dAtA []byte) (int, error)

func (*EncodeAggDistinctPB) MarshalToSizedBuffer added in v0.8.0

func (m *EncodeAggDistinctPB) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*EncodeAggDistinctPB) ProtoMessage added in v0.8.0

func (*EncodeAggDistinctPB) ProtoMessage()

func (*EncodeAggDistinctPB) ProtoSize added in v0.8.0

func (m *EncodeAggDistinctPB) ProtoSize() (n int)

func (*EncodeAggDistinctPB) Reset added in v0.8.0

func (m *EncodeAggDistinctPB) Reset()

func (*EncodeAggDistinctPB) String added in v0.8.0

func (m *EncodeAggDistinctPB) String() string

func (*EncodeAggDistinctPB) Unmarshal added in v0.8.0

func (m *EncodeAggDistinctPB) Unmarshal(dAtA []byte) error

func (*EncodeAggDistinctPB) XXX_DiscardUnknown added in v0.8.0

func (m *EncodeAggDistinctPB) XXX_DiscardUnknown()

func (*EncodeAggDistinctPB) XXX_Marshal added in v0.8.0

func (m *EncodeAggDistinctPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EncodeAggDistinctPB) XXX_Merge added in v0.8.0

func (m *EncodeAggDistinctPB) XXX_Merge(src proto.Message)

func (*EncodeAggDistinctPB) XXX_Size added in v0.8.0

func (m *EncodeAggDistinctPB) XXX_Size() int

func (*EncodeAggDistinctPB) XXX_Unmarshal added in v0.8.0

func (m *EncodeAggDistinctPB) XXX_Unmarshal(b []byte) error

type UnaryAgg

type UnaryAgg[T1, T2 any] struct {
	PartialResult any
	// contains filtered or unexported fields
}

UnaryAgg generic aggregation function with one input vector and without distinct

func (*UnaryAgg[T1, T2]) BatchFill

func (a *UnaryAgg[T1, T2]) BatchFill(offset int64, groupStatus []uint8, groupOfRows []uint64, vectors []*vector.Vector) (err error)

func (*UnaryAgg[T1, T2]) BatchMerge

func (a *UnaryAgg[T1, T2]) BatchMerge(b Agg[any], offset int64, groupStatus []uint8, groupIdxes []uint64) (err error)

func (*UnaryAgg[T1, T2]) BulkFill

func (a *UnaryAgg[T1, T2]) BulkFill(groupIdx int64, vectors []*vector.Vector) (err error)

func (*UnaryAgg[T1, T2]) Dup

func (a *UnaryAgg[T1, T2]) Dup(m *mpool.MPool) Agg[any]

todo need improve performance

func (*UnaryAgg[T1, T2]) Eval

func (a *UnaryAgg[T1, T2]) Eval(pool *mpool.MPool) (vec *vector.Vector, err error)

func (*UnaryAgg[T1, T2]) Fill

func (a *UnaryAgg[T1, T2]) Fill(groupIdx int64, rowIndex int64, vectors []*vector.Vector) (err error)

func (*UnaryAgg[T1, T2]) Free

func (a *UnaryAgg[T1, T2]) Free(pool *mpool.MPool)

func (*UnaryAgg[T1, T2]) GetOperatorId added in v0.6.0

func (a *UnaryAgg[T1, T2]) GetOperatorId() int64

func (*UnaryAgg[T1, T2]) Grows

func (a *UnaryAgg[T1, T2]) Grows(count int, pool *mpool.MPool) error

func (*UnaryAgg[T1, T2]) InputTypes

func (a *UnaryAgg[T1, T2]) InputTypes() []types.Type

func (*UnaryAgg[T1, T2]) IsDistinct added in v0.6.0

func (a *UnaryAgg[T1, T2]) IsDistinct() bool

func (*UnaryAgg[T1, T2]) MarshalBinary added in v0.6.0

func (a *UnaryAgg[T1, T2]) MarshalBinary() ([]byte, error)

func (*UnaryAgg[T1, T2]) Merge

func (a *UnaryAgg[T1, T2]) Merge(b Agg[any], groupIdx1, groupIdx2 int64) (err error)

Merge a[x] += b[y]

func (*UnaryAgg[T1, T2]) OutputType

func (a *UnaryAgg[T1, T2]) OutputType() types.Type

func (*UnaryAgg[T1, T2]) SetPartialResult added in v1.1.0

func (agg *UnaryAgg[T1, T2]) SetPartialResult(PartialResult any)

func (*UnaryAgg[T1, T2]) UnmarshalBinary added in v0.6.0

func (a *UnaryAgg[T1, T2]) UnmarshalBinary(data []byte) error

func (*UnaryAgg[T1, T2]) WildAggReAlloc added in v0.6.0

func (a *UnaryAgg[T1, T2]) WildAggReAlloc(m *mpool.MPool) error

type UnaryDistAgg

type UnaryDistAgg[T1, T2 any] struct {
	PartialResult any
	// contains filtered or unexported fields
}

UnaryDistAgg generic aggregation function with one input vector and with distinct

func (*UnaryDistAgg[T1, T2]) BatchFill

func (a *UnaryDistAgg[T1, T2]) BatchFill(offset int64, groupStatus []uint8, groupOfRows []uint64, vectors []*vector.Vector) (err error)

func (*UnaryDistAgg[T1, T2]) BatchMerge

func (a *UnaryDistAgg[T1, T2]) BatchMerge(b Agg[any], offset int64, groupStatus []uint8, groupIdxes []uint64) (err error)

func (*UnaryDistAgg[T1, T2]) BulkFill

func (a *UnaryDistAgg[T1, T2]) BulkFill(groupIdx int64, vectors []*vector.Vector) (err error)

func (*UnaryDistAgg[T1, T2]) Dup

func (a *UnaryDistAgg[T1, T2]) Dup(m *mpool.MPool) Agg[any]

todo need improve performance

func (*UnaryDistAgg[T1, T2]) Eval

func (a *UnaryDistAgg[T1, T2]) Eval(pool *mpool.MPool) (vec *vector.Vector, err error)

func (*UnaryDistAgg[T1, T2]) Fill

func (a *UnaryDistAgg[T1, T2]) Fill(groupIdx int64, rowIndex int64, vectors []*vector.Vector) (err error)

func (*UnaryDistAgg[T1, T2]) Free

func (a *UnaryDistAgg[T1, T2]) Free(pool *mpool.MPool)

func (*UnaryDistAgg[T1, T2]) GetOperatorId added in v0.6.0

func (a *UnaryDistAgg[T1, T2]) GetOperatorId() int64

func (*UnaryDistAgg[T1, T2]) Grows

func (a *UnaryDistAgg[T1, T2]) Grows(count int, pool *mpool.MPool) (err error)

func (*UnaryDistAgg[T1, T2]) InputTypes

func (a *UnaryDistAgg[T1, T2]) InputTypes() []types.Type

func (*UnaryDistAgg[T1, T2]) IsDistinct added in v0.6.0

func (a *UnaryDistAgg[T1, T2]) IsDistinct() bool

func (*UnaryDistAgg[T1, T2]) MarshalBinary added in v0.6.0

func (a *UnaryDistAgg[T1, T2]) MarshalBinary() ([]byte, error)

func (*UnaryDistAgg[T1, T2]) Merge

func (a *UnaryDistAgg[T1, T2]) Merge(b Agg[any], groupIdx1, groupIdx2 int64) (err error)

Merge a[x] += b[y]

func (*UnaryDistAgg[T1, T2]) OutputType

func (a *UnaryDistAgg[T1, T2]) OutputType() types.Type

func (*UnaryDistAgg[T1, T2]) SetPartialResult added in v1.1.0

func (agg *UnaryDistAgg[T1, T2]) SetPartialResult(PartialResult any)

func (*UnaryDistAgg[T1, T2]) UnmarshalBinary added in v0.6.0

func (a *UnaryDistAgg[T1, T2]) UnmarshalBinary(data []byte) error

func (*UnaryDistAgg[T1, T2]) WildAggReAlloc added in v0.6.0

func (a *UnaryDistAgg[T1, T2]) WildAggReAlloc(m *mpool.MPool) error

Jump to

Keyboard shortcuts

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