memoryengine

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpCreateDatabase = iota + 64
	OpOpenDatabase
	OpGetDatabases
	OpDeleteDatabase
	OpCreateRelation
	OpDeleteRelation
	OpTruncateRelation
	OpOpenRelation
	OpGetRelations
	OpAddTableDef
	OpDelTableDef
	OpDelete
	OpGetPrimaryKeys
	OpGetTableColumns
	OpGetTableDefs
	OpGetHiddenKeys
	OpUpdate
	OpWrite
	OpNewTableIter
	OpRead
	OpCloseTableIter
	OpTableStats
	OpPreCommit  = uint32(apipb.OpCode_OpPreCommit)
	OpGetLogTail = uint32(apipb.OpCode_OpGetLogTail)
)

Variables

View Source
var RandomIDGenerator = new(randomIDGenerator)

Functions

func DoTxnRequest

func DoTxnRequest[
	Resp Response,
	Req Request,
](
	ctx context.Context,
	txnOperator client.TxnOperator,
	isRead bool,
	shardsFunc shardsFunc,
	op uint32,
	req Req,
) (
	resps []Resp,
	err error,
)

func GetClusterDetailsFromHAKeeper

func GetClusterDetailsFromHAKeeper(
	ctx context.Context,
	client logservice.CNHAKeeperClient,
) (
	get engine.GetClusterDetailsFunc,
)

Types

type AccessInfo

type AccessInfo struct {
	AccountID uint32
	UserID    uint32
	RoleID    uint32
}

type AddTableDefReq

type AddTableDefReq struct {
	TableID ID
	Def     engine.TableDef

	DatabaseName string
	TableName    string
}

type AddTableDefResp

type AddTableDefResp struct {
}

type BindedEngine

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

func (*BindedEngine) Commit

func (b *BindedEngine) Commit(ctx context.Context, _ client.TxnOperator) error

func (*BindedEngine) Create

func (b *BindedEngine) Create(ctx context.Context, databaseName string, _ client.TxnOperator) error

func (*BindedEngine) Database

func (b *BindedEngine) Database(ctx context.Context, databaseName string, _ client.TxnOperator) (engine.Database, error)

func (*BindedEngine) Databases

func (b *BindedEngine) Databases(ctx context.Context, _ client.TxnOperator) (databaseNames []string, err error)

func (*BindedEngine) Delete

func (b *BindedEngine) Delete(ctx context.Context, databaseName string, _ client.TxnOperator) error

func (*BindedEngine) GetNameById added in v0.7.0

func (b *BindedEngine) GetNameById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, err error)

func (*BindedEngine) GetRelationById added in v0.7.0

func (b *BindedEngine) GetRelationById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, rel engine.Relation, err error)

func (*BindedEngine) Hints

func (b *BindedEngine) Hints() engine.Hints

func (*BindedEngine) New

func (*BindedEngine) NewBlockReader

func (b *BindedEngine) NewBlockReader(_ context.Context, _ int, _ timestamp.Timestamp,
	_ *plan.Expr, _ [][]byte, _ *plan.TableDef) ([]engine.Reader, error)

func (*BindedEngine) Nodes

func (b *BindedEngine) Nodes() (cnNodes engine.Nodes, err error)

func (*BindedEngine) Rollback

func (b *BindedEngine) Rollback(ctx context.Context, _ client.TxnOperator) error

type CloseTableIterReq

type CloseTableIterReq struct {
	IterID ID
}

type CloseTableIterResp

type CloseTableIterResp struct {
}

type CompilerContext

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

func (*CompilerContext) DatabaseExists

func (c *CompilerContext) DatabaseExists(name string) bool

func (*CompilerContext) DefaultDatabase

func (c *CompilerContext) DefaultDatabase() string

func (*CompilerContext) GetAccountId

func (c *CompilerContext) GetAccountId() uint32

func (*CompilerContext) GetBuildingAlterView added in v0.7.0

func (c *CompilerContext) GetBuildingAlterView() (bool, string, string)

