catalog

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

Documentation

Index

Constants

View Source
const (
	CmdCreateDatabase = int16(256) + iota
	CmdDropDatabase
	CmdCreateTable
	CmdDropTable
	CmdCreateSegment
	CmdDropSegment
	CmdCreateBlock
	CmdDropBlock
	CmdLogDatabase
	CmdLogTable
	CmdLogSegment
	CmdLogBlock
)
View Source
const (
	HiddenColumnName    = "PADDR"
	HiddenColumnComment = "Physical address"
	SortKeyNamePrefx    = "_SORT_"

	SystemDBID               = uint64(1)
	SystemDBName             = "mo_catalog"
	CatalogName              = "taec"
	SystemTable_DB_Name      = "mo_database"
	SystemTable_Table_Name   = "mo_tables"
	SystemTable_Columns_Name = "mo_columns"
	SystemTable_DB_ID        = uint64(1)
	SystemTable_Table_ID     = uint64(2)
	SystemTable_Columns_ID   = uint64(3)
	SystemSegment_DB_ID      = uint64(101)
	SystemSegment_Table_ID   = uint64(102)
	SystemSegment_Columns_ID = uint64(103)
	SystemBlock_DB_ID        = uint64(201)
	SystemBlock_Table_ID     = uint64(202)
	SystemBlock_Columns_ID   = uint64(203)

	SystemCatalogName  = "def"
	SystemPersistRel   = "p"
	SystemTransientRel = "t"

	SystemOrdinaryRel     = "r"
	SystemIndexRel        = "i"
	SystemSequenceRel     = "S"
	SystemViewRel         = "v"
	SystemMaterializedRel = "m"

	SystemColPKConstraint = "p"
	SystemColNoConstraint = "n"
)
View Source
const (
	SystemDBAttr_Name        = "datname"
	SystemDBAttr_CatalogName = "dat_catalog_name"
	SystemDBAttr_CreateSQL   = "dat_createsql"

	SystemRelAttr_Name        = "relname"
	SystemRelAttr_DBName      = "reldatabase"
	SystemRelAttr_Persistence = "relpersistence"
	SystemRelAttr_Kind        = "relkind"
	SystemRelAttr_Comment     = "rel_comment"
	SystemRelAttr_CreateSQL   = "rel_createsql"

	SystemColAttr_Name            = "attname"
	SystemColAttr_DBName          = "att_database"
	SystemColAttr_RelName         = "att_relname"
	SystemColAttr_Type            = "atttyp"
	SystemColAttr_Num             = "attnum"
	SystemColAttr_Length          = "att_length"
	SystemColAttr_NullAbility     = "attnotnull"
	SystemColAttr_HasExpr         = "atthasdef"
	SystemColAttr_DefaultExpr     = "att_default"
	SystemColAttr_IsDropped       = "attisdropped"
	SystemColAttr_ConstraintType  = "att_constraint_type"
	SystemColAttr_IsUnsigned      = "att_is_unsigned"
	SystemColAttr_IsAutoIncrement = "att_is_auto_increment"
	SystemColAttr_IsHidden        = "att_is_hidden"
	SystemColAttr_Comment         = "att_comment"
)
View Source
const (
	ModelSchemaName   = "_ModelSchema"
	ModelAttrET       = "ET"
	ModelAttrID       = "ID"
	ModelAttrName     = "NAME"
	ModelAttrTS       = "TS"
	ModelAttrOpT      = "OPT"
	ModelAttrLogIdx   = "LOGIDX"
	ModelAttrInfo     = "INFO"
	ModelAttrParentID = "PARENTID"
)
View Source
const DefaultReplayCacheSize = 2 * common.M
View Source
const (
	ETCatalogCheckpoint = entry.ETCustomizedStart + 100 + iota
)

Variables

View Source
var (
	ErrNotFound     = errors.New("tae catalog: not found")
	ErrDuplicate    = errors.New("tae catalog: duplicate")
	ErrCheckpoint   = errors.New("tae catalog: checkpoint")
	ErrNotPermitted = errors.New("tae catalog: operation not permitted")

	ErrSchemaValidation = errors.New("tae catalog: schema validation")

	ErrStopCurrRecur = errors.New("tae catalog: stop current recursion")
)
View Source
var EmptyCheckpoint = new(Checkpoint)
View Source
var (
	HiddenColumnType types.Type
)
View Source
var OpNames = map[OpT]string{
	OpCreate:     "Create",
	OpUpdate:     "Update",
	OpSoftDelete: "SoftDelete",
	OpHardDelete: "HardDelete",
}

Functions

func ActiveWithNoTxnFilter

func ActiveWithNoTxnFilter(be *BaseEntry) bool

func AppendableBlkFilter

func AppendableBlkFilter(be *BlockEntry) bool

func CheckpointOp

func CheckpointOp(ckpEntry *CheckpointEntry, entry *BaseEntry, item CheckpointItem, minTs, maxTs uint64)

func CheckpointSelectOp

func CheckpointSelectOp(entry *BaseEntry, minTs, maxTs uint64) bool

func CmdName

func CmdName(t int16) string

func CompareUint64

func CompareUint64(left, right uint64) int

func EstimateBlockSize

func EstimateBlockSize(meta *BlockEntry, rows uint32) uint32

func EstimateColumnBlockSize

func EstimateColumnBlockSize(colIdx int, rows uint32, meta *BlockEntry) uint32

func GetAttrIdx

func GetAttrIdx(attrs []string, name string) int

func MarshalDefault

func MarshalDefault(w *bytes.Buffer, typ types.Type, data Default) (err error)

