memtable

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

Documentation

Index

Constants

View Source
const (
	Active = iota
	Committed
	Aborted
)

Variables

View Source
var (
	ToOrdered = memorytable.ToOrdered
	TypeMatch = memorytable.TypeMatch
	Min       = memorytable.Min
	Max       = memorytable.Max
)
View Source
var Serializable = IsolationPolicy{
	Read: ReadNoStale,
}
View Source
var SnapshotIsolation = IsolationPolicy{
	Read: ReadSnapshot,
}

Functions

This section is empty.

Types

type Bool

type Bool = memorytable.Bool

type Bytes

type Bytes = memorytable.Bytes

type DiffIter

type DiffIter[
	K memorytable.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 = memorytable.Float

type ID

type ID = memoryengine.ID

type IndexEntry

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

type IndexIter

type IndexIter[
	K memorytable.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 = memorytable.Int

type IsolationPolicy

type IsolationPolicy struct {
	Read ReadPolicy
}

type Nullable

type Nullable = memorytable.Nullable

type PhysicalRow

type PhysicalRow[
	K memorytable.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 memorytable.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 memorytable.Ordered[K],
	V any,
	R Row[K, V],
] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewTable

func NewTable[
	K memorytable.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 memorytable.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 = memorytable.Text

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           *memorytable.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 = memorytable.Tuple

type TxCommitter

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

type Uint

type Uint = memorytable.Uint

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 memorytable.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