func (*CompilerContext) GetContext added in v0.7.0

func (c *CompilerContext) GetContext() context.Context

func (*CompilerContext) GetHideKeyDef

func (c *CompilerContext) GetHideKeyDef(dbName string, tableName string) *plan.ColDef

func (*CompilerContext) GetPrimaryKeyDef

func (c *CompilerContext) GetPrimaryKeyDef(dbName string, tableName string) (defs []*plan.ColDef)

func (*CompilerContext) GetProcess added in v0.7.0

func (c *CompilerContext) GetProcess() *process.Process

func (*CompilerContext) GetQueryResultMeta added in v0.7.0

func (c *CompilerContext) GetQueryResultMeta(uuid string) ([]*plan.ColDef, string, error)

func (*CompilerContext) GetRootSql

func (*CompilerContext) GetRootSql() string

func (*CompilerContext) GetUserName

func (*CompilerContext) GetUserName() string

func (*CompilerContext) Resolve

func (c *CompilerContext) Resolve(schemaName string, tableName string) (objRef *plan.ObjectRef, tableDef *plan.TableDef)

func (*CompilerContext) ResolveAccountIds added in v0.7.0

func (c *CompilerContext) ResolveAccountIds(accountNames []string) ([]uint32, error)

func (*CompilerContext) ResolveById added in v0.7.0

func (c *CompilerContext) ResolveById(tableId uint64) (objRef *plan.ObjectRef, tableDef *plan.TableDef)

func (*CompilerContext) ResolveVariable

func (*CompilerContext) ResolveVariable(varName string, isSystemVar bool, isGlobalVar bool) (interface{}, error)

func (*CompilerContext) SetBuildingAlterView added in v0.7.0

func (c *CompilerContext) SetBuildingAlterView(yesOrNo bool, dbName, viewName string)

func (*CompilerContext) Stats added in v0.7.0

func (*CompilerContext) Stats(obj *plan.ObjectRef, e *plan.Expr) *plan.Stats

type CreateDatabaseReq

type CreateDatabaseReq struct {
	ID         ID
	AccessInfo AccessInfo
	Name       string
}

type CreateDatabaseResp

type CreateDatabaseResp struct {
	ID ID
}

type CreateRelationReq

type CreateRelationReq struct {
	ID           ID
	DatabaseID   ID
	DatabaseName string
	Name         string
	Type         RelationType
	Defs         []engine.TableDef
}

type CreateRelationResp

type CreateRelationResp struct {
	ID ID
}

type Database

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

func (*Database) Create

func (d *Database) Create(ctx context.Context, relName string, defs []engine.TableDef) error

func (*Database) Delete

func (d *Database) Delete(ctx context.Context, relName string) error

func (*Database) GetDatabaseId

func (d *Database) GetDatabaseId(ctx context.Context) string

func (*Database) Relation

func (d *Database) Relation(ctx context.Context, relName string) (engine.Relation, error)

func (*Database) Relations

func (d *Database) Relations(ctx context.Context) ([]string, error)

func (*Database) Truncate

func (d *Database) Truncate(ctx context.Context, relName string) (uint64, error)

type DelTableDefReq

type DelTableDefReq struct {
	TableID      ID
	DatabaseName string
	TableName    string
	Def          engine.TableDef
}

type DelTableDefResp

type DelTableDefResp struct {
}

type DeleteDatabaseReq

type DeleteDatabaseReq struct {
	AccessInfo AccessInfo
	Name       string
}

type DeleteDatabaseResp

type DeleteDatabaseResp struct {
	ID ID
}

type DeleteRelationReq

type DeleteRelationReq struct {
	DatabaseID   ID
	DatabaseName string
	Name         string
}

type DeleteRelationResp

type DeleteRelationResp struct {
	ID ID
}

type DeleteReq

type DeleteReq struct {
	TableID      ID
	DatabaseName string
	TableName    string
	ColumnName   string
	Vector       *vector.Vector
}