func MockBatch

func MockBatch(schema *Schema, rows int) *containers.Batch

func MockTxnFactory

func MockTxnFactory(catalog *Catalog) txnbase.TxnFactory

func MockTxnStoreFactory

func MockTxnStoreFactory(catalog *Catalog) txnbase.TxnStoreFactory

func NonAppendableBlkFilter

func NonAppendableBlkFilter(be *BlockEntry) bool

func OpName

func OpName(op OpT) string

func UnMarshalDefault

func UnMarshalDefault(r io.Reader, typ types.Type, data *Default) (n int64, err error)

Types

type BaseEntry

type BaseEntry struct {
	*sync.RWMutex
	CommitInfo
	PrevCommit         *CommitInfo
	ID                 uint64
	CreateAt, DeleteAt uint64
}

func NewReplayBaseEntry

func NewReplayBaseEntry() *BaseEntry

func (*BaseEntry) ApplyCommit

func (be *BaseEntry) ApplyCommit(index *wal.Index) error

func (*BaseEntry) ApplyDeleteCmd

func (be *BaseEntry) ApplyDeleteCmd(ts uint64, index *wal.Index) error

func (*BaseEntry) ApplyRollback

func (be *BaseEntry) ApplyRollback() error

func (*BaseEntry) Clone

func (be *BaseEntry) Clone() *BaseEntry

func (*BaseEntry) CloneCreate

func (be *BaseEntry) CloneCreate() *BaseEntry

func (*BaseEntry) CreateAfter

func (be *BaseEntry) CreateAfter(ts uint64) bool

func (*BaseEntry) CreateAndDropInSameTxn

func (be *BaseEntry) CreateAndDropInSameTxn() bool

func (*BaseEntry) CreateBefore

func (be *BaseEntry) CreateBefore(ts uint64) bool

func (*BaseEntry) DeleteAfter

func (be *BaseEntry) DeleteAfter(ts uint64) bool

func (*BaseEntry) DeleteBefore

func (be *BaseEntry) DeleteBefore(ts uint64) bool

func (*BaseEntry) DoCompre

func (be *BaseEntry) DoCompre(oe *BaseEntry) int

func (*BaseEntry) DropEntryLocked

func (be *BaseEntry) DropEntryLocked(txnCtx txnif.TxnReader) error

func (*BaseEntry) GetID

func (be *BaseEntry) GetID() uint64

func (*BaseEntry) GetLogIndex

func (be *BaseEntry) GetLogIndex() *wal.Index

func (*BaseEntry) GetTxn

func (be *BaseEntry) GetTxn() txnif.TxnReader

func (*BaseEntry) GetTxnID

func (be *BaseEntry) GetTxnID() uint64

func (*BaseEntry) HasActiveTxn

func (be *BaseEntry) HasActiveTxn() bool

func (*BaseEntry) HasCreated

func (be *BaseEntry) HasCreated() bool

func (*BaseEntry) HasDropped

func (be *BaseEntry) HasDropped() bool

func (*BaseEntry) InTxnOrRollbacked

func (be *BaseEntry) InTxnOrRollbacked() bool

func (*BaseEntry) IsCommitted

func (be *BaseEntry) IsCommitted() bool

func (*BaseEntry) IsCommitting

func (be *BaseEntry) IsCommitting() bool

func (*BaseEntry) IsCreatedUncommitted

func (be *BaseEntry) IsCreatedUncommitted() bool

func (*BaseEntry) IsDroppedCommitted

func (be *BaseEntry) IsDroppedCommitted() bool

func (*BaseEntry) IsDroppedUncommitted

func (be *BaseEntry) IsDroppedUncommitted() bool

func (*BaseEntry) IsSameTxn

func (be *BaseEntry) IsSameTxn(ctx txnif.TxnReader) bool

func (*BaseEntry) IsTerminated

func (be *BaseEntry) IsTerminated(waitIfcommitting bool) bool

func (*BaseEntry) MaxCommittedTS

func (be *BaseEntry) MaxCommittedTS() uint64

func (*BaseEntry) PrepareCommit

func (be *BaseEntry) PrepareCommit() error

func (*BaseEntry) PrepareRollback

func (be *BaseEntry) PrepareRollback() error

func (*BaseEntry) PrepareWrite

func (be *BaseEntry) PrepareWrite(txn txnif.TxnReader, rwlocker *sync.RWMutex) (err error)

func (*BaseEntry) ReadFrom

func (be *BaseEntry) ReadFrom(r io.Reader) (n int64, err error)

func (*BaseEntry) SameTxn

func (be *BaseEntry) SameTxn(o *BaseEntry) bool

func (*BaseEntry) String

func (be *BaseEntry) String() string

func (*BaseEntry) TxnCanRead

func (be *BaseEntry) TxnCanRead(txn txnif.AsyncTxn, rwlocker *sync.RWMutex) (ok bool, err error)

func (*BaseEntry) WriteTo

func (be *BaseEntry) WriteTo(w io.Writer) (n int64, err error)

type BlockDataFactory

type BlockDataFactory = func(meta *BlockEntry) data.Block

type BlockEntry

type BlockEntry struct {
	*BaseEntry
	// contains filtered or unexported fields
}

func NewBlockEntry

func NewBlockEntry(segment *SegmentEntry, txn txnif.AsyncTxn, state EntryState, dataFactory BlockDataFactory) *BlockEntry

func NewReplayBlockEntry

func NewReplayBlockEntry() *BlockEntry

func NewStandaloneBlock

