db

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

Documentation

Index

Constants

View Source
const (
	WALDir     = "wal"
	CATALOGDir = "catalog"
)
View Source
const (
	OpPreCommit  = uint32(apipb.OpCode_OpPreCommit)
	OpGetLogTail = uint32(apipb.OpCode_OpGetLogTail)
)
View Source
const (
	InspectNormal = 0
	InspectCata   = 1
)
View Source
const (
	LockName string = "TAE"
)

Variables

View Source
var (
	ErrTaskDuplicated = moerr.NewInternalErrorNoCtx("tae task: duplicated task found")
	ErrTaskNotFound   = moerr.NewInternalErrorNoCtx("tae task: task not found")
)
View Source
var (
	ErrClosed = moerr.NewInternalErrorNoCtx("tae: closed")
)

Functions

func MakeBlockScopes

func MakeBlockScopes(entries ...*catalog.BlockEntry) (scopes []common.ID)

func MakeDBScopes

func MakeDBScopes(entry *catalog.DBEntry) (scopes []common.ID)

func MakeSegmentScopes

func MakeSegmentScopes(entries ...*catalog.SegmentEntry) (scopes []common.ID)

func MakeTableScopes

func MakeTableScopes(entries ...*catalog.TableEntry) (scopes []common.ID)

func NewDBScanner

func NewDBScanner(db *DB, errHandler ErrHandler) *dbScanner

func ScopeConflictCheck

func ScopeConflictCheck(oldScope, newScope *common.ID) (err error)

Types

type AccessInfo added in v0.6.0

type AccessInfo struct {
	AccountID uint32
	UserID    uint32
	RoleID    uint32
}

type CatalogResp added in v0.7.0

type CatalogResp struct {
	Item string         `json:"Item,omitempty"`
	Sub  []*CatalogResp `json:"Sub,omitempty"`
}

type Checkpoint added in v0.7.0

type Checkpoint struct {
	FlushDuration time.Duration
}

type CreateDatabaseReq added in v0.6.0

type CreateDatabaseReq struct {
	AccessInfo AccessInfo
	Name       string
	CreateSql  string
	//Global unique, allocated by CN .
	DatabaseId uint64
}

type CreateDatabaseResp added in v0.6.0

type CreateDatabaseResp struct {
	ID uint64
}

type CreateRelationReq added in v0.6.0

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

type CreateRelationResp added in v0.6.0

type CreateRelationResp struct {
	ID uint64
}

type DB

type DB struct {
	Dir  string
	Opts *options.Options

	Catalog *catalog.Catalog

	MTBufMgr  base.INodeManager
	TxnBufMgr base.INodeManager

	TxnMgr        *txnbase.TxnManager
	TransferTable *model.HashPageTable

	LogtailMgr *logtail.Manager
	Wal        wal.Driver

	Scheduler tasks.TaskScheduler

	GCManager *gc.Manager

	BGScanner          wb.IHeartbeater
	BGCheckpointRunner checkpoint.Runner

	DiskCleaner *gc2.DiskCleaner

	Fs *objectio.ObjectFS

	DBLocker io.Closer

	Closed *atomic.Value
}

func Open

func Open(dirname string, opts *options.Options) (db *DB, err error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) CollectStats

func (db *DB) CollectStats() *Stats

func (*DB) CommitTxn

func (db *DB) CommitTxn(txn txnif.AsyncTxn) (err error)

func (*DB) FlushTable added in v0.6.0

func (db *DB) FlushTable(
	tenantID uint32,
	dbId, tableId uint64,
	ts types.TS) (err error)

func (*DB) GetOrCreateTxnWithMeta added in v0.6.0

func (db *DB) GetOrCreateTxnWithMeta(
	info []byte,
	id []byte,
	ts types.TS) (txn txnif.AsyncTxn, err error)

func (*DB) GetTxn

func (db *DB) GetTxn(id string) (txn txnif.AsyncTxn, err error)

func (*DB) GetTxnByCtx

func (db *DB) GetTxnByCtx(txnOperator client.TxnOperator) (txn txnif.AsyncTxn, err error)

func (*DB) PrintStats

func (db *DB) PrintStats()

func (*DB) Replay

func (db *DB) Replay(dataFactory *tables.DataFactory, maxTs types.TS)

func (*DB) RollbackTxn

func (db *DB) RollbackTxn(txn txnif.AsyncTxn) error

func (*DB) StartTxn

func (db *DB) StartTxn(info []byte) (txnif.AsyncTxn, error)

type DBScanner

type DBScanner interface {
	base.IHBHandle
	RegisterOp(ScannerOp)
}

type DropDatabaseReq added in v0.6.0

type DropDatabaseReq struct {
	Name string
	ID   uint64
}

type DropDatabaseResp added in v0.6.0

type DropDatabaseResp struct {
	ID uint64
}

type DropOrTruncateRelationReq added in v0.6.0

type DropOrTruncateRelationReq struct {
	IsDrop       bool
	DatabaseID   uint64
	DatabaseName string
	Name         string
	ID           uint64
	NewId        uint64
}

type DropOrTruncateRelationResp added in v0.6.0

type DropOrTruncateRelationResp struct {
}

type EntryType added in v0.6.0

type EntryType int32
const (
	EntryInsert EntryType = 0
	EntryDelete EntryType = 1
)

type ErrHandler

