model

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBlockKeyPrefix

func DecodeBlockKeyPrefix(rowid types.Rowid) (segmentId, blockId uint64)

func DecodePhyAddrKey added in v0.6.0

func DecodePhyAddrKey(src types.Rowid) (segmentId, blockId uint64, offset uint32)

func DecodePhyAddrKeyFromValue added in v0.6.0

func DecodePhyAddrKeyFromValue(v any) (segmentId, blockId uint64, offset uint32)

func EncodeBlockKeyPrefix

func EncodeBlockKeyPrefix(segmentId, blockId uint64) []byte

EncodeBlockKeyPrefix [48 Bit (BlockID) + 48 Bit (SegmentID)]

func EncodePhyAddrKey added in v0.6.0

func EncodePhyAddrKey(segmentId, blockId uint64, offset uint32) types.Rowid

func EncodePhyAddrKeyWithPrefix added in v0.6.0

func EncodePhyAddrKeyWithPrefix(prefix []byte, offset uint32) types.Rowid

func PreparePhyAddrData added in v0.6.0

func PreparePhyAddrData(typ types.Type, prefix []byte, startRow, length uint32) (col containers.Vector, err error)

func PreparePhyAddrDataWithPool added in v0.6.0

func PreparePhyAddrDataWithPool(typ types.Type, prefix []byte, startRow, length uint32, pool *mpool.MPool) (col containers.Vector, err error)

Types

type AOT added in v0.7.0

type AOT[B BlockT[R], R RowsT[R]] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

AOT stands for append-only-table append-only is the most common form of data organization. A basic data structure is abstracted here, which can cover most scenarios, such as logtail data and checkpoint data

func NewAOT added in v0.7.0

func NewAOT[B BlockT[R], R RowsT[R]](
	blockSize int,
	blockFactory func(R) B,
	lessFn func(_, _ B) bool) *AOT[B, R]

func (*AOT[B, R]) Append added in v0.7.0

func (aot *AOT[B, R]) Append(rows R) (err error)

One appender

func (*AOT[B, R]) BlockCount added in v0.7.0

func (aot *AOT[B, R]) BlockCount() int

func (*AOT[B, R]) Close added in v0.7.0

func (aot *AOT[B, R]) Close()

func (*AOT[B, R]) Max added in v0.7.0

func (aot *AOT[B, R]) Max() (b B)

func (*AOT[B, R]) Min added in v0.7.0

func (aot *AOT[B, R]) Min() (b B)

func (*AOT[B, R]) Scan added in v0.7.0

func (aot *AOT[B, R]) Scan(fn func(_ B) bool)

func (*AOT[B, R]) Snapshot added in v0.7.0

func (aot *AOT[B, R]) Snapshot() AOTSnapshot[B, R]

func (*AOT[B, R]) String added in v0.7.0

func (aot *AOT[B, R]) String() string

func (*AOT[B, R]) Truncate added in v0.7.0

func (aot *AOT[B, R]) Truncate(stopFn func(_ B) bool) (cnt int)

Truncate prunes the blocks. Deletable blocks are those have all txns prepared before the given timestamp For example: truncate the table by timestamp blocks: (Page1[bornTs=1], Page2[bornTs=10], Page3[bornTs=20]) Call Remain Delete Truncate(ts=5): (Page1,Page2,Page3), () Truncate(ts=12): (Page2,Page3), (Page1) Truncate(ts=30): (Page3), (Page1,Page2)

type AOTSnapshot added in v0.7.0

type AOTSnapshot[B BlockT[R], R RowsT[R]] interface {
	// Ascend the table within the range [pivot, last]
	Ascend(pivot B, iter func(blk B) bool)

	// Descend the table within the range [pivot, first]
	Descend(pivot B, iter func(blk B) bool)
}

AOTSnapshot represents the snapshot of a AOT

type BaseView added in v0.7.0

type BaseView struct {
	Ts         types.TS
	DeleteMask *roaring.Bitmap
}

type BatchBlock added in v0.7.0

type BatchBlock struct {
	*containers.Batch
	ID uint64
}

func NewBatchBlock added in v0.7.0

func NewBatchBlock(
	id uint64,
	attrs []string,
	colTypes []types.Type,
	nullables []bool,
	opts containers.Options) *BatchBlock

func (*BatchBlock) IsAppendable added in v0.7.0

func (blk *BatchBlock) IsAppendable() bool

type BlockT added in v0.7.0

type BlockT[R RowsT[R]] interface {
	// Append appends a group of rows into the block
	Append(R) error

	// IsAppendable specifies wether the block is appendable
	IsAppendable() bool

	// Length specifies the row count of the block
	Length() int

	String() string

	// Close release the block bound resources
	// It should be called when the block is not used
	Close()
}

BlockT represents a block of rows

type BlockView

type BlockView struct {
	*BaseView
	Columns          map[int]*ColumnView
	DeleteLogIndexes []*wal.Index
}

func NewBlockView

func NewBlockView(ts types.TS) *BlockView

func (*BlockView) ApplyDeletes added in v0.7.0

func (view *BlockView) ApplyDeletes()

func (*BlockView) Close

func (view *BlockView) Close()

func (*BlockView) Eval

func (view *BlockView) Eval(clear bool) (err error)

func (*BlockView) GetColumnData

func (view *BlockView) GetColumnData(i int) containers.Vector

func (*BlockView) Orphan

func (view *BlockView) Orphan(i int) containers.Vector

func (*BlockView) SetBatch

func (view *BlockView) SetBatch(bat *containers.Batch)

func (*BlockView) SetData

