group_concat

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: 18 Imported by: 0

Documentation

Overview

Copyright 2022 Matrix Origin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

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")
)

Functions

func NewGroupConcat

func NewGroupConcat(arg *Argument, typs []types.Type) agg.Agg[any]

func VectorToString

func VectorToString(vec *vector.Vector, rowIndex int) (string, error)

Types

type Argument

type Argument struct {
	Dist        bool
	GroupExpr   []*plan.Expr // group Expressions
	OrderByExpr []*plan.Expr // orderby Expressions, for now we don't care about it
	Separator   string
	// because we store multiAgg and UnaryAgg separately.
	// we use this to record the order in sql.
	// like 'select group_concat(a),avg(a) from t;'
	// this orderId will be 0.
	// but for 'select avg(a), group_concat(a) from t;'
	// this orderId will be 1.
	OrderId int32
}

for example: group_concat(distinct a,b order by a seporator '|') dist: true groupExpr: a,b orderByExpr: a separator: "|"

func (*Argument) Descriptor added in v0.8.0

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

func (*Argument) GetDist added in v0.8.0

func (m *Argument) GetDist() bool

func (*Argument) GetGroupExpr added in v0.8.0

func (m *Argument) GetGroupExpr() []*plan.Expr

func (*Argument) GetOrderByExpr added in v0.8.0

func (m *Argument) GetOrderByExpr() []*plan.Expr

func (*Argument) GetOrderId added in v0.8.0

func (m *Argument) GetOrderId() int32

func (*Argument) GetSeparator added in v0.8.0

func (m *Argument) GetSeparator() string

func (*Argument) Marshal added in v0.8.0

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

func (*Argument) MarshalTo added in v0.8.0

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

func (*Argument) MarshalToSizedBuffer added in v0.8.0

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

func (*Argument) ProtoMessage added in v0.8.0

func (*Argument) ProtoMessage()

func (*Argument) ProtoSize added in v0.8.0

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

func (*Argument) Reset added in v0.8.0

func (m *Argument) Reset()

func (*Argument) String added in v0.8.0

func (m *Argument) String() string

func (*Argument) Unmarshal added in v0.8.0

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

func (*Argument) XXX_DiscardUnknown added in v0.8.0

func (m *Argument) XXX_DiscardUnknown()

func (*Argument) XXX_Marshal added in v0.8.0

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

func (*Argument) XXX_Merge added in v0.8.0

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

func (*Argument) XXX_Size added in v0.8.0

func (m *Argument) XXX_Size() int

func (*Argument) XXX_Unmarshal added in v0.8.0

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

type EncodeGroupConcat

type EncodeGroupConcat struct {
	ResStrData     []byte
	InsertsStrData []byte
	Arg            *Argument
	Ityp           []types.Type
	Groups         int
}

func (*EncodeGroupConcat) Descriptor added in v0.8.0

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

func (*EncodeGroupConcat) GetArg added in v0.8.0

func (m *EncodeGroupConcat) GetArg() *Argument

func (*EncodeGroupConcat) GetGroups added in v0.8.0

func (m *EncodeGroupConcat) GetGroups() int

func (*EncodeGroupConcat) GetInsertsStrData added in v0.8.0

func (m *EncodeGroupConcat) GetInsertsStrData() []byte

func (*EncodeGroupConcat) GetResStrData added in v0.8.0

func (m *EncodeGroupConcat) GetResStrData() []byte

func (*EncodeGroupConcat) Marshal added in v0.8.0

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

func (*EncodeGroupConcat) MarshalBinary added in v0.8.0

func (m *EncodeGroupConcat) MarshalBinary() ([]byte, error)

func (*EncodeGroupConcat) MarshalTo added in v0.8.0

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

func (*EncodeGroupConcat) MarshalToSizedBuffer added in v0.8.0

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

func (*EncodeGroupConcat) ProtoMessage added in v0.8.0

func (*EncodeGroupConcat) ProtoMessage()

func (*EncodeGroupConcat) ProtoSize added in v0.8.0

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

func (*EncodeGroupConcat) Reset added in v0.8.0

func (m *EncodeGroupConcat) Reset()

func (*EncodeGroupConcat) String added in v0.8.0

func (m *EncodeGroupConcat) String() string

func (*EncodeGroupConcat) Unmarshal added in v0.8.0

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

func (*EncodeGroupConcat) UnmarshalBinary added in v0.8.0

func (m *EncodeGroupConcat) UnmarshalBinary(data []byte) error

func (*EncodeGroupConcat) XXX_DiscardUnknown added in v0.8.0