type DeleteResp

type DeleteResp struct {
}

type Engine

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

Engine is an engine.Engine impl

func New

func New(
	ctx context.Context,
	shardPolicy ShardPolicy,
	getClusterDetails engine.GetClusterDetailsFunc,
	idGenerator IDGenerator,
) *Engine

func (*Engine) Bind

func (e *Engine) Bind(txnOp client.TxnOperator) *BindedEngine

func (*Engine) Commit

func (e *Engine) Commit(_ context.Context, _ client.TxnOperator) error

func (*Engine) Create

func (e *Engine) Create(ctx context.Context, dbName string, txnOperator client.TxnOperator) error

func (*Engine) Database

func (e *Engine) Database(ctx context.Context, dbName string, txnOperator client.TxnOperator) (engine.Database, error)

func (*Engine) Databases

func (e *Engine) Databases(ctx context.Context, txnOperator client.TxnOperator) ([]string, error)

func (*Engine) Delete

func (e *Engine) Delete(ctx context.Context, dbName string, txnOperator client.TxnOperator) error

func (*Engine) GetNameById added in v0.7.0

func (e *Engine) GetNameById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, err error)

func (*Engine) GetRelationById added in v0.7.0

func (e *Engine) GetRelationById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, rel engine.Relation, err error)

func (*Engine) Hints

func (e *Engine) Hints() (h engine.Hints)

func (*Engine) New

func (*Engine) NewBlockReader

func (e *Engine) NewBlockReader(_ context.Context, _ int, _ timestamp.Timestamp,
	_ *plan.Expr, _ [][]byte, _ *plan.TableDef) ([]engine.Reader, error)

func (*Engine) NewCompilerContext

func (e *Engine) NewCompilerContext(
	ctx context.Context,
	defaultDB string,
	txnOp client.TxnOperator,
) *CompilerContext

func (*Engine) Nodes

func (e *Engine) Nodes() (engine.Nodes, error)

func (*Engine) Rollback

func (e *Engine) Rollback(_ context.Context, _ client.TxnOperator) error

type FallbackShard

type FallbackShard []ShardPolicy

func (FallbackShard) Batch

func (f FallbackShard) Batch(ctx context.Context, tableID ID, getDefs func(context.Context) ([]engine.TableDef, error), batch *batch.Batch, nodes []logservicepb.DNStore) (sharded []*ShardedBatch, err error)

func (FallbackShard) Vector

func (f FallbackShard) Vector(ctx context.Context, tableID ID, getDefs func(context.Context) ([]engine.TableDef, error), colName string, vec *vector.Vector, nodes []logservicepb.DNStore) (sharded []*ShardedVector, err error)

type GetDatabasesReq

type GetDatabasesReq struct {
	AccessInfo AccessInfo
}

type GetDatabasesResp

type GetDatabasesResp struct {
	Names []string
}

type GetHiddenKeysReq

type GetHiddenKeysReq struct {
	TableID ID
}

type GetHiddenKeysResp

type GetHiddenKeysResp struct {
	Attrs []*engine.Attribute
}

type GetPrimaryKeysReq

type GetPrimaryKeysReq struct {
	TableID ID
}

type GetPrimaryKeysResp

type GetPrimaryKeysResp struct {
	Attrs []*engine.Attribute
}

type GetRelationsReq

type GetRelationsReq struct {
	DatabaseID ID
}

type GetRelationsResp

type GetRelationsResp struct {
	Names []string
}

type GetTableColumnsReq

type GetTableColumnsReq struct {
	TableID ID
}

type GetTableColumnsResp

type GetTableColumnsResp struct {
	Attrs []*engine.Attribute
}

type GetTableDefsReq

type GetTableDefsReq struct {
	TableID ID
}

type GetTableDefsResp

type GetTableDefsResp struct {
	Defs []engine.TableDef
}

type HakeeperIDGenerator

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

func NewHakeeperIDGenerator