func NewStandaloneBlock(segment *SegmentEntry, id uint64, ts uint64) *BlockEntry

func NewSysBlockEntry

func NewSysBlockEntry(segment *SegmentEntry, id uint64) *BlockEntry

func (*BlockEntry) AsCommonID

func (entry *BlockEntry) AsCommonID() *common.ID

func (*BlockEntry) Clone

func (entry *BlockEntry) Clone() CheckpointItem

func (*BlockEntry) CloneCreate

func (entry *BlockEntry) CloneCreate() CheckpointItem

func (*BlockEntry) Compare

func (entry *BlockEntry) Compare(o common.NodePayload) int

func (*BlockEntry) DestroyData

func (entry *BlockEntry) DestroyData() (err error)

func (*BlockEntry) GetBlockData

func (entry *BlockEntry) GetBlockData() data.Block

func (*BlockEntry) GetCatalog

func (entry *BlockEntry) GetCatalog() *Catalog

func (*BlockEntry) GetFileTs

func (entry *BlockEntry) GetFileTs() (uint64, error)

func (*BlockEntry) GetSchema

func (entry *BlockEntry) GetSchema() *Schema

func (*BlockEntry) GetSegment

func (entry *BlockEntry) GetSegment() *SegmentEntry

func (*BlockEntry) GetTerminationTS

func (entry *BlockEntry) GetTerminationTS() (ts uint64, terminated bool)

GetTerminationTS is coarse API: no consistency check

func (*BlockEntry) InitData

func (entry *BlockEntry) InitData(factory DataFactory)

func (*BlockEntry) IsActive

func (entry *BlockEntry) IsActive() bool

IsActive is coarse API: no consistency check

func (*BlockEntry) IsAppendable

func (entry *BlockEntry) IsAppendable() bool

func (*BlockEntry) MakeCommand

func (entry *BlockEntry) MakeCommand(id uint32) (cmd txnif.TxnCmd, err error)

func (*BlockEntry) MakeKey

func (entry *BlockEntry) MakeKey() []byte

func (*BlockEntry) MakeLogEntry

func (entry *BlockEntry) MakeLogEntry() *EntryCommand

func (*BlockEntry) PPString

func (entry *BlockEntry) PPString(level common.PPLevel, depth int, prefix string) string

func (*BlockEntry) PrepareRollback

func (entry *BlockEntry) PrepareRollback() (err error)

func (*BlockEntry) ReadFrom

func (entry *BlockEntry) ReadFrom(r io.Reader) (n int64, err error)

func (*BlockEntry) Repr

func (entry *BlockEntry) Repr() string

func (*BlockEntry) String

func (entry *BlockEntry) String() string

func (*BlockEntry) StringLocked

func (entry *BlockEntry) StringLocked() string

func (*BlockEntry) WriteTo

func (entry *BlockEntry) WriteTo(w io.Writer) (n int64, err error)

type Catalog

type Catalog struct {
	*IDAlloctor
	*sync.RWMutex
	// contains filtered or unexported fields
}

func MockCatalog

func MockCatalog(dir, name string, cfg *store.StoreCfg, scheduler tasks.TaskScheduler) *Catalog

func OpenCatalog

func OpenCatalog(dir, name string, cfg *store.StoreCfg, scheduler tasks.TaskScheduler, dataFactory DataFactory) (*Catalog, error)

func (*Catalog) AddColumnCnt

func (catalog *Catalog) AddColumnCnt(cnt int)

func (*Catalog) AddEntryLocked

func (catalog *Catalog) AddEntryLocked(database *DBEntry) error

func (*Catalog) AddTableCnt

func (catalog *Catalog) AddTableCnt(cnt int)

func (*Catalog) Checkpoint

func (catalog *Catalog) Checkpoint(maxTs uint64) (err error)

func (*Catalog) CheckpointClosure

func (catalog *Catalog) CheckpointClosure(maxTs uint64) tasks.FuncT

func (*Catalog) Close

func (catalog *Catalog) Close() error

func (*Catalog) CoarseColumnCnt

func (catalog *Catalog) CoarseColumnCnt() int

func (*Catalog) CoarseDBCnt

func (catalog *Catalog) CoarseDBCnt() int

func (*Catalog) CoarseTableCnt

func (catalog *Catalog) CoarseTableCnt() int

func (*Catalog) CreateDBEntry

func (catalog *Catalog) CreateDBEntry(name string, txnCtx txnif.AsyncTxn) (*DBEntry, error)

func (*Catalog) DropDBEntry

func (catalog *Catalog) DropDBEntry(name string, txnCtx txnif.AsyncTxn) (deleted *DBEntry, err error)

func (*Catalog) GetCheckpointed

func (catalog *Catalog) GetCheckpointed() *Checkpoint

func (*Catalog) GetDBEntry

func (catalog *Catalog) GetDBEntry(name string, txnCtx txnif.AsyncTxn) (*DBEntry, error)

func (*Catalog) GetDatabaseByID

func (catalog *Catalog) GetDatabaseByID(id uint64) (db *DBEntry, err error)

func (*Catalog) GetScheduler

func (catalog *Catalog) GetScheduler() tasks.TaskScheduler

func (*Catalog) GetStore

func (catalog *Catalog) GetStore() store.Store

func (*Catalog) InitSystemDB

func (catalog *Catalog) InitSystemDB()

func (*Catalog) MakeDBIt

func (catalog *Catalog) MakeDBIt(reverse bool) *common.LinkIt

func (*Catalog) PPString

func (catalog *Catalog) PPString(level common.PPLevel, depth int, prefix string) string

