memtable

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Active = iota
	Committed
	Aborted
)

Variables

View Source
var Max max
View Source
var Min min
View Source
var Serializable = IsolationPolicy{
	Read: ReadNoStale,
}
View Source
var SnapshotIsolation = IsolationPolicy{
	Read: ReadSnapshot,
}

Functions

func ToOrdered

func ToOrdered(v any) any

func TypeMatch

func TypeMatch(v any, typ types.T) bool

Types

type Atomic

type Atomic[T any] struct {
	// contains filtered or unexported fields
}

func NewAtomic

func NewAtomic[T any](value T) *Atomic[T]

func (*Atomic[T]) Load

func (a *Atomic[T]) Load() T

func (*Atomic[T]) Store

func (a *Atomic[T]) Store(value T)

type BatchIter

type BatchIter func() (tuple []Nullable)

func NewBatchIter

func NewBatchIter(b *batch.Batch) BatchIter

type Bool

type Bool bool

func (Bool) Less

func (b Bool) Less(than Bool) bool

type Bytes

type Bytes []byte

func (Bytes) Less

func (b Bytes) Less(than Bytes) bool

type DiffIter

type DiffIter[
	K Ordered[K],
	V any,
] struct {
	// contains filtered or unexported fields
}

func (*DiffIter[K, V]) Close

func (t *DiffIter[K, V]) Close() error

func (*DiffIter[K, V]) First

func (t *DiffIter[K, V]) First() bool

func (*DiffIter[K, V]) Next

func (t *DiffIter[K, V]) Next() bool

func (*DiffIter[K, V]) Read

func (t *DiffIter[K, V]) Read() (
	key K,
	value V,
	bornTime Time,
	lockTime *Time,
	err error,
)

func (*DiffIter[K, V]) Seek

func (t *DiffIter[K, V]) Seek(pivot K) bool

type Float

type Float float64

func (Float) Less

func (f Float) Less(than Float) bool

type ID

type ID = memoryengine.ID

type IndexEntry

type IndexEntry[
	K Ordered[K],
	V any,
] struct {
	Index     Tuple
	Key       K
	VersionID int64
}

type IndexIter

type IndexIter[
	K Ordered[K],
	V any,
] struct {
	// contains filtered or unexported fields
}

func (*IndexIter[K, V]) Close

func (i *IndexIter[K, V]) Close() error

func (*IndexIter[K, V]) First

func (i *IndexIter[K, V]) First() bool

func (*IndexIter[K, V]) Item

func (i *IndexIter[K, V]) Item() *IndexEntry[K, V]

func (*IndexIter[K, V]) Next

func (i *IndexIter[K, V]) Next() bool

type Int

type Int int64

func (Int) Less

func (i Int) Less(than Int) bool

type IsolationPolicy

type IsolationPolicy struct {
	Read ReadPolicy
}

type Nullable

type Nullable struct {
	IsNull bool
	Value  any
}

func VectorAt

func VectorAt(vec *vector.Vector, i int) (value Nullable)

func (Nullable) AppendVector

func (n Nullable) AppendVector(
	vec *vector.Vector, mp *mpool.MPool)

func (Nullable) Equal

func (n Nullable) Equal(n2 Nullable) bool

type Ordered

type Ordered[To any] interface {
	Less(to To) bool
}

type PhysicalRow

type PhysicalRow[
	K Ordered[K],
	V any,
] struct {
	Key        K
	LastUpdate time.Time
	Versions   []Version[V]
}

func (*PhysicalRow[K, V]) Delete

func (p *PhysicalRow[K, V]) Delete(
	now Time,
	tx *Transaction,
) (
	newRow *PhysicalRow[K, V],
	version *Version[V],
	err error,
)

func (*PhysicalRow[K, V]) Insert

func (p *PhysicalRow[K, V]) Insert(
	now Time,
	tx *Transaction,
	value V,
) (
	newRow *PhysicalRow[K, V],
	version *Version[V],
	err error,
)

func (*PhysicalRow[K, V]) Read

func (p *PhysicalRow[K, V]) Read(now Time, tx *Transaction) (value V, err error)

Read reads the visible value from Values readTime's logical time should be monotonically increasing in one transaction to reflect commands order

func (*PhysicalRow[K, V]) Update

func (p *PhysicalRow[K, V]) Update(
	now Time,
	tx *Transaction,
	newValue V,
) (
	newRow *PhysicalRow[K, V],
	version *Version[V],
	err error,
)

type ReadPolicy

type ReadPolicy uint8
const (
	ReadCommitted ReadPolicy = iota + 1
	ReadSnapshot
	ReadNoStale
)

type ReverseIndexEntry

type ReverseIndexEntry[
	K Ordered[K],
	V any,
] struct {
	Key       K
	VersionID int64
	Index     Tuple
}

type Row

type Row[K any, V any] interface {
	Key() K
	Value() V
	Indexes() []Tuple
	UniqueIndexes() []Tuple
}