func NewHakeeperIDGenerator(
	generator hakeeperIDGenerator,
) *HakeeperIDGenerator

func (*HakeeperIDGenerator) NewID

func (h *HakeeperIDGenerator) NewID(ctx context.Context) (ID, error)

type HashShard

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

func NewHashShard

func NewHashShard(mp *mpool.MPool) *HashShard

func (*HashShard) Batch

func (*HashShard) Batch(
	ctx context.Context,
	tableID ID,
	getDefs getDefsFunc,
	bat *batch.Batch,
	nodes []logservicepb.DNStore,
) (
	sharded []*ShardedBatch,
	err error,
)

func (*HashShard) Vector

func (h *HashShard) Vector(
	ctx context.Context,
	tableID ID,
	getDefs getDefsFunc,
	colName string,
	vec *vector.Vector,
	nodes []logservicepb.DNStore,
) (
	sharded []*ShardedVector,
	err error,
)

type ID

type ID uint64

func (ID) IsEmpty

func (i ID) IsEmpty() bool

func (ID) Less

func (i ID) Less(than ID) bool

func (ID) ToRowID

func (i ID) ToRowID() types.Rowid

type IDGenerator

type IDGenerator interface {
	NewID(context.Context) (ID, error)
}

type IterInfo

type IterInfo struct {
	Shard  Shard
	IterID ID
}

type NewTableIterReq

type NewTableIterReq struct {
	TableID ID
	Expr    *plan.Expr
}

type NewTableIterResp

type NewTableIterResp struct {
	IterID ID
}

type NoShard

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

NoShard doesn't do sharding at all

func (*NoShard) Batch

func (s *NoShard) Batch(
	ctx context.Context,
	tableID ID,
	getDefs getDefsFunc,
	bat *batch.Batch,
	nodes []logservicepb.DNStore,
) (
	sharded []*ShardedBatch,
	err error,
)

func (*NoShard) Vector

func (s *NoShard) Vector(
	ctx context.Context,
	tableID ID,
	getDefs getDefsFunc,
	colName string,
	vec *vector.Vector,
	nodes []logservicepb.DNStore,
) (
	sharded []*ShardedVector,
	err error,
)

type Nullable

type Nullable struct {
	IsNull bool
	Value  any
}

type OpenDatabaseReq

type OpenDatabaseReq struct {
	AccessInfo AccessInfo
	Name       string
}

type OpenDatabaseResp

type OpenDatabaseResp struct {
	ID   ID
	Name string
}

type OpenRelationReq

type OpenRelationReq struct {
	DatabaseID   ID
	DatabaseName string
	Name         string
}

type OpenRelationResp

type OpenRelationResp struct {
	ID           ID
	Type         RelationType
	DatabaseName string
	RelationName string
}

type OperationHandler

