qrouter

package
v0.0.0-...-963c118 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: PostgreSQL Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CatalogDistribution = distributions.Distribution{
	Relations: nil,
	Id:        distributions.REPLICATED,
	ColTypes:  nil,
}
View Source
var ErrComplexQuery = fmt.Errorf("too complex query to route")
View Source
var ErrInformationSchemaCombinedQuery = fmt.Errorf("combined information schema and regular relation is not supported")
View Source
var MatchShardError = fmt.Errorf("failed to match datashard")

Functions

func ReportStmtDeparsedAttrs

func ReportStmtDeparsedAttrs(ctx context.Context, pi *clientinteractor.PSQLInteractor, meta *RoutingMetadataContext) error

TODO : unit tests

Types

type AnyRelation

type AnyRelation struct{}

type LocalQrouter

type LocalQrouter struct {
	QueryRouter
	// contains filtered or unexported fields
}

func NewLocalQrouter

func NewLocalQrouter(shardMapping map[string]*config.Shard) (*LocalQrouter, error)

func (*LocalQrouter) AddDataShard

func (l *LocalQrouter) AddDataShard(_ context.Context, ds *datashards.DataShard) error

TODO : unit tests

func (*LocalQrouter) DataShardsRoutes

func (l *LocalQrouter) DataShardsRoutes() []*routingstate.DataShardRoute

TODO : unit tests

func (*LocalQrouter) Initialize

func (l *LocalQrouter) Initialize() bool

func (*LocalQrouter) Initialized

func (l *LocalQrouter) Initialized() bool

func (*LocalQrouter) ListKeyRanges

func (l *LocalQrouter) ListKeyRanges(ctx context.Context) ([]*kr.KeyRange, error)

func (*LocalQrouter) Route

TODO : unit tests

type ProxyQrouter

type ProxyQrouter struct {
	ColumnMapping map[string]struct{}
	LocalTables   map[string]struct{}

	// shards
	DataShardCfgs  map[string]*config.Shard
	WorldShardCfgs map[string]*config.Shard
	// contains filtered or unexported fields
}

func NewProxyRouter

func NewProxyRouter(shardMapping map[string]*config.Shard, mgr meta.EntityMgr, qcfg *config.QRouter, cache *cache.SchemaCache) (*ProxyQrouter, error)

func (*ProxyQrouter) CheckTableIsRoutable

func (qr *ProxyQrouter) CheckTableIsRoutable(ctx context.Context, node *lyx.CreateTable) error

CheckTableIsRoutable Given table create statement, check if it is routable with some sharding rule TODO : unit tests

func (*ProxyQrouter) DataShardsRoutes

func (qr *ProxyQrouter) DataShardsRoutes() []*routingstate.DataShardRoute

TODO : unit tests

func (*ProxyQrouter) DeparseExprShardingEntries

func (qr *ProxyQrouter) DeparseExprShardingEntries(expr lyx.Node, meta *RoutingMetadataContext) (string, string, error)

DeparseExprShardingEntries deparses sharding column entries(column names or aliased column names) e.g {fields:{string:{str:"a"}} fields:{string:{str:"i"}} for `WHERE a.i = 1` returns alias and column name

func (*ProxyQrouter) DeparseKeyWithRangesInternal

func (qr *ProxyQrouter) DeparseKeyWithRangesInternal(_ context.Context, key []interface{}, krs []*kr.KeyRange) (*routingstate.DataShardRoute, error)

TODO : unit tests

func (*ProxyQrouter) DeparseSelectStmt

func (qr *ProxyQrouter) DeparseSelectStmt(ctx context.Context, selectStmt lyx.Node, meta *RoutingMetadataContext) error

TODO : unit tests

func (*ProxyQrouter) Explain

TODO : unit tests

func (*ProxyQrouter) GetDistributionKeyOffsetType

func (qr *ProxyQrouter) GetDistributionKeyOffsetType(meta *RoutingMetadataContext, resolvedRelation RelationFQN, colname string) (int, string)

func (*ProxyQrouter) Initialize

func (qr *ProxyQrouter) Initialize() bool

func (*ProxyQrouter) Initialized

func (qr *ProxyQrouter) Initialized() bool

func (*ProxyQrouter) Mgr

func (qr *ProxyQrouter) Mgr() meta.EntityMgr

func (*ProxyQrouter) Route

TODO : unit tests

func (*ProxyQrouter) SchemaCache

func (qr *ProxyQrouter) SchemaCache() *cache.SchemaCache

func (*ProxyQrouter) WorldShardsRoutes

func (qr *ProxyQrouter) WorldShardsRoutes() []*routingstate.DataShardRoute

TODO : unit tests

type QueryRouter

type QueryRouter interface {
	Route(ctx context.Context, stmt lyx.Node, sph session.SessionParamsHolder) (routingstate.RoutingState, error)

	WorldShardsRoutes() []*routingstate.DataShardRoute
	DataShardsRoutes() []*routingstate.DataShardRoute

	DeparseKeyWithRangesInternal(ctx context.Context, key []interface{}, krs []*kr.KeyRange) (*routingstate.DataShardRoute, error)

	Initialized() bool
	Initialize() bool

	Mgr() meta.EntityMgr
	SchemaCache() *cache.SchemaCache
}

func NewQrouter

func NewQrouter(qtype config.RouterMode, shardMapping map[string]*config.Shard, mgr meta.EntityMgr, qcfg *config.QRouter, cache *cache.SchemaCache) (QueryRouter, error)

type RelationFQN

type RelationFQN struct {
	RelationName string
	SchemaName   string
}

func RelationFQNFromRangeRangeVar

func RelationFQNFromRangeRangeVar(rv *lyx.RangeVar) RelationFQN

type RelationList

type RelationList struct {
	Relations []string
}

type RoutingMetadataContext

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

func NewRoutingMetadataContext

func NewRoutingMetadataContext() *RoutingMetadataContext

func (*RoutingMetadataContext) GetRelationDistribution

func (meta *RoutingMetadataContext) GetRelationDistribution(ctx context.Context, mgr meta.EntityMgr, resolvedRelation RelationFQN) (*distributions.Distribution, error)

func (*RoutingMetadataContext) RFQNIsCTE

func (meta *RoutingMetadataContext) RFQNIsCTE(resolvedRelation RelationFQN) bool

func (*RoutingMetadataContext) RecordConstExpr

func (meta *RoutingMetadataContext) RecordConstExpr(resolvedRelation RelationFQN, colname string, expr interface{}) error

TODO : unit tests

func (*RoutingMetadataContext) RecordParamRefExpr

func (meta *RoutingMetadataContext) RecordParamRefExpr(resolvedRelation RelationFQN, colname string, ind int) error

func (*RoutingMetadataContext) ResolveRelationByAlias

func (meta *RoutingMetadataContext) ResolveRelationByAlias(alias string) (RelationFQN, error)

TODO : unit tests

type SpecificRelation

type SpecificRelation struct {
	Name string
}

type StatementRelation

type StatementRelation interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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