func (*Catalog) PrepareCheckpoint

func (catalog *Catalog) PrepareCheckpoint(startTs, endTs uint64) *CheckpointEntry

func (*Catalog) RecurLoop

func (catalog *Catalog) RecurLoop(processor Processor) (err error)

func (*Catalog) RemoveEntry

func (catalog *Catalog) RemoveEntry(database *DBEntry) error

func (*Catalog) ReplayCmd

func (catalog *Catalog) ReplayCmd(txncmd txnif.TxnCmd, dataFactory DataFactory, idxCtx *wal.Index, observer wal.ReplayObserver, cache *bytes.Buffer)

func (*Catalog) ReplayTableRows

func (catalog *Catalog) ReplayTableRows()

func (*Catalog) SimplePPString

func (catalog *Catalog) SimplePPString(level common.PPLevel) string

type Checkpoint

type Checkpoint struct {
	MaxTS    uint64
	LSN      uint64
	CommitId uint64
}

func (*Checkpoint) String

func (ckp *Checkpoint) String() string

type CheckpointEntry

type CheckpointEntry struct {
	MinTS, MaxTS uint64
	LogIndexes   []*wal.Index
	MaxIndex     wal.Index
	Entries      []*EntryCommand
}

func NewCheckpointEntry

func NewCheckpointEntry(minTs, maxTs uint64) *CheckpointEntry

func NewEmptyCheckpointEntry

func NewEmptyCheckpointEntry() *CheckpointEntry

func (*CheckpointEntry) AddCommand

func (e *CheckpointEntry) AddCommand(cmd *EntryCommand)

func (*CheckpointEntry) AddIndex

func (e *CheckpointEntry) AddIndex(index *wal.Index)

func (*CheckpointEntry) GetMaxIndex

func (e *CheckpointEntry) GetMaxIndex() *wal.Index

func (*CheckpointEntry) MakeLogEntry

func (e *CheckpointEntry) MakeLogEntry() (logEntry LogEntry, err error)

func (*CheckpointEntry) Marshal

func (e *CheckpointEntry) Marshal() (buf []byte, err error)

func (*CheckpointEntry) PrintItems

func (e *CheckpointEntry) PrintItems()

func (*CheckpointEntry) Unmarshal

func (e *CheckpointEntry) Unmarshal(buf []byte) (err error)

type CheckpointItem

type CheckpointItem interface {
	Clone() CheckpointItem
	CloneCreate() CheckpointItem
	MakeLogEntry() *EntryCommand
	StringLocked() string
}

type ColDef

type ColDef struct {
	Name          string
	Idx           int
	Type          types.Type
	Hidden        int8
	NullAbility   int8
	AutoIncrement int8
	SortIdx       int8
	SortKey       int8
	Primary       int8
	Comment       string
	Default       Default
}

func (*ColDef) GetName

func (def *ColDef) GetName() string

func (*ColDef) GetType

func (def *ColDef) GetType() types.Type

func (*ColDef) IsHidden

func (def *ColDef) IsHidden() bool

func (*ColDef) IsPrimary

func (def *ColDef) IsPrimary() bool

func (*ColDef) IsSortKey

func (def *ColDef) IsSortKey() bool

func (*ColDef) Nullable

func (def *ColDef) Nullable() bool

type CommitInfo

type CommitInfo struct {
	CurrOp   OpT
	Txn      txnif.TxnReader
	LogIndex *wal.Index
}

func (*CommitInfo) Clone

func (info *CommitInfo) Clone() *CommitInfo

func (*CommitInfo) ReadFrom

func (info *CommitInfo) ReadFrom(r io.Reader) (n int64, err error)

func (*CommitInfo) WriteTo

func (info *CommitInfo) WriteTo(w io.Writer) (n int64, err error)

type ComposedFilter

type ComposedFilter struct {
	CommitFilters []func(*BaseEntry) bool
	BlockFilters  []func(*BlockEntry) bool
}

func NewComposedFilter

func NewComposedFilter() *ComposedFilter

func (*ComposedFilter) AddBlockFilter

func (filter *ComposedFilter) AddBlockFilter(f func(*BlockEntry) bool)

func (*ComposedFilter) AddCommitFilter

func (filter *ComposedFilter) AddCommitFilter(f func(*BaseEntry) bool)

func (*ComposedFilter) FilteBlock

func (filter *ComposedFilter) FilteBlock(be *BlockEntry) bool

func (*ComposedFilter) FilteCommit

func (filter *ComposedFilter) FilteCommit(be *BaseEntry) bool

type DBEntry

type DBEntry struct {
	// *BaseEntry
	*BaseEntry
	// contains filtered or unexported fields
}

func NewDBEntry

func NewDBEntry(catalog *Catalog, name string, txnCtx txnif.AsyncTxn) *DBEntry

func NewReplayDBEntry

func NewReplayDBEntry() *DBEntry

func NewSystemDBEntry

func NewSystemDBEntry(catalog *Catalog) *DBEntry

func (*DBEntry) AddEntryLocked

func (e *DBEntry) AddEntryLocked(table *TableEntry) (err error)

func (*DBEntry) Clone

func (e *DBEntry) Clone() CheckpointItem

func (*DBEntry) CloneCreate

func (e *DBEntry) CloneCreate() CheckpointItem

func (*DBEntry) CloneCreateEntry

func (e *DBEntry) CloneCreateEntry() *DBEntry

func (*DBEntry) CoarseTableCnt

func (e *DBEntry) CoarseTableCnt() int

func (*DBEntry) Compare