type OperationHandler interface {
	HandleOpenDatabase(
		ctx context.Context,
		meta txn.TxnMeta,
		req OpenDatabaseReq,
		resp *OpenDatabaseResp,
	) error

	HandleGetDatabases(
		ctx context.Context,
		meta txn.TxnMeta,
		req GetDatabasesReq,
		resp *GetDatabasesResp,
	) error

	HandleOpenRelation(
		ctx context.Context,
		meta txn.TxnMeta,
		req OpenRelationReq,
		resp *OpenRelationResp,
	) error

	HandleGetRelations(
		ctx context.Context,
		meta txn.TxnMeta,
		req GetRelationsReq,
		resp *GetRelationsResp,
	) error

	HandleGetPrimaryKeys(
		ctx context.Context,
		meta txn.TxnMeta,
		req GetPrimaryKeysReq,
		resp *GetPrimaryKeysResp,
	) error

	HandleGetTableColumns(
		ctx context.Context,
		meta txn.TxnMeta,
		req GetTableColumnsReq,
		resp *GetTableColumnsResp,
	) error

	HandleGetTableDefs(
		ctx context.Context,
		meta txn.TxnMeta,
		req GetTableDefsReq,
		resp *GetTableDefsResp,
	) error

	HandleGetHiddenKeys(
		ctx context.Context,
		meta txn.TxnMeta,
		req GetHiddenKeysReq,
		resp *GetHiddenKeysResp,
	) error

	HandleNewTableIter(
		ctx context.Context,
		meta txn.TxnMeta,
		req NewTableIterReq,
		resp *NewTableIterResp,
	) error

	HandleRead(
		ctx context.Context,
		meta txn.TxnMeta,
		req ReadReq,
		resp *ReadResp,
	) error

	HandleCloseTableIter(
		ctx context.Context,
		meta txn.TxnMeta,
		req CloseTableIterReq,
		resp *CloseTableIterResp,
	) error

	HandleCreateDatabase(
		ctx context.Context,
		meta txn.TxnMeta,
		req CreateDatabaseReq,
		resp *CreateDatabaseResp,
	) error

	HandleDeleteDatabase(
		ctx context.Context,
		meta txn.TxnMeta,
		req DeleteDatabaseReq,
		resp *DeleteDatabaseResp,
	) error

	HandleCreateRelation(
		ctx context.Context,
		meta txn.TxnMeta,
		req CreateRelationReq,
		resp *CreateRelationResp,
	) error

	HandleDeleteRelation(
		ctx context.Context,
		meta txn.TxnMeta,
		req DeleteRelationReq,
		resp *DeleteRelationResp,
	) error

	HandleTruncateRelation(
		ctx context.Context,
		meta txn.TxnMeta,
		req TruncateRelationReq,
		resp *TruncateRelationResp,
	) error

	HandleAddTableDef(
		ctx context.Context,
		meta txn.TxnMeta,
		req AddTableDefReq,
		resp *AddTableDefResp,
	) error

	HandleDelTableDef(
		ctx context.Context,
		meta txn.TxnMeta,
		req DelTableDefReq,
		resp *DelTableDefResp,
	) error

	HandleDelete(
		ctx context.Context,
		meta txn.TxnMeta,
		req DeleteReq,
		resp *DeleteResp,
	) error

	HandleUpdate(
		ctx context.Context,
		meta txn.TxnMeta,
		req UpdateReq,
		resp *UpdateResp,
	) error

	HandleWrite(
		ctx context.Context,
		meta txn.TxnMeta,
		req WriteReq,
		resp *WriteResp,
	) error

	HandleTableStats(
		ctx context.Context,
		meta txn.TxnMeta,
		req TableStatsReq,
		resp *TableStatsResp,
	) error
}

type OperationHandlerProvider

type OperationHandlerProvider interface {
	GetOperationHandler(shard Shard) (OperationHandler, txn.TxnMeta)
}

type ReadReq

type ReadReq struct {
	IterID   ID
	ColNames []string
}

type ReadResp

type ReadResp struct {
	Batch *batch.Batch
	// contains filtered or unexported fields
}

func (*ReadResp) Close

func (r *ReadResp) Close() error

func (*ReadResp) SetHeap

func (r *ReadResp) SetHeap(mp *mpool.MPool)

type RelationType

type RelationType uint8
const (
	RelationTable RelationType = iota + 1
	RelationView
)

type Request

type Request interface {
	ReadRequest | WriteReqeust
}

type Shard

type Shard = metadata.DNShard

type ShardPolicy

type ShardPolicy interface {
	Vector(
		ctx context.Context,
		tableID ID,
		getDefs getDefsFunc,
		colName string,
		vec *vector.Vector,
		nodes []logservicepb.DNStore,
	) (
		sharded []*ShardedVector,
		err error,
	)

	Batch(
		ctx context.Context,
		tableID ID,
		getDefs getDefsFunc,
		batch *batch.Batch,
		nodes []logservicepb.DNStore,
	) (
		sharded []*ShardedBatch,
		err error,
	)
}

func NewDefaultShardPolicy

func NewDefaultShardPolicy(mp *mpool.MPool) ShardPolicy

type ShardedBatch

