partitionservice

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: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PartitionTableMetadataSQL = fmt.Sprintf(`create table %s.%s(
		table_id 		           bigint        unsigned primary key not null,  
		table_name                 varchar(500)                       not null,
		database_name			   varchar(500)                       not null,
		partition_method           varchar(13)                        not null,  
		partition_description      text                               not null,
		partition_count            int	         unsigned
	)`, catalog.MO_CATALOG, catalog.MOPartitionMetadata)

	PartitionTablesSQL = fmt.Sprintf(`create table %s.%s(
		partition_id               bigint        unsigned not null,
		partition_table_name       varchar(200)  not null,
		primary_table_id 		   bigint        unsigned not null, 
		partition_name             varchar(50)   not null,
		partition_ordinal_position int	         unsigned not null,
		partition_expression_str   varchar(2048) not null,
    	partition_expression       varchar(2048) not null
	)`, catalog.MO_CATALOG, catalog.MOPartitionTables)

	InitSQLs = []string{
		PartitionTablesSQL,
		PartitionTableMetadataSQL,
	}
)
View Source
var (
	DisabledService = NewService(Config{}, nil)
)

Functions

func GetPartitionTableName

func GetPartitionTableName(
	tableName string,
	partitionName string,
) string

Types

type Config

type Config struct {
	// ServiceID service id
	ServiceID string `toml:"-"`
	// Disable disable partition service
	Disable bool `toml:"disable"`
}

Config partition service

type PartitionService

type PartitionService interface {
	Create(
		ctx context.Context,
		tableID uint64,
		stmt *tree.CreateTable,
		txnOp client.TxnOperator,
	) error

	Redefine(
		ctx context.Context,
		tableID uint64,
		stmt *tree.PartitionOption,
		txnOp client.TxnOperator,
	) error

	Rename(
		ctx context.Context,
		tableID uint64,
		oldName, newName string,
		txnOp client.TxnOperator,
	) error

	Delete(
		ctx context.Context,
		tableID uint64,
		txnOp client.TxnOperator,
	) error

	AddPartitions(
		ctx context.Context,
		tableID uint64,
		partitions []*tree.Partition,
		partitionDefs []*plan.PartitionDef,
		txnOp client.TxnOperator,
	) error

	DropPartitions(
		ctx context.Context,
		tableID uint64,
		partitions []string,
		txnOp client.TxnOperator,
	) error

	TruncatePartitions(
		ctx context.Context,
		tableID uint64,
		partitions []string,
		txnOp client.TxnOperator,
	) error

	GetPartitionMetadata(
		ctx context.Context,
		tableID uint64,
		txnOp client.TxnOperator,
	) (partition.PartitionMetadata, error)

	GetStorage() PartitionStorage

	Enabled() bool
}

PartitionService is used to maintaining the metadata of the partition table.

func GetService

func GetService(
	sid string,
) PartitionService

type PartitionStorage

type PartitionStorage interface {
	GetMetadata(
		ctx context.Context,
		tableID uint64,
		txnOp client.TxnOperator,
	) (partition.PartitionMetadata, bool, error)

	Create(
		ctx context.Context,
		def *plan.TableDef,
		stmt *tree.CreateTable,
		metadata partition.PartitionMetadata,
		txnOp client.TxnOperator,
	) error

	Redefine(
		ctx context.Context,
		def *plan.TableDef,
		options *tree.PartitionOption,
		metadata partition.PartitionMetadata,
		txnOp client.TxnOperator,
	) error

	Rename(
		ctx context.Context,
		def *plan.TableDef,
		oldName, newName string,
		metadata partition.PartitionMetadata,
		txnOp client.TxnOperator,
	) error

	AddPartitions(
		ctx context.Context,
		def *plan.TableDef,
		metadata partition.PartitionMetadata,
		partitions []partition.Partition,
		txnOp client.TxnOperator,
	) error

	DropPartitions(
		ctx context.Context,
		def *plan.TableDef,
		metadata partition.PartitionMetadata,
		partitions []string,
		txnOp client.TxnOperator,
	) error

	TruncatePartitions(
		ctx context.Context,
		def *plan.TableDef,
		metadata partition.PartitionMetadata,
		partitions []string,
		txnOp client.TxnOperator,
	) error

	Delete(
		ctx context.Context,
		metadata partition.PartitionMetadata,
		txnOp client.TxnOperator,
	) error

	GetTableDef(
		ctx context.Context,
		tableID uint64,
		txnOp client.TxnOperator,
	) (*plan.TableDef, error)
}

func NewStorage

func NewStorage(
	sid string,
	exec executor.SQLExecutor,
	eng engine.Engine,
) PartitionStorage

type PruneResult

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

func NewPruneResult

func NewPruneResult(bats []*batch.Batch, partitions []partition.Partition) PruneResult

func (PruneResult) Close

func (res PruneResult) Close()

func (PruneResult) Empty

func (res PruneResult) Empty() bool

func (PruneResult) Iter

func (res PruneResult) Iter(fn func(partition partition.Partition, bat *batch.Batch) bool)

type Service

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

func NewService

func NewService(
	cfg Config,
	store PartitionStorage,
) *Service

func (*Service) AddPartitions

func (s *Service) AddPartitions(
	ctx context.Context,
	tableID uint64,
	partitions []*tree.Partition,
	partitionDefs []*plan.PartitionDef,
	txnOp client.TxnOperator,
) error

func (*Service) Create

func (s *Service) Create(
	ctx context.Context,
	tableID uint64,
	stmt *tree.CreateTable,
	txnOp client.TxnOperator,
) error

func (*Service) Delete

func (s *Service) Delete(
	ctx context.Context,
	tableID uint64,
	txnOp client.TxnOperator,
) error

func (*Service) DropPartitions

func (s *Service) DropPartitions(
	ctx context.Context,
	tableID uint64,
	partitions []string,
	txnOp client.TxnOperator,
) error

func (*Service) Enabled

func (s *Service) Enabled() bool

func (*Service) GetPartitionMetadata

func (s *Service) GetPartitionMetadata(
	ctx context.Context,
	tableID uint64,
	txnOp client.TxnOperator,
) (partition.PartitionMetadata, error)

func (*Service) GetStorage

func (s *Service) GetStorage() PartitionStorage

func (*Service) Redefine

func (s *Service) Redefine(
	ctx context.Context,
	tableID uint64,
	stmt *tree.PartitionOption,
	txnOp client.TxnOperator,
) error

func (*Service) Rename

func (s *Service) Rename(
	ctx context.Context,
	tableID uint64,
	oldName, newName string,
	txnOp client.TxnOperator,
) error

func (*Service) TruncatePartitions

func (s *Service) TruncatePartitions(
	ctx context.Context,
	tableID uint64,
	partitions []string,
	txnOp client.TxnOperator,
) error

Jump to

Keyboard shortcuts

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