func (m *EncodeGroupConcat) XXX_DiscardUnknown()

func (*EncodeGroupConcat) XXX_Marshal added in v0.8.0

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

func (*EncodeGroupConcat) XXX_Merge added in v0.8.0

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

func (*EncodeGroupConcat) XXX_Size added in v0.8.0

func (m *EncodeGroupConcat) XXX_Size() int

func (*EncodeGroupConcat) XXX_Unmarshal added in v0.8.0

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

type GroupConcat

type GroupConcat struct {
	// contains filtered or unexported fields
}

+------+------+------+ | a | b | c | +------+------+------+ | 1 | 2 | 3 | | 4 | 5 | 6 | +------+------+------+ select group_concat(a,b,c separator "|") from t; res[0] = "123|456" inserts = "encode(1,2,3)|encode(4,5,6) we need inserts to store the source keys, so we can use then where merge

func (*GroupConcat) BatchFill

func (gc *GroupConcat) BatchFill(offset int64, os []uint8, vps []uint64, vecs []*vector.Vector) error

BatchFill use part of the vector to update the data of agg's group

os(origin-s) records information about which groups need to be updated
if length of os is N, we use first N of vps to do update work.
And if os[i] > 0, it means the agg's (vps[i]-1)th group is a new one (never been assigned a value),
Maybe this feature can help us to do some optimization work.
So we use the os as a parameter but not len(os).

agg's (vps[i]-1)th group is related to vector's (offset+i)th row.
rowCounts[i] is count number of the row[i]

For a more detailed introduction of rowCounts, please refer to comments of Function Fill.

func (*GroupConcat) BatchMerge

func (gc *GroupConcat) BatchMerge(agg2 agg.Agg[any], start int64, os []uint8, vps []uint64) error

BatchMerge merges multi groups of agg1 and agg2

agg1's (vps[i]-1)th group is related to agg2's (start+i)th group

For more introduction of os, please refer to comments of Function BatchFill.

func (*GroupConcat) BulkFill

func (gc *GroupConcat) BulkFill(groupIndex int64, vecs []*vector.Vector) error

func (*GroupConcat) Dup

func (gc *GroupConcat) Dup(_ *mpool.MPool) agg.Agg[any]

todo need improve performance

func (*GroupConcat) Eval

func (gc *GroupConcat) Eval(m *mpool.MPool) (*vector.Vector, error)

Eval method calculates and returns the final result of the aggregate function.

func (*GroupConcat) Fill

func (gc *GroupConcat) Fill(groupIndex int64, rowIndex int64, vecs []*vector.Vector) error

Fill use the rowIndex-rows of vector to update the data of groupIndex-group. rowCount indicates the number of times the rowIndex-row is repeated. for group_concat(distinct a,b,c separator '|'); vecs is: a,b,c remember that, we won't do evalExpr here, so the groupExpr is not used here

func (*GroupConcat) Free

func (gc *GroupConcat) Free(*mpool.MPool)

Free the agg.

func (*GroupConcat) GetOperatorId

func (gc *GroupConcat) GetOperatorId() int64

GetOperatorId get types of aggregate's aggregate id. this is used to print log in group string();

func (*GroupConcat) Grows

func (gc *GroupConcat) Grows(n int, m *mpool.MPool) error

Grows allocates n groups for the agg.

func (*GroupConcat) InputTypes

func (gc *GroupConcat) InputTypes() []types.Type

group_concat is not a normal agg func, we don't need this func

func (*GroupConcat) IsDistinct

func (gc *GroupConcat) IsDistinct() bool

func (*GroupConcat) MarshalBinary

func (gc *GroupConcat) MarshalBinary() (data []byte, err error)

We need to implements the interface of Agg

func (*GroupConcat) Merge

func (gc *GroupConcat) Merge(agg2 agg.Agg[any], groupIndex1 int64, groupIndex2 int64) 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

func (*GroupConcat) OutputType

func (gc *GroupConcat) OutputType() types.Type

Type return the type of the agg's result.

func (*GroupConcat) SetPartialResult added in v1.1.0

func (gc *GroupConcat) SetPartialResult(_ any)

func (*GroupConcat) UnmarshalBinary

func (gc *GroupConcat) UnmarshalBinary(data []byte) error

encoding.BinaryUnmarshaler

func (*GroupConcat) WildAggReAlloc

func (gc *GroupConcat) WildAggReAlloc(m *mpool.MPool) error

WildAggReAlloc reallocate for agg structure from memory pool.

Jump to

Keyboard shortcuts

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