type ShardedBatch struct {
	Shard Shard
	Batch *batch.Batch
}

type ShardedVector

type ShardedVector struct {
	Shard  Shard
	Vector *vector.Vector
}

type Table

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

func (*Table) AddTableDef

func (t *Table) AddTableDef(ctx context.Context, def engine.TableDef) error

func (*Table) DelTableDef

func (t *Table) DelTableDef(ctx context.Context, def engine.TableDef) error

func (*Table) Delete

func (t *Table) Delete(ctx context.Context, bat *batch.Batch, colName string) error

func (*Table) GetHideKey

func (*Table) GetHideKey() *engine.Attribute

func (*Table) GetHideKeys

func (t *Table) GetHideKeys(ctx context.Context) (attrs []*engine.Attribute, err error)

func (*Table) GetLogTail

func (t *Table) GetLogTail(
	ctx context.Context,
	from *timestamp.Timestamp,
	to *timestamp.Timestamp,
	targetShard Shard,
) (
	resp *apipb.SyncLogTailResp,
	err error,
)

func (*Table) GetPriKeyOrHideKey

func (*Table) GetPriKeyOrHideKey() ([]engine.Attribute, bool)

func (*Table) GetPrimaryKeys

func (t *Table) GetPrimaryKeys(ctx context.Context) ([]*engine.Attribute, error)

func (*Table) GetTableID

func (t *Table) GetTableID(ctx context.Context) uint64

func (*Table) MaxAndMinValues added in v0.7.0

func (t *Table) MaxAndMinValues(ctx context.Context) ([][2]any, []uint8, error)

func (*Table) NewReader

func (t *Table) NewReader(
	ctx context.Context,
	parallel int,
	expr *plan.Expr,
	shardIDs [][]byte,
) (
	readers []engine.Reader,
	err error,
)

func (*Table) Ranges

func (t *Table) Ranges(ctx context.Context, _ *plan.Expr) ([][]byte, error)

func (*Table) Rows

func (t *Table) Rows(ctx context.Context) (int64, error)

func (*Table) Size

func (t *Table) Size(ctx context.Context, columnName string) (int64, error)

func (*Table) Stats added in v0.7.0

func (t *Table) Stats(ctx context.Context, e *plan2.Expr) (*plan.Stats, error)

func (*Table) TableColumns

func (t *Table) TableColumns(ctx context.Context) ([]*engine.Attribute, error)

func (*Table) TableDefs

func (t *Table) TableDefs(ctx context.Context) ([]engine.TableDef, error)

func (*Table) Update

func (t *Table) Update(ctx context.Context, data *batch.Batch) error

func (*Table) UpdateConstraint added in v0.7.0

func (t *Table) UpdateConstraint(context.Context, *engine.ConstraintDef) error

func (*Table) Write

func (t *Table) Write(ctx context.Context, data *batch.Batch) error

type TableReader

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

func (*TableReader) Close

func (t *TableReader) Close() error

func (*TableReader) Read

func (t *TableReader) Read(ctx context.Context, colNames []string, plan *plan.Expr, mp *mpool.MPool) (*batch.Batch, error)

type TableStatsReq

type TableStatsReq struct {
	TableID ID
}

type TableStatsResp

type TableStatsResp struct {
	Rows int
}

type TruncateRelationReq

type TruncateRelationReq struct {
	NewTableID   ID
	OldTableID   ID
	DatabaseID   ID
	DatabaseName string
	Name         string
}

type TruncateRelationResp

type TruncateRelationResp struct {
	ID ID
}

type UpdateReq

type UpdateReq struct {
	TableID      ID
	DatabaseName string
	TableName    string
	Batch        *batch.Batch
}

type UpdateResp

type UpdateResp struct {
}

type WriteReq

type WriteReq struct {
	TableID      ID
	DatabaseName string
	TableName    string
	Batch        *batch.Batch
}

type WriteResp

type WriteResp struct {
}

Jump to

Keyboard shortcuts

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