util

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPackerSize = 4096
)

Variables

View Source
var CompactPrimaryCol = compactPrimaryCol
View Source
var CompactSingleIndexCol = compactSingleIndexCol
View Source
var SerialWithCompacted = serialWithCompacted
View Source
var SerialWithoutCompacted = serialWithoutCompacted

Functions

func AppendAnyToStringVector added in v0.8.0

func AppendAnyToStringVector(proc *process.Process, val any, vec *vector.Vector) error

func BinaryToInt added in v1.1.1

func BinaryToInt(b string) (uint64, error)

func BuildCompositeClusterByColumnName added in v0.7.0

func BuildCompositeClusterByColumnName(s []string) string

func BuildIndexTableName added in v0.6.0

func BuildIndexTableName(ctx context.Context, unique bool) (string, error)

func BuildMoColumnsFilter added in v0.7.0

func BuildMoColumnsFilter(curAccountId uint64) tree.Expr

Build the filter condition AST expression for mo_columns, as follows: account_id = current_id or (account_id = 0 and attr_databse in mo_catalog and att_relname not in other tables)

func BuildMoDataBaseFilter added in v0.7.0

func BuildMoDataBaseFilter(curAccountId uint64) tree.Expr

Build the filter condition AST expression for mo_database, as follows: account_id = cur_accountId or (account_id = 0 and datname in ('mo_catalog'))

func BuildMoTablesFilter added in v0.7.0

func BuildMoTablesFilter(curAccountId uint64) tree.Expr

Build the filter condition AST expression for mo_tables, as follows: account_id = cur_account_id or (account_id = 0 and (relname in ('mo_tables','mo_database','mo_columns') or relkind = 'cluster'))

func BuildSysMetricFilter added in v0.8.0

func BuildSysMetricFilter(curAccountId uint64) tree.Expr

func BuildSysStatementInfoFilter added in v0.8.0

func BuildSysStatementInfoFilter(curAccountId uint64) tree.Expr

func BuildUniqueKeyBatch added in v0.6.0

func BuildUniqueKeyBatch(
	vecs []*vector.Vector,
	attrs []string,
	parts []string,
	originTablePrimaryKey string,
	proc *process.Process,
	packers *PackerList,
) (*batch.Batch, int, error)

BuildUniqueKeyBatch used in test to validate serialWithCompacted(), compactSingleIndexCol() and compactPrimaryCol()

func ConvertAccountToAccountIdWithTableCheck

func ConvertAccountToAccountIdWithTableCheck(astExpr tree.Expr, isSystemAccount bool, currentAccountName string, currentAccountID uint32, tableAliasMap map[string]bool, accountIdResolver AccountIdResolver) (tree.Expr, bool)

ConvertAccountToAccountIdWithTableCheck converts account column references to account_id comparisons in AST. This conversion is primarily designed for compatibility with mo-cloud's business-level usage of the account field.

The function only handles EQUAL operations (account = 'xxx') for system accounts. For other operations (IN, LIKE, etc.), it keeps the original condition unchanged.

For system accounts (account_id = 0):

  • If account = 'sys', it directly converts to account_id = 0 without query
  • If account = 'xxx' and accountIdResolver is provided, it queries account_id:
  • If account_id is found, replaces with account_id = <id> (can be pushed down to tablescan)
  • If account_id is not found, keeps the original account = 'xxx' condition

For non-system accounts:

  • No conversion is performed because account_id filter is already added in tablescan during plan building. QueryBuiler::buildTable pkg/sql/plan/query_builder.go:4889

tableAliasMap is a map of table names/aliases that refer to statement_info or metric table. If nil, only checks for unqualified column names or table name "statement_info"/"metric". This map is used to verify if table-qualified column names (e.g., s.account, m.account) refer to statement_info or metric.

This allows mo-cloud to query statement_info or metric table using account names (e.g., WHERE account = 'sys' or WHERE s.account = 'sys') instead of account_ids, providing a more intuitive interface while maintaining compatibility with the underlying account_id-based storage and access control.

Returns the converted AST expression and a boolean indicating if any conversion was made.

func CopyBatch added in v0.8.0

func CopyBatch(bat *batch.Batch, proc *process.Process) (*batch.Batch, error)

func DbIsSystemDb added in v0.8.0

func DbIsSystemDb(dbName string) bool

func DecodeBinaryString added in v1.1.1

func DecodeBinaryString(s string) ([]byte, error)

func FillCompositeClusterByBatch added in v0.7.0

func FillCompositeClusterByBatch(bat *batch.Batch, cbName string, proc *process.Process) error

build the clusterBy key's vector of the cluster table according to the composite column name, and append the result vector to batch cbName: column name of composite column

func FillCompositeKeyBatch added in v0.8.0

func FillCompositeKeyBatch(bat *batch.Batch, ckeyName string, keyParts []string, proc *process.Process) error

build the vector of the composite key, and append the result vector to batch ckeyName: column name of composite column keyParts: parts of the composite column

func GenVectorByVarValue added in v0.8.0

func GenVectorByVarValue(proc *process.Process, typ types.Type, val any) (*vector.Vector, error)

func GetClusterByColumnOrder added in v0.7.0

func GetClusterByColumnOrder(cbName, colName string) int

