txnif

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UncommitTS = ^uint64(0)
)

Variables

View Source
var (
	ErrTxnInternal   = errors.New("tae txn: internal error")
	ErrTxnRWConflict = errors.New("tae txn: r-w conflict error")
	ErrTxnWWConflict = errors.New("tae txn: w-w conflict error")
)

Functions

func RegisterCmdFactory

func RegisterCmdFactory(cmdType int16, factory CmdFactory)

func TxnStrState

func TxnStrState(state TxnState) string

Types

type AppendNode

type AppendNode interface {
	TxnEntry
}

type CmdFactory

type CmdFactory func(int16) TxnCmd

func GetCmdFactory

func GetCmdFactory(cmdType int16) (factory CmdFactory)

type DeleteChain

type DeleteChain interface {
	sync.Locker
	RLock()
	RUnlock()
	// GetID() *common.ID
	RemoveNodeLocked(DeleteNode)

	AddNodeLocked(txn AsyncTxn, deleteType handle.DeleteType) DeleteNode
	AddMergeNode() DeleteNode

	PrepareRangeDelete(start, end uint32, ts uint64) error
	DepthLocked() int
	CollectDeletesLocked(ts uint64, collectIndex bool, rwlocker *sync.RWMutex) (DeleteNode, error)
}

type DeleteNode

type DeleteNode interface {
	TxnEntry
	StringLocked() string
	GetChain() DeleteChain
	RangeDeleteLocked(start, end uint32)
	GetCardinalityLocked() uint32
	IsDeletedLocked(row uint32) bool
	GetRowMaskRefLocked() *roaring.Bitmap
	OnApply() error
}

type SyncTxn

type SyncTxn interface {
	TxnReader
	TxnWriter
	TxnChanger
}

type Txn2PC

type Txn2PC interface {
	PrepareRollback() error
	ApplyRollback() error
	PreCommit() error
	PrepareCommit() error
	PreApplyCommit() error
	ApplyCommit() error
}

type TxnAsyncer

type TxnAsyncer interface {
	WaitDone(error) error
}

type TxnChanger

type TxnChanger interface {
	sync.Locker
	RLock()
	RUnlock()
	ToCommittedLocked() error
	ToCommittingLocked(ts uint64) error
	ToRollbackedLocked() error
	ToRollbackingLocked(ts uint64) error
	ToUnknownLocked()
	Commit() error
	Rollback() error
	SetError(error)
}

type TxnCmd

type TxnCmd interface {
	WriteTo(io.Writer) (int64, error)
	ReadFrom(io.Reader) (int64, error)
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	GetType() int16
	Desc() string
	String() string
	VerboseString() string
	Close()
}

type TxnEntry

type TxnEntry interface {
	sync.Locker
	RLock()
	RUnlock()
	PrepareCommit() error
	PrepareRollback() error
	ApplyCommit(index *wal.Index) error
	ApplyRollback() error
	MakeCommand(uint32) (TxnCmd, error)
}

type TxnEntryType

type TxnEntryType int16

type TxnHandle

type TxnHandle interface {
	CreateDatabase(name string) (handle.Database, error)
	DropDatabase(name string) (handle.Database, error)
	GetDatabase(name string) (handle.Database, error)
	DatabaseNames() []string
}

type TxnReader

type TxnReader interface {
	RLock()
	RUnlock()
	GetID() uint64
	GetCtx() []byte
	GetStartTS() uint64
	GetCommitTS() uint64
	GetInfo() []byte
	IsTerminated(bool) bool
	IsVisible(o TxnReader) bool
	GetTxnState(waitIfcommitting bool) TxnState
	GetError() error
	GetStore() TxnStore
	String() string
	Repr() string
	GetLSN() uint64

	SameTxn(startTs uint64) bool
	CommitBefore(startTs uint64) bool
	CommitAfter(startTs uint64) bool
}

type TxnState

type TxnState int32
const (
	TxnStateActive TxnState = iota
	TxnStateCommitting
	TxnStateRollbacking
	TxnStateCommitted
	TxnStateRollbacked
	TxnStateUnknown
)

type TxnStore

type TxnStore interface {
	Txn2PC
	io.Closer
	BindTxn(AsyncTxn)
	GetLSN() uint64

	BatchDedup(dbId, id uint64, pks ...containers.Vector) error
	LogSegmentID(dbId, tid, sid uint64)
	LogBlockID(dbId, tid, bid uint64)

	Append(dbId, id uint64, data *containers.Batch) error

	RangeDelete(dbId uint64, id *common.ID, start, end uint32, dt handle.DeleteType) error
	Update(dbId uint64, id *common.ID, row uint32, col uint16, v any) error
	GetByFilter(dbId uint64, id uint64, filter *handle.Filter) (*common.ID, uint32, error)
	GetValue(dbId uint64, id *common.ID, row uint32, col uint16) (any, error)

	CreateRelation(dbId uint64, def any) (handle.Relation, error)
	DropRelationByName(dbId uint64, name string) (handle.Relation, error)
	GetRelationByName(dbId uint64, name string) (handle.Relation, error)

	CreateDatabase(name string) (handle.Database, error)
	GetDatabase(name string) (handle.Database, error)
	DropDatabase(name string) (handle.Database, error)
	DatabaseNames() []string

	GetSegment(dbId uint64, id *common.ID) (handle.Segment, error)
	CreateSegment(dbId, tid uint64) (handle.Segment, error)
	CreateNonAppendableSegment(dbId, tid uint64) (handle.Segment, error)
	CreateBlock(dbId, tid, sid uint64) (handle.Block, error)
	GetBlock(dbId uint64, id *common.ID) (handle.Block, error)
	CreateNonAppendableBlock(dbId uint64, id *common.ID) (handle.Block, error)
	SoftDeleteSegment(dbId uint64, id *common.ID) error
	SoftDeleteBlock(dbId uint64, id *common.ID) error

	AddTxnEntry(TxnEntryType, TxnEntry)

	LogTxnEntry(dbId, tableId uint64, entry TxnEntry, readed []*common.ID) error

	IsReadonly() bool
	IncreateWriteCnt() int
}

type TxnTest

type TxnTest interface {
	MockSetCommitTSLocked(ts uint64)
	MockIncWriteCnt() int
	SetPrepareCommitFn(func(AsyncTxn) error)
	SetPrepareRollbackFn(func(AsyncTxn) error)
	SetApplyCommitFn(func(AsyncTxn) error)
	SetApplyRollbackFn(func(AsyncTxn) error)
}

type TxnWriter

type TxnWriter interface {
	LogTxnEntry(dbId, tableId uint64, entry TxnEntry, readed []*common.ID) error
}

type UpdateChain

type UpdateChain interface {
	sync.Locker
	RLock()
	RUnlock()
	GetID() *common.ID

	DeleteNode(*common.DLNode)
	DeleteNodeLocked(*common.DLNode)

	AddNode(txn AsyncTxn) UpdateNode
	AddNodeLocked(txn AsyncTxn) UpdateNode
	PrepareUpdate(uint32, UpdateNode) error

	GetValueLocked(row uint32, ts uint64) (any, error)
	TryUpdateNodeLocked(row uint32, v any, n UpdateNode) error
}

type UpdateNode

type UpdateNode interface {
	TxnEntry
	GetID() *common.ID
	String() string
	GetChain() UpdateChain
	GetDLNode() *common.DLNode
	GetMask() *roaring.Bitmap
	GetValues() map[uint32]interface{}

	UpdateLocked(row uint32, v any) error
}

Jump to

Keyboard shortcuts

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