func (e *DBEntry) Compare(o common.NodePayload) int

func (*DBEntry) CreateTableEntry

func (e *DBEntry) CreateTableEntry(schema *Schema, txnCtx txnif.AsyncTxn, dataFactory TableDataFactory) (created *TableEntry, err error)

func (*DBEntry) DropTableEntry

func (e *DBEntry) DropTableEntry(name string, txnCtx txnif.AsyncTxn) (deleted *TableEntry, err error)

func (*DBEntry) GetBlockEntryByID

func (e *DBEntry) GetBlockEntryByID(id *common.ID) (blk *BlockEntry, err error)

func (*DBEntry) GetCatalog

func (e *DBEntry) GetCatalog() *Catalog

func (*DBEntry) GetName

func (e *DBEntry) GetName() string

func (*DBEntry) GetTableEntry

func (e *DBEntry) GetTableEntry(name string, txnCtx txnif.AsyncTxn) (entry *TableEntry, err error)

func (*DBEntry) GetTableEntryByID

func (e *DBEntry) GetTableEntryByID(id uint64) (table *TableEntry, err error)

func (*DBEntry) IsActive

func (e *DBEntry) IsActive() bool

IsActive is coarse API: no consistency check

func (*DBEntry) IsSystemDB

func (e *DBEntry) IsSystemDB() bool

func (*DBEntry) MakeCommand

func (e *DBEntry) MakeCommand(id uint32) (txnif.TxnCmd, error)

func (*DBEntry) MakeLogEntry

func (e *DBEntry) MakeLogEntry() *EntryCommand

func (*DBEntry) MakeTableIt

func (e *DBEntry) MakeTableIt(reverse bool) *common.LinkIt

func (*DBEntry) PPString

func (e *DBEntry) PPString(level common.PPLevel, depth int, prefix string) string

func (*DBEntry) PrepareRollback

func (e *DBEntry) PrepareRollback() (err error)

func (*DBEntry) ReadFrom

func (e *DBEntry) ReadFrom(r io.Reader) (n int64, err error)

func (*DBEntry) RecurLoop

func (e *DBEntry) RecurLoop(processor Processor) (err error)

func (*DBEntry) RemoveEntry

func (e *DBEntry) RemoveEntry(table *TableEntry) (err error)

func (*DBEntry) String

func (e *DBEntry) String() string

func (*DBEntry) StringLocked

func (e *DBEntry) StringLocked() string

func (*DBEntry) WriteTo

func (e *DBEntry) WriteTo(w io.Writer) (n int64, err error)

type DataFactory

type DataFactory interface {
	MakeTableFactory() TableDataFactory
	MakeSegmentFactory() SegmentDataFactory
	MakeBlockFactory(segFile file.Segment) BlockDataFactory
}

type Default

type Default struct {
	Set   bool
	Null  bool
	Value any
}

type EntryCommand

type EntryCommand struct {
	*txnbase.BaseCustomizedCmd

	DBID      uint64
	TableID   uint64
	SegmentID uint64
	DB        *DBEntry
	Table     *TableEntry
	Segment   *SegmentEntry
	Block     *BlockEntry
	// contains filtered or unexported fields
}

func (*EntryCommand) Desc

func (cmd *EntryCommand) Desc() string

func (*EntryCommand) GetID

func (cmd *EntryCommand) GetID() (uint64, *common.ID)

func (*EntryCommand) GetLogIndex

func (cmd *EntryCommand) GetLogIndex() *wal.Index

func (*EntryCommand) GetTs

func (cmd *EntryCommand) GetTs() uint64

func (*EntryCommand) GetType

func (cmd *EntryCommand) GetType() int16

func (*EntryCommand) IDString

func (cmd *EntryCommand) IDString() string

func (*EntryCommand) Marshal

func (cmd *EntryCommand) Marshal() (buf []byte, err error)

func (*EntryCommand) ReadFrom

func (cmd *EntryCommand) ReadFrom(r io.Reader) (n int64, err error)

func (*EntryCommand) String

func (cmd *EntryCommand) String() string

func (*EntryCommand) Unmarshal

func (cmd *EntryCommand) Unmarshal(buf []byte) (err error)

func (*EntryCommand) VerboseString

func (cmd *EntryCommand) VerboseString() string

func (*EntryCommand) WriteTo

func (cmd *EntryCommand) WriteTo(w io.Writer) (n int64, err error)

type EntryState

type EntryState int8
const (
	ES_Appendable EntryState = iota
	ES_NotAppendable
	ES_Frozen
)

func (EntryState) Repr

func (es EntryState) Repr() string

type EntryType

type EntryType uint8
const (
	ETDatabase EntryType = iota
	ETTable
	ETSegment
	ETBlock
	ETColDef
)

type IDAlloctor

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

func NewIDAllocator

func NewIDAllocator() *IDAlloctor

func (*IDAlloctor) CurrBlock

func (alloc *IDAlloctor) CurrBlock() uint64

func (*IDAlloctor) CurrDB

func (alloc *IDAlloctor) CurrDB() uint64

func (*IDAlloctor) CurrSegment

func (alloc *IDAlloctor) CurrSegment() uint64

func (*IDAlloctor) CurrTable

func (alloc *IDAlloctor) CurrTable() uint64

func (*IDAlloctor) IDStates

func (alloc *IDAlloctor) IDStates() string

func (*IDAlloctor) Init

func (alloc *IDAlloctor) Init(prevDb, prevTbl, prevSeg, prevBlk uint64)

func (*IDAlloctor) NextBlock

func (alloc *IDAlloctor) NextBlock() uint64