func GetClusterByFirstColumn added in v1.1.0

func GetClusterByFirstColumn(cbName string) string

func GetClusterTableAttributeName added in v0.7.0

func GetClusterTableAttributeName() string

func GetClusterTableAttributeType added in v0.7.0

func GetClusterTableAttributeType() *tree.T

func HexToInt added in v1.1.1

func HexToInt(hex string) (uint64, error)

func InitPredefinedTables added in v1.2.1

func InitPredefinedTables(tables []string)

func IsClusterTableAttribute added in v0.7.0

func IsClusterTableAttribute(name string) bool

func IsIndexTableName

func IsIndexTableName(tableName string) bool

IsIndexTableName checks if the given table name is an index table name with a valid UUID.

func IsValidNameForPartitionTable added in v0.8.0

func IsValidNameForPartitionTable(name string) bool

IsValidNameForPartitionTable the name forms the partition table does not have the partitionDelimiter

func JudgeIsCompositeClusterByColumn added in v0.7.0

func JudgeIsCompositeClusterByColumn(s string) bool

func MakeNameOfPartitionTable added in v0.8.0

func MakeNameOfPartitionTable(partitionName, tableName string) (bool, string)

MakeNameOfPartitionTable !!!NOTE!!! With assumption: the partition name and the table name does not have partitionDelimiter. partition table name format : %!%partition_name%!%table_name

func ScoreBinaryToInt added in v1.2.0

func ScoreBinaryToInt(s string) (uint64, error)

func SetAnyToStringVector added in v0.8.0

func SetAnyToStringVector(proc *process.Process, val any, vec *vector.Vector, idx int) error

func SetBytesToAnyVector added in v0.8.0

func SetBytesToAnyVector(ctx context.Context, val string, row int,
	isNull bool, vec *vector.Vector, proc *process.Process) error

func SetInsertValueBit

func SetInsertValueBit(proc *process.Process, numVal *tree.NumVal, colType *types.Type) (canInsert bool, val uint64, err error)

func SetInsertValueBool

func SetInsertValueBool(proc *process.Process, numVal *tree.NumVal) (canInsert bool, num bool, err error)

func SetInsertValueDate

func SetInsertValueDate(proc *process.Process, numVal *tree.NumVal, typ *types.Type) (canInsert bool, isnull bool, res types.Date, err error)

func SetInsertValueDateTime

func SetInsertValueDateTime(proc *process.Process, numVal *tree.NumVal, typ *types.Type) (canInsert bool, isnull bool, res types.Datetime, err error)

func SetInsertValueDecimal64

func SetInsertValueDecimal64(proc *process.Process, numVal *tree.NumVal, typ *types.Type) (canInsert bool, res types.Decimal64, err error)

func SetInsertValueDecimal128

func SetInsertValueDecimal128(proc *process.Process, numVal *tree.NumVal, typ *types.Type) (canInsert bool, res types.Decimal128, err error)

func SetInsertValueJSON

func SetInsertValueJSON(proc *process.Process, numVal *tree.NumVal) (canInsert bool, val []byte, err error)

func SetInsertValueNumber

func SetInsertValueNumber[T constraints.Integer | constraints.Float](proc *process.Process, numVal *tree.NumVal, colType *types.Type) (canInsert bool, num T, err error)

func SetInsertValueString

func SetInsertValueString(proc *process.Process, numVal *tree.NumVal, typ *types.Type) (canInsert bool, val []byte, err error)

func SetInsertValueTime

func SetInsertValueTime(proc *process.Process, numVal *tree.NumVal, typ *types.Type) (canInsert bool, isnull bool, res types.Time, err error)

func SetInsertValueTimeStamp

func SetInsertValueTimeStamp(proc *process.Process, numVal *tree.NumVal, typ *types.Type) (canInsert bool, isnull bool, res types.Timestamp, err error)

func SplitCompositeClusterByColumnName added in v0.7.0

func SplitCompositeClusterByColumnName(s string) []string

func SplitNameOfPartitionTable added in v0.8.0

func SplitNameOfPartitionTable(name string) (bool, string, string)

SplitNameOfPartitionTable splits the partition table name into partition name and origin table name

func SplitTableAndColumn

func SplitTableAndColumn(name string) (string, string)

func TableIsClusterTable added in v0.7.0

func TableIsClusterTable(tableType string) bool

TableIsClusterTable check the table type is cluster table

func TableIsLoggingTable added in v0.8.0

func TableIsLoggingTable(dbName string, tableName string) bool

func XXHashVectors

func XXHashVectors(vs []*vector.Vector,
	proc *process.Process,
	packers *PackerList,
	hashCode []uint64) ([]uint64, int, error)

Types

type AccountIdResolver

type AccountIdResolver func(accountName string) (uint32, error)

AccountIdResolver is a function type that resolves account name to account_id. It returns the account_id if found, or an error if not found or on failure. If the account is not found, it should return (0, nil) to indicate the account doesn't exist.

type PackerList added in v1.2.0

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

func (*PackerList) Free added in v1.2.0

func (list *PackerList) Free()

func (*PackerList) PackerCount

func (list *PackerList) PackerCount() int

func (*PackerList) Reset

func (list *PackerList) Reset()

func (*PackerList) ResetN

func (list *PackerList) ResetN(n int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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