handle

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIteratorEnd = errors.New("end of interator")
)

Functions

This section is empty.

Types

type Block

type Block interface {
	BlockReader
	BlockWriter
}

type BlockIt

type BlockIt interface {
	Iterator
	GetBlock() Block
}

type BlockReader

type BlockReader interface {
	io.Closer
	ID() uint64
	String() string
	IsUncommitted() bool
	GetByFilter(filter *Filter) (uint32, error)
	GetColumnDataByName(string, *bytes.Buffer) (*model.ColumnView, error)
	GetColumnDataById(int, *bytes.Buffer) (*model.ColumnView, error)
	GetMeta() any
	Fingerprint() *common.ID
	Rows() int

	// Why need rowmask?
	// We don't update the index until committing the transaction. Before that, even if we deleted a row
	// from a block, the index would not change. If then we insert a row with the same primary key as the
	// previously deleted row, there will be an deduplication error (unexpected!).
	// Here we use the rowmask to ingore any deduplication error on those deleted rows.
	BatchDedup(col containers.Vector, invisibility *roaring.Bitmap) error

	IsAppendableBlock() bool

	GetSegment() Segment

	GetTotalChanges() int
}

type BlockWriter

type BlockWriter interface {
	io.Closer
	Append(data *containers.Batch, offset uint32) (uint32, error)
	Update(row uint32, col uint16, v any) error
	RangeDelete(start, end uint32, dt DeleteType) error

	PushDeleteOp(filter Filter) error
	PushUpdateOp(filter Filter, attr string, val any) error
}

type Database

type Database interface {
	io.Closer

	GetID() uint64
	GetName() string
	CreateRelation(def any) (Relation, error)
	DropRelationByName(name string) (Relation, error)
	TruncateByName(name string) (Relation, error)

	GetRelationByName(name string) (Relation, error)
	RelationCnt() int64
	Relations() []Relation

	MakeRelationIt() RelationIt
	String() string
	GetMeta() any
}

type DeleteType

type DeleteType int8
const (
	DT_Normal DeleteType = iota
	DT_MergeCompact
)

type Filter

type Filter struct {
	Op  FilterOp
	Val any
}

func NewEQFilter

func NewEQFilter(v any) *Filter

type FilterOp

type FilterOp int16
const (
	FilterEq FilterOp = iota
	FilterBatchEq
	FilterBtw
)

type Iterator

type Iterator interface {
	sync.Locker
	RLock()
	RUnlock()
	io.Closer
	Valid() bool
	Next()
	GetError() error
}

TODO: this is not thread-safe

type Relation

type Relation interface {
	io.Closer
	ID() uint64
	Rows() int64
	Size(attr string) int64
	String() string
	SimplePPString(common.PPLevel) string
	GetCardinality(attr string) int64
	Schema() any
	MakeSegmentIt() SegmentIt
	MakeBlockIt() BlockIt

	DeleteByHiddenKey(key any) error
	UpdateByHiddenKey(key any, col int, v any) error
	GetValueByHiddenKey(key any, col int) (any, error)

	DeleteByHiddenKeys(keys containers.Vector) error

	RangeDelete(id *common.ID, start, end uint32, dt DeleteType) error
	Update(id *common.ID, row uint32, col uint16, v any) error
	GetByFilter(filter *Filter) (id *common.ID, offset uint32, err error)
	GetValue(id *common.ID, row uint32, col uint16) (any, error)
	GetValueByFilter(filter *Filter, col int) (any, error)
	UpdateByFilter(filter *Filter, col uint16, v any) error
	DeleteByFilter(filter *Filter) error

	BatchDedup(cols ...containers.Vector) error
	Append(data *containers.Batch) error

	GetMeta() any
	CreateSegment() (Segment, error)
	CreateNonAppendableSegment() (Segment, error)
	GetSegment(id uint64) (Segment, error)

	SoftDeleteSegment(id uint64) (err error)

	GetDB() (Database, error)
}

type RelationIt

type RelationIt interface {
	Iterator
	GetRelation() Relation
}

type Segment

type Segment interface {
	SegmentReader
	SegmentWriter
}

type SegmentIt

type SegmentIt interface {
	Iterator
	GetSegment() Segment
}

type SegmentReader

type SegmentReader interface {
	io.Closer
	GetID() uint64
	IsUncommitted() bool
	MakeBlockIt() BlockIt
	// GetByFilter(filter Filter, offsetOnly bool) (map[uint64]*batch.Batch, error)
	String() string
	GetMeta() any

	GetBlock(id uint64) (Block, error)
	GetRelation() Relation

	BatchDedup(pks containers.Vector) error
}

type SegmentWriter

type SegmentWriter interface {
	io.Closer
	String() string
	Update(blk uint64, row uint32, col uint16, v any) error
	RangeDelete(blk uint64, start, end uint32, dt DeleteType) error

	PushDeleteOp(filter Filter) error
	PushUpdateOp(filter Filter, attr string, val any) error

	CreateBlock() (Block, error)
	CreateNonAppendableBlock() (Block, error)

	SoftDeleteBlock(id uint64) (err error)
}

Jump to

Keyboard shortcuts

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