func (*IDAlloctor) NextDB

func (alloc *IDAlloctor) NextDB() uint64

func (*IDAlloctor) NextSegment

func (alloc *IDAlloctor) NextSegment() uint64

func (*IDAlloctor) NextTable

func (alloc *IDAlloctor) NextTable() uint64

func (*IDAlloctor) OnReplayBlockID

func (alloc *IDAlloctor) OnReplayBlockID(id uint64)

func (*IDAlloctor) OnReplayDBID

func (alloc *IDAlloctor) OnReplayDBID(id uint64)

func (*IDAlloctor) OnReplaySegmentID

func (alloc *IDAlloctor) OnReplaySegmentID(id uint64)

func (*IDAlloctor) OnReplayTableID

func (alloc *IDAlloctor) OnReplayTableID(id uint64)

type IndexInfo

type IndexInfo struct {
	Id      uint64
	Name    string
	Type    IndexT
	Columns []uint16
}

func NewIndexInfo

func NewIndexInfo(name string, typ IndexT, colIdx ...int) *IndexInfo

type IndexT

type IndexT uint16
const (
	ZoneMap IndexT = iota
)

type LogEntry

type LogEntry = entry.Entry

type LoopProcessor

type LoopProcessor struct {
	DatabaseFn    func(*DBEntry) error
	TableFn       func(*TableEntry) error
	SegmentFn     func(*SegmentEntry) error
	BlockFn       func(*BlockEntry) error
	PostSegmentFn func(*SegmentEntry) error
}

func (*LoopProcessor) OnBlock

func (p *LoopProcessor) OnBlock(block *BlockEntry) error

func (*LoopProcessor) OnDatabase

func (p *LoopProcessor) OnDatabase(database *DBEntry) error

func (*LoopProcessor) OnPostSegment

func (p *LoopProcessor) OnPostSegment(segment *SegmentEntry) error

func (*LoopProcessor) OnSegment

func (p *LoopProcessor) OnSegment(segment *SegmentEntry) error

func (*LoopProcessor) OnTable

func (p *LoopProcessor) OnTable(table *TableEntry) error

type OpT

type OpT int8
const (
	OpCreate OpT = iota
	OpUpdate
	OpSoftDelete
	OpHardDelete
)

type PersistentType

type PersistentType int8
const (
	PT_Permanent PersistentType = iota
	PT_Temporary
)

type Processor

type Processor interface {
	OnDatabase(database *DBEntry) error
	OnTable(table *TableEntry) error
	OnPostSegment(segment *SegmentEntry) error
	OnSegment(segment *SegmentEntry) error
	OnBlock(block *BlockEntry) error
}

type Replayer

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

func NewReplayer

func NewReplayer(dataFactory DataFactory, catalog *Catalog) *Replayer

func (*Replayer) ReplayerHandle

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

type Schema

type Schema struct {
	Name             string
	ColDefs          []*ColDef
	NameIndex        map[string]int
	BlockMaxRows     uint32
	SegmentMaxBlocks uint16
	Comment          string

	SortKey   *SortKey
	HiddenKey *ColDef
}
var SystemColumnSchema *Schema
var SystemDBSchema *Schema
var SystemTableSchema *Schema

func MockCompoundSchema

func MockCompoundSchema(colCnt int, pkIdx ...int) *Schema

func MockSchema

func MockSchema(colCnt int, pkIdx int) *Schema

func MockSchemaAll

func MockSchemaAll(colCnt int, pkIdx int, from ...int) *Schema

MockSchemaAll if char/varchar is needed, colCnt = 14, otherwise colCnt = 12 pkIdx == -1 means no pk defined

func NewEmptySchema

func NewEmptySchema(name string) *Schema

func (*Schema) AllNames

func (s *Schema) AllNames() []string

func (*Schema) AllNullables

func (s *Schema) AllNullables() []bool

func (*Schema) AllTypes

func (s *Schema) AllTypes() []types.Type

func (*Schema) AppendCol

func (s *Schema) AppendCol(name string, typ types.Type) error

func (*Schema) AppendColDef

func (s *Schema) AppendColDef(def *ColDef) (err error)

func (*Schema) AppendColWithDefault

func (s *Schema) AppendColWithDefault(name string, typ types.Type, val Default) error

func (*Schema) AppendPKCol

func (s *Schema) AppendPKCol(name string, typ types.Type, idx int) error

func (*Schema) AppendSortKey

func (s *Schema) AppendSortKey(name string, typ types.Type, idx int, isPrimary bool) error

func (*Schema) Attrs

func (s *Schema) Attrs() []string

func (*Schema) Clone

func (s *Schema) Clone() *Schema

func (*Schema) Finalize

func (s *Schema) Finalize(rebuild bool) (err error)

func (*Schema) GetColIdx

func (s *Schema) GetColIdx(attr string) int

GetColIdx returns column index for the given column name if found, otherwise returns -1.

func (*Schema) GetSingleSortKey

func (s *Schema) GetSingleSortKey() *ColDef

GetSingleSortKey should be call only if IsSinglePK is checked

func (*Schema) GetSingleSortKeyIdx

func (s *Schema) GetSingleSortKeyIdx() int

func (*Schema) GetSortKeyCnt

func (s *Schema) GetSortKeyCnt() int

func (*Schema) GetSortKeyType

func (s *Schema) GetSortKeyType() types.Type

func (*Schema) HasPK

func (s *Schema) HasPK() bool

func (*Schema) HasSortKey

func (s *Schema) HasSortKey() bool

func (*Schema) IsCompoundPK