type ErrHandler interface {
	OnBlockErr(entry *catalog.BlockEntry, err error) error
	OnSegmentErr(entry *catalog.SegmentEntry, err error) error
	OnTableErr(entry *catalog.TableEntry, err error) error
	OnDatabaseErr(entry *catalog.DBEntry, err error) error
}

type FlushTable added in v0.6.0

type FlushTable struct {
	AccessInfo AccessInfo
	DatabaseID uint64
	TableID    uint64
}

type InspectDN added in v0.7.0

type InspectDN struct {
	AccessInfo AccessInfo
	Operation  string
}

type InspectResp added in v0.7.0

type InspectResp struct {
	Typ     int    `json:"-"`
	Message string `json:"msg"`
	Payload []byte `json:"-"`
}

func (*InspectResp) GetResponse added in v0.7.0

func (r *InspectResp) GetResponse() any

type LocationKey added in v0.7.0

type LocationKey struct{}

type MergeTaskBuilder added in v0.7.0

type MergeTaskBuilder struct {
	*catalog.LoopProcessor
	// contains filtered or unexported fields
}

func (*MergeTaskBuilder) PostExecute added in v0.7.0

func (s *MergeTaskBuilder) PostExecute() error

func (*MergeTaskBuilder) PreExecute added in v0.7.0

func (s *MergeTaskBuilder) PreExecute() error

type NoopErrHandler

type NoopErrHandler struct{}

func (*NoopErrHandler) OnBlockErr

func (h *NoopErrHandler) OnBlockErr(entry *catalog.BlockEntry, err error) error

func (*NoopErrHandler) OnDatabaseErr

func (h *NoopErrHandler) OnDatabaseErr(entry *catalog.DBEntry, err error) error

func (*NoopErrHandler) OnSegmentErr

func (h *NoopErrHandler) OnSegmentErr(entry *catalog.SegmentEntry, err error) error

func (*NoopErrHandler) OnTableErr

func (h *NoopErrHandler) OnTableErr(entry *catalog.TableEntry, err error) error

type RelationType added in v0.6.0

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

type Replayer

type Replayer struct {
	DataFactory *tables.DataFactory
	// contains filtered or unexported fields
}

func (*Replayer) GetMaxTS

func (replayer *Replayer) GetMaxTS() types.TS

func (*Replayer) OnReplayEntry

func (replayer *Replayer) OnReplayEntry(group uint32, lsn uint64, payload []byte, typ uint16, info any)

func (*Replayer) OnReplayTxn added in v0.6.0

func (replayer *Replayer) OnReplayTxn(cmd txnif.TxnCmd, walIdx *wal.Index, lsn uint64)

func (*Replayer) OnStaleIndex

func (replayer *Replayer) OnStaleIndex(idx *wal.Index)

func (*Replayer) OnTimeStamp

func (replayer *Replayer) OnTimeStamp(ts types.TS)

func (*Replayer) PreReplayWal

func (replayer *Replayer) PreReplayWal()

func (*Replayer) Replay

func (replayer *Replayer) Replay()

type ScannerOp

type ScannerOp interface {
	catalog.Processor
	PreExecute() error
	PostExecute() error
}

type ScheduledTxnTask

type ScheduledTxnTask struct {
	*tasks.BaseTask
	// contains filtered or unexported fields
}

func NewScheduledTxnTask

func NewScheduledTxnTask(ctx *tasks.Context, db *DB, taskType tasks.TaskType, scopes []common.ID, factory tasks.TxnTaskFactory) (task *ScheduledTxnTask)

func (*ScheduledTxnTask) Execute

func (task *ScheduledTxnTask) Execute() (err error)

func (*ScheduledTxnTask) Scope

func (task *ScheduledTxnTask) Scope() *common.ID

func (*ScheduledTxnTask) Scopes

func (task *ScheduledTxnTask) Scopes() []common.ID

type Stats

type Stats struct {
	WalStats *WalStats
	// contains filtered or unexported fields
}

func NewStats

func NewStats(db *DB) *Stats

func (*Stats) Collect

func (stats *Stats) Collect()

func (*Stats) ToString

func (stats *Stats) ToString(prefix string) string

type UpdateConstraintReq added in v0.7.0

type UpdateConstraintReq struct {
	TableId      uint64
	TableName    string
	DatabaseId   uint64
	DatabaseName string
	Constraint   []byte
}

type UpdateConstraintResp added in v0.7.0

type UpdateConstraintResp struct{}

type WalStats

type WalStats struct {
	MaxLSN     uint64
	MaxCkped   uint64
	PendingCnt uint64
}

func CollectWalStats

func CollectWalStats(w wal.Driver) *WalStats

type WriteReq added in v0.6.0

type WriteReq struct {
	Type         EntryType
	DatabaseId   uint64
	TableID      uint64
	DatabaseName string
	TableName    string
	Schema       *catalog2.Schema
	Batch        *batch.Batch
	//S3 object file name
	FileName string
	MetaLocs []string
	//for delete on S3
	DeltaLocs []string
	//tasks for loading primary keys or deleted row ids
	Jobs []*tasks.Job
	//loaded sorted primary keys or deleted row ids.
	JobRes []*tasks.JobResult
	//load context cancel function
	Cancel context.CancelFunc
}

type WriteResp added in v0.6.0

type WriteResp struct {
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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