func (view *BlockView) SetData(i int, data containers.Vector)

func (*BlockView) SetLogIndexes

func (view *BlockView) SetLogIndexes(i int, indexes []*wal.Index)

func (*BlockView) SetUpdates

func (view *BlockView) SetUpdates(i int, mask *roaring.Bitmap, vals map[uint32]any)

type ColumnView

type ColumnView struct {
	*BaseView
	ColIdx int

	UpdateMask *roaring.Bitmap
	UpdateVals map[uint32]any
	LogIndexes []*wal.Index
	// contains filtered or unexported fields
}

func NewColumnView

func NewColumnView(ts types.TS, colIdx int) *ColumnView

func (*ColumnView) ApplyDeletes

func (view *ColumnView) ApplyDeletes() containers.Vector

func (*ColumnView) Close

func (view *ColumnView) Close()

func (*ColumnView) Eval

func (view *ColumnView) Eval(clear bool) (err error)

func (*ColumnView) GetData

func (view *ColumnView) GetData() containers.Vector

func (*ColumnView) GetValue

func (view *ColumnView) GetValue(row int) any

func (*ColumnView) IsDeleted added in v0.7.0

func (view *ColumnView) IsDeleted(row int) bool

func (*ColumnView) Length

func (view *ColumnView) Length() int

func (*ColumnView) Orphan

func (view *ColumnView) Orphan() containers.Vector

func (*ColumnView) SetData

func (view *ColumnView) SetData(data containers.Vector)

func (*ColumnView) String

func (view *ColumnView) String() string

type HashPageTable added in v0.6.0

type HashPageTable = TransferTable[*TransferHashPage]

type PageT added in v0.6.0

type PageT[T common.IRef] interface {
	common.IRef
	Pin() *common.PinnedItem[T]
	TTL(time.Time, time.Duration) bool
	ID() *common.ID
}

type PreparedCompactedBlockData

type PreparedCompactedBlockData struct {
	Columns *containers.Batch
	SortKey containers.Vector
}

func NewPreparedCompactedBlockData

func NewPreparedCompactedBlockData() *PreparedCompactedBlockData

func (*PreparedCompactedBlockData) Close

func (preparer *PreparedCompactedBlockData) Close()

type RowsT added in v0.7.0

type RowsT[T any] interface {
	// row count
	Length() int

	// returns a window of the group of rows
	Window(offset, length int) T
}

RowsT represents a group of rows

type TimedSliceBlock added in v0.7.0

type TimedSliceBlock[R any] struct {
	BornTS types.TS
	Rows   []R
}

func NewTimedSliceBlock added in v0.7.0

func NewTimedSliceBlock[R any](ts types.TS) *TimedSliceBlock[R]

func (*TimedSliceBlock[R]) Append added in v0.7.0

func (blk *TimedSliceBlock[R]) Append(rows R) (err error)

func (*TimedSliceBlock[R]) Close added in v0.7.0

func (blk *TimedSliceBlock[R]) Close()

func (*TimedSliceBlock[R]) IsAppendable added in v0.7.0

func (blk *TimedSliceBlock[R]) IsAppendable() bool

func (*TimedSliceBlock[R]) Length added in v0.7.0

func (blk *TimedSliceBlock[R]) Length() int

func (*TimedSliceBlock[R]) String added in v0.7.0

func (blk *TimedSliceBlock[R]) String() string

type TransferHashPage added in v0.6.0

type TransferHashPage struct {
	common.RefHelper
	// contains filtered or unexported fields
}

func NewTransferHashPage added in v0.6.0

func NewTransferHashPage(id *common.ID, ts time.Time) *TransferHashPage

func (*TransferHashPage) BornTS added in v0.6.0

func (page *TransferHashPage) BornTS() time.Time

func (*TransferHashPage) Close added in v0.6.0

func (page *TransferHashPage) Close()

func (*TransferHashPage) ID added in v0.6.0

func (page *TransferHashPage) ID() *common.ID

func (*TransferHashPage) Pin added in v0.6.0

func (*TransferHashPage) String added in v0.6.0

func (page *TransferHashPage) String() string

func (*TransferHashPage) TTL added in v0.6.0

func (page *TransferHashPage) TTL(now time.Time, ttl time.Duration) bool

func (*TransferHashPage) Train added in v0.6.0

func (page *TransferHashPage) Train(from uint32, to types.Rowid)

func (*TransferHashPage) Transfer added in v0.6.0

func (page *TransferHashPage) Transfer(from uint32) (dest types.Rowid, ok bool)

type TransferTable added in v0.6.0

type TransferTable[T PageT[T]] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTransferTable added in v0.6.0

func NewTransferTable[T PageT[T]](ttl time.Duration) *TransferTable[T]

func (*TransferTable[T]) AddPage added in v0.6.0

func (table *TransferTable[T]) AddPage(page T) (dup bool)

func (*TransferTable[T]) Close added in v0.6.0

func (table *TransferTable[T]) Close()

func (*TransferTable[T]) DeletePage added in v0.6.0

func (table *TransferTable[T]) DeletePage(id *common.ID) (deleted bool)

func (*TransferTable[T]) Len added in v0.6.0

func (table *TransferTable[T]) Len() int

func (*TransferTable[T]) Pin added in v0.6.0

func (table *TransferTable[T]) Pin(id common.ID) (pinned *common.PinnedItem[T], err error)

func (*TransferTable[T]) RunTTL added in v0.6.0

func (table *TransferTable[T]) RunTTL(now time.Time)

Jump to

Keyboard shortcuts

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