type Table

type Table[
	K Ordered[K],
	V any,
	R Row[K, V],
] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewTable

func NewTable[
	K Ordered[K],
	V any,
	R Row[K, V],
]() *Table[K, V, R]

func (*Table[K, V, R]) AbortTx

func (t *Table[K, V, R]) AbortTx(tx *Transaction) error

func (*Table[K, V, R]) CommitTx

func (t *Table[K, V, R]) CommitTx(tx *Transaction) error

func (*Table[K, V, R]) Delete

func (t *Table[K, V, R]) Delete(
	tx *Transaction,
	key K,
) error

func (*Table[K, V, R]) Dump

func (t *Table[K, V, R]) Dump(out io.Writer)

func (*Table[K, V, R]) FilterVersions

func (t *Table[K, V, R]) FilterVersions(filterFunc func(K, []Version[V]) ([]Version[V], error)) error

func (*Table[K, V, R]) Get

func (t *Table[K, V, R]) Get(
	tx *Transaction,
	key K,
) (
	value V,
	err error,
)

func (*Table[K, V, R]) Index

func (t *Table[K, V, R]) Index(tx *Transaction, index Tuple) (entries []*IndexEntry[K, V], err error)

func (*Table[K, V, R]) Insert

func (t *Table[K, V, R]) Insert(
	tx *Transaction,
	row R,
) error

func (*Table[K, V, R]) NewDiffIter

func (t *Table[K, V, R]) NewDiffIter(fromTime, toTime *Time) *DiffIter[K, V]

func (*Table[K, V, R]) NewIndexIter

func (t *Table[K, V, R]) NewIndexIter(tx *Transaction, min Tuple, max Tuple) *IndexIter[K, V]

func (*Table[K, V, R]) NewIter

func (t *Table[K, V, R]) NewIter(tx *Transaction) *TableIter[K, V]

func (*Table[K, V, R]) Update

func (t *Table[K, V, R]) Update(
	tx *Transaction,
	row R,
) error

func (*Table[K, V, R]) Upsert

func (t *Table[K, V, R]) Upsert(
	tx *Transaction,
	row R,
) error

type TableIter

type TableIter[
	K Ordered[K],
	V any,
] struct {
	// contains filtered or unexported fields
}

func (*TableIter[K, V]) Close

func (t *TableIter[K, V]) Close() error

func (*TableIter[K, V]) First

func (t *TableIter[K, V]) First() bool

func (*TableIter[K, V]) Item

func (t *TableIter[K, V]) Item() (row *PhysicalRow[K, V])

func (*TableIter[K, V]) Next

func (t *TableIter[K, V]) Next() bool

func (*TableIter[K, V]) Read

func (t *TableIter[K, V]) Read() (key K, value V, err error)

func (*TableIter[K, V]) Seek

func (t *TableIter[K, V]) Seek(key K) bool

type Text

type Text string

func (Text) Less

func (t Text) Less(than Text) bool

type Time

type Time struct {
	Timestamp timestamp.Timestamp
	Statement int
}

func Now

func Now(clock clock.Clock) Time

func (Time) After

func (t Time) After(t2 Time) bool

func (Time) Before

func (t Time) Before(t2 Time) bool

func (Time) Equal

func (t Time) Equal(t2 Time) bool

func (Time) IsZero

func (t Time) IsZero() bool

func (Time) String

func (t Time) String() string

func (*Time) Tick

func (t *Time) Tick()

func (Time) ToTxnTS

func (t Time) ToTxnTS() types.TS

type Transaction

type Transaction struct {
	ID              string
	BeginTime       Time
	Time            Time
	CommitTime      Time
	State           *Atomic[TransactionState]
	IsolationPolicy IsolationPolicy
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction(
	id string,
	t Time,
	isolationPolicy IsolationPolicy,
) *Transaction

func (*Transaction) Abort

func (t *Transaction) Abort() error

func (*Transaction) Commit

func (t *Transaction) Commit(commitTime Time) error

func (*Transaction) Copy

func (t *Transaction) Copy() *Transaction

type TransactionState

type TransactionState uint8

type Tuple

type Tuple []any

func (Tuple) Less

func (t Tuple) Less(than Tuple) bool

type TxCommitter

type TxCommitter interface {
	CommitTx(*Transaction) error
	AbortTx(*Transaction) error
}

type Uint

type Uint int64

func (Uint) Less

func (i Uint) Less(than Uint) bool

type Version

type Version[T any] struct {
	ID       int64
	BornTx   *Transaction
	BornTime Time
	LockTx   *Transaction
	LockTime Time
	Value    T
}

func (*Version[T]) Visible

func (v *Version[T]) Visible(now Time, txID string, policy ReadPolicy) bool

type WriteEntry

type WriteEntry[
	K Ordered[K],
	V any,
] struct {
	Transaction *Transaction
	Key         *K

	VersionID int64
}

Jump to

Keyboard shortcuts

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