func (s *Schema) IsCompoundPK() bool

func (*Schema) IsCompoundSortKey

func (s *Schema) IsCompoundSortKey() bool

func (*Schema) IsPartOfPK

func (s *Schema) IsPartOfPK(idx int) bool

func (*Schema) IsSinglePK

func (s *Schema) IsSinglePK() bool

func (*Schema) IsSingleSortKey

func (s *Schema) IsSingleSortKey() bool

func (*Schema) Marshal

func (s *Schema) Marshal() (buf []byte, err error)

func (*Schema) Nullables

func (s *Schema) Nullables() []bool

func (*Schema) ReadFrom

func (s *Schema) ReadFrom(r io.Reader) (n int64, err error)

func (*Schema) String

func (s *Schema) String() string

func (*Schema) Types

func (s *Schema) Types() []types.Type

type SegmentDataFactory

type SegmentDataFactory = func(meta *SegmentEntry) data.Segment

type SegmentEntry

type SegmentEntry struct {
	*BaseEntry
	// contains filtered or unexported fields
}

func NewReplaySegmentEntry

func NewReplaySegmentEntry() *SegmentEntry

func NewSegmentEntry

func NewSegmentEntry(table *TableEntry, txn txnif.AsyncTxn, state EntryState, dataFactory SegmentDataFactory) *SegmentEntry

func NewStandaloneSegment

func NewStandaloneSegment(table *TableEntry, id uint64, ts uint64) *SegmentEntry

func NewSysSegmentEntry

func NewSysSegmentEntry(table *TableEntry, id uint64) *SegmentEntry

func (*SegmentEntry) AddEntryLocked

func (entry *SegmentEntry) AddEntryLocked(block *BlockEntry)

func (*SegmentEntry) AsCommonID

func (entry *SegmentEntry) AsCommonID() *common.ID

func (*SegmentEntry) BlockCnt

func (entry *SegmentEntry) BlockCnt() int

func (*SegmentEntry) Clone

func (entry *SegmentEntry) Clone() CheckpointItem

func (*SegmentEntry) CloneCreate

func (entry *SegmentEntry) CloneCreate() CheckpointItem

func (*SegmentEntry) CollectBlockEntries

func (entry *SegmentEntry) CollectBlockEntries(commitFilter func(be *BaseEntry) bool, blockFilter func(be *BlockEntry) bool) []*BlockEntry

func (*SegmentEntry) Compare

func (entry *SegmentEntry) Compare(o common.NodePayload) int

func (*SegmentEntry) CreateBlock

func (entry *SegmentEntry) CreateBlock(txn txnif.AsyncTxn, state EntryState, dataFactory BlockDataFactory) (created *BlockEntry, err error)

func (*SegmentEntry) DestroyData

func (entry *SegmentEntry) DestroyData() (err error)

func (*SegmentEntry) DropBlockEntry

func (entry *SegmentEntry) DropBlockEntry(id uint64, txn txnif.AsyncTxn) (deleted *BlockEntry, err error)

func (*SegmentEntry) GetAppendableBlockCnt

func (entry *SegmentEntry) GetAppendableBlockCnt() int

func (*SegmentEntry) GetBlockEntryByID

func (entry *SegmentEntry) GetBlockEntryByID(id uint64) (blk *BlockEntry, err error)

func (*SegmentEntry) GetBlockEntryByIDLocked

func (entry *SegmentEntry) GetBlockEntryByIDLocked(id uint64) (blk *BlockEntry, err error)

func (*SegmentEntry) GetCatalog

func (entry *SegmentEntry) GetCatalog() *Catalog

func (*SegmentEntry) GetScheduler

func (entry *SegmentEntry) GetScheduler() tasks.TaskScheduler

func (*SegmentEntry) GetSegmentData

func (entry *SegmentEntry) GetSegmentData() data.Segment

func (*SegmentEntry) GetTable

func (entry *SegmentEntry) GetTable() *TableEntry

func (*SegmentEntry) InitData

func (entry *SegmentEntry) InitData(factory DataFactory)

func (*SegmentEntry) IsActive

func (entry *SegmentEntry) IsActive() bool

IsActive is coarse API: no consistency check

func (*SegmentEntry) IsAppendable

func (entry *SegmentEntry) IsAppendable() bool

func (*SegmentEntry) LastAppendableBlock

func (entry *SegmentEntry) LastAppendableBlock() (blk *BlockEntry)

func (*SegmentEntry) MakeBlockIt

func (entry *SegmentEntry) MakeBlockIt(reverse bool) *common.LinkIt

func (*SegmentEntry) MakeCommand

func (entry *SegmentEntry) MakeCommand(id uint32) (cmd txnif.TxnCmd, err error)

func (*SegmentEntry) MakeLogEntry

func (entry *SegmentEntry) MakeLogEntry() *EntryCommand

func (*SegmentEntry) PPString

func (entry *SegmentEntry) PPString(level common.PPLevel, depth int, prefix string) string

func (*SegmentEntry) PrepareRollback

func (entry *SegmentEntry) PrepareRollback() (err error)

func (*SegmentEntry) ReadFrom

func (entry *SegmentEntry) ReadFrom(r io.Reader) (n int64, err error)

func (*SegmentEntry) RemoveEntry

func (entry *SegmentEntry) RemoveEntry(block *BlockEntry) (err error)

func (*SegmentEntry) Repr

func (entry *SegmentEntry) Repr() string

func (*SegmentEntry) String

func (entry *SegmentEntry) String() string

func (*SegmentEntry) StringLocked

func (entry *SegmentEntry) StringLocked() string

func (*SegmentEntry) TreeMaxDropCommitEntry

func (entry *SegmentEntry) TreeMaxDropCommitEntry() *BaseEntry

func (*SegmentEntry) WriteTo

func (entry *SegmentEntry) WriteTo(w io.Writer) (n int64, err error)

type SortKey

type SortKey struct {
	Defs []*ColDef
	// contains filtered or unexported fields
}

func NewSortKey

func NewSortKey() *SortKey

func (*SortKey) AddDef

func (cpk *SortKey) AddDef(def *ColDef) (ok bool)

func (*SortKey) GetDef

func (cpk *SortKey) GetDef(pos int) *ColDef

func (*SortKey) GetSingleIdx

func (cpk *SortKey) GetSingleIdx() int

func (*SortKey) HasColumn

func (cpk *SortKey) HasColumn(idx int) (found bool)

func (*SortKey) IsPrimary

func (cpk *SortKey) IsPrimary() bool

func (*SortKey) IsSinglePK

func (cpk *SortKey) IsSinglePK() bool

func (*SortKey) Size

func (cpk *SortKey) Size() int

type TableDataFactory

type TableDataFactory = func(meta *TableEntry) data.Table

type TableEntry

type TableEntry struct {
	*BaseEntry
	// contains filtered or unexported fields
}

func MockStaloneTableEntry

func MockStaloneTableEntry(id uint64, schema *Schema) *TableEntry

func NewReplayTableEntry

func NewReplayTableEntry() *TableEntry

func NewSystemTableEntry

func NewSystemTableEntry(db *DBEntry, id uint64, schema *Schema) *TableEntry

func NewTableEntry

func NewTableEntry(db *DBEntry, schema *Schema, txnCtx txnif.AsyncTxn, dataFactory TableDataFactory) *TableEntry

func (*TableEntry) AddEntryLocked

func (entry *TableEntry) AddEntryLocked(segment *SegmentEntry)

func (*TableEntry) AddRows

func (entry *TableEntry) AddRows(delta uint64) uint64

func (*TableEntry) AsCommonID

func (entry *TableEntry) AsCommonID() *common.ID

func (*TableEntry) Clone

func (entry *TableEntry) Clone() CheckpointItem

func (*TableEntry) CloneCreate

func (entry *TableEntry) CloneCreate() CheckpointItem

func (*TableEntry) CloneCreateEntry

func (entry *TableEntry) CloneCreateEntry() *TableEntry

CloneCreateEntry is for collect commands

func (*TableEntry) Compare

func (entry *TableEntry) Compare(o common.NodePayload) int

func (*TableEntry) CreateSegment

func (entry *TableEntry) CreateSegment(txn txnif.AsyncTxn, state EntryState, dataFactory SegmentDataFactory) (created *SegmentEntry, err error)

func (*TableEntry) DropSegmentEntry

func (entry *TableEntry) DropSegmentEntry(id uint64, txn txnif.AsyncTxn) (deleted *SegmentEntry, err error)

func (*TableEntry) GetCatalog

func (entry *TableEntry) GetCatalog() *Catalog

func (*TableEntry) GetDB

func (entry *TableEntry) GetDB() *DBEntry

func (*TableEntry) GetRows

func (entry *TableEntry) GetRows() uint64

func (*TableEntry) GetSchema

func (entry *TableEntry) GetSchema() *Schema

func (*TableEntry) GetSegmentByID

func (entry *TableEntry) GetSegmentByID(id uint64) (seg *SegmentEntry, err error)

func (*TableEntry) GetTableData

func (entry *TableEntry) GetTableData() data.Table

func (*TableEntry) IsActive

func (entry *TableEntry) IsActive() bool

IsActive is coarse API: no consistency check

func (*TableEntry) IsVirtual

func (entry *TableEntry) IsVirtual() bool

func (*TableEntry) LastAppendableSegmemt

func (entry *TableEntry) LastAppendableSegmemt() (seg *SegmentEntry)

func (*TableEntry) MakeCommand

func (entry *TableEntry) MakeCommand(id uint32) (cmd txnif.TxnCmd, err error)

func (*TableEntry) MakeLogEntry

func (entry *TableEntry) MakeLogEntry() *EntryCommand

func (*TableEntry) MakeSegmentIt

func (entry *TableEntry) MakeSegmentIt(reverse bool) *common.LinkIt

func (*TableEntry) PPString

func (entry *TableEntry) PPString(level common.PPLevel, depth int, prefix string) string

func (*TableEntry) PrepareRollback

func (entry *TableEntry) PrepareRollback() (err error)

func (*TableEntry) ReadFrom

func (entry *TableEntry) ReadFrom(r io.Reader) (n int64, err error)

func (*TableEntry) RecurLoop

func (entry *TableEntry) RecurLoop(processor Processor) (err error)

func (*TableEntry) RemoveEntry

func (entry *TableEntry) RemoveEntry(segment *SegmentEntry) (err error)

func (*TableEntry) RemoveRows

func (entry *TableEntry) RemoveRows(delta uint64) uint64

func (*TableEntry) String

func (entry *TableEntry) String() string

func (*TableEntry) StringLocked

func (entry *TableEntry) StringLocked() string

func (*TableEntry) WriteTo

func (entry *TableEntry) WriteTo(w io.Writer) (n int64, err error)

type TableType

type TableType int8
const (
	TT_Ordinary TableType = iota
	TT_Index
	TT_Sequence
	TT_View
	TT_MaterializedView
)

Jump to

Keyboard shortcuts

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