in_mem_table

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEntryNotFound = errors.New("cannot insert row; matching entry not found")

Functions

func Delete

func Delete[V any](ctx *sql.Context, ops *ValueOps[V], is IndexedSet[V], row sql.Row) error

func Insert

func Insert[V any](ctx *sql.Context, ops *ValueOps[V], is IndexedSet[V], row sql.Row) error

func MultiDelete

func MultiDelete[V any](ctx *sql.Context, ops *MultiValueOps[V], is IndexedSet[V], row sql.Row) error

func MultiInsert

func MultiInsert[V any](ctx *sql.Context, ops *MultiValueOps[V], is IndexedSet[V], row sql.Row) error

func MultiToRows

func MultiToRows[V any](ctx *sql.Context, ops *MultiValueOps[V], is IndexedSet[V]) ([]sql.Row, error)

func MultiUpdate

func MultiUpdate[V any](ctx *sql.Context, ops *MultiValueOps[V], is IndexedSet[V], old, new sql.Row) error

func ToRows

func ToRows[V any](ctx *sql.Context, ops *ValueOps[V], is IndexedSet[V]) ([]sql.Row, error)

func Update

func Update[V any](ctx *sql.Context, ops *ValueOps[V], is IndexedSet[V], old, new sql.Row) error

Types

type IndexedSet

type IndexedSet[V any] struct {
	Keyers  []Keyer[V]
	Indexes []MultiMap[V]
}

func NewIndexedSet

func NewIndexedSet[V any](eqf func(V, V) bool, keyers []Keyer[V]) IndexedSet[V]

func (IndexedSet[V]) Clear

func (is IndexedSet[V]) Clear()

func (IndexedSet[V]) Count

func (is IndexedSet[V]) Count() int

func (IndexedSet[V]) Get

func (is IndexedSet[V]) Get(v V) (V, bool)

func (IndexedSet[V]) GetMany

func (is IndexedSet[V]) GetMany(keyer Keyer[V], k any) []V

func (IndexedSet[V]) Put

func (is IndexedSet[V]) Put(v V)

func (IndexedSet[V]) Remove

func (is IndexedSet[V]) Remove(v V) (res V, found bool)

func (IndexedSet[V]) RemoveMany

func (is IndexedSet[V]) RemoveMany(keyer Keyer[V], k any)

func (IndexedSet[V]) VisitEntries

func (is IndexedSet[V]) VisitEntries(f func(v V))

type IndexedSetTable

type IndexedSetTable[V any] struct {
	// contains filtered or unexported fields
}

func NewIndexedSetTable

func NewIndexedSetTable[V any](name string, schema sql.Schema, coll sql.CollationID, set IndexedSet[V], ops ValueOps[V], lock, rlock sync.Locker) *IndexedSetTable[V]

func (*IndexedSetTable[V]) Collation

func (t *IndexedSetTable[V]) Collation() sql.CollationID

func (*IndexedSetTable[V]) Deleter

func (t *IndexedSetTable[V]) Deleter(ctx *sql.Context) sql.RowDeleter

func (*IndexedSetTable[V]) Editor

func (t *IndexedSetTable[V]) Editor() editor

func (*IndexedSetTable[V]) Inserter

func (t *IndexedSetTable[V]) Inserter(ctx *sql.Context) sql.RowInserter

func (*IndexedSetTable[V]) Name

func (t *IndexedSetTable[V]) Name() string

func (*IndexedSetTable[V]) PartitionRows

func (t *IndexedSetTable[V]) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)

func (*IndexedSetTable[V]) Partitions

func (t *IndexedSetTable[V]) Partitions(ctx *sql.Context) (sql.PartitionIter, error)

func (*IndexedSetTable[V]) Replacer

func (t *IndexedSetTable[V]) Replacer(ctx *sql.Context) sql.RowReplacer

func (*IndexedSetTable[V]) Schema

func (t *IndexedSetTable[V]) Schema() sql.Schema

func (*IndexedSetTable[V]) Set

func (t *IndexedSetTable[V]) Set() IndexedSet[V]

func (*IndexedSetTable[V]) String

func (t *IndexedSetTable[V]) String() string

func (*IndexedSetTable[V]) TableId

func (t *IndexedSetTable[V]) TableId() sql.TableId

func (*IndexedSetTable[V]) Truncate

func (t *IndexedSetTable[V]) Truncate(ctx *sql.Context) (int, error)

func (*IndexedSetTable[V]) Updater

func (t *IndexedSetTable[V]) Updater(ctx *sql.Context) sql.RowUpdater

type IndexedSetTableEditor

type IndexedSetTableEditor[V any] struct {
	Set IndexedSet[V]
	Ops ValueOps[V]
}

func (*IndexedSetTableEditor[V]) Close

func (e *IndexedSetTableEditor[V]) Close(ctx *sql.Context) error

func (*IndexedSetTableEditor[V]) Delete

func (e *IndexedSetTableEditor[V]) Delete(ctx *sql.Context, row sql.Row) error

func (*IndexedSetTableEditor[V]) DiscardChanges

func (e *IndexedSetTableEditor[V]) DiscardChanges(ctx *sql.Context, cause error) error

func (*IndexedSetTableEditor[V]) Insert

func (e *IndexedSetTableEditor[V]) Insert(ctx *sql.Context, row sql.Row) error

func (*IndexedSetTableEditor[V]) StatementBegin

func (e *IndexedSetTableEditor[V]) StatementBegin(ctx *sql.Context)

func (*IndexedSetTableEditor[V]) StatementComplete

func (e *IndexedSetTableEditor[V]) StatementComplete(ctx *sql.Context) error

func (*IndexedSetTableEditor[V]) Update

func (e *IndexedSetTableEditor[V]) Update(ctx *sql.Context, old, new sql.Row) error

type Keyer

type Keyer[V any] interface {
	GetKey(V) any
}

type MultiIndexedSetTable

type MultiIndexedSetTable[V any] struct {
	// contains filtered or unexported fields
}

func NewMultiIndexedSetTable

func NewMultiIndexedSetTable[V any](name string, schema sql.Schema, coll sql.CollationID, set IndexedSet[V], ops MultiValueOps[V], lock, rlock sync.Locker) *MultiIndexedSetTable[V]

func (*MultiIndexedSetTable[V]) Collation

func (t *MultiIndexedSetTable[V]) Collation() sql.CollationID

func (*MultiIndexedSetTable[V]) Deleter

func (t *MultiIndexedSetTable[V]) Deleter(ctx *sql.Context) sql.RowDeleter

func (*MultiIndexedSetTable[V]) Editor

func (t *MultiIndexedSetTable[V]) Editor() editor

func (*MultiIndexedSetTable[V]) Inserter

func (t *MultiIndexedSetTable[V]) Inserter(ctx *sql.Context) sql.RowInserter

func (*MultiIndexedSetTable[V]) Name

func (t *MultiIndexedSetTable[V]) Name() string

func (*MultiIndexedSetTable[V]) PartitionRows

func (t *MultiIndexedSetTable[V]) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)

func (*MultiIndexedSetTable[V]) Partitions

func (t *MultiIndexedSetTable[V]) Partitions(ctx *sql.Context) (sql.PartitionIter, error)

func (*MultiIndexedSetTable[V]) Replacer

func (t *MultiIndexedSetTable[V]) Replacer(ctx *sql.Context) sql.RowReplacer

func (*MultiIndexedSetTable[V]) Schema

func (t *MultiIndexedSetTable[V]) Schema() sql.Schema

func (*MultiIndexedSetTable[V]) Set

func (t *MultiIndexedSetTable[V]) Set() IndexedSet[V]

func (*MultiIndexedSetTable[V]) String

func (t *MultiIndexedSetTable[V]) String() string

func (*MultiIndexedSetTable[V]) Updater

func (t *MultiIndexedSetTable[V]) Updater(ctx *sql.Context) sql.RowUpdater

type MultiIndexedSetTableEditor

type MultiIndexedSetTableEditor[V any] struct {
	Set IndexedSet[V]
	Ops MultiValueOps[V]
}

func (*MultiIndexedSetTableEditor[V]) Close

func (e *MultiIndexedSetTableEditor[V]) Close(ctx *sql.Context) error

func (*MultiIndexedSetTableEditor[V]) Delete

func (e *MultiIndexedSetTableEditor[V]) Delete(ctx *sql.Context, row sql.Row) error

func (*MultiIndexedSetTableEditor[V]) DiscardChanges

func (e *MultiIndexedSetTableEditor[V]) DiscardChanges(ctx *sql.Context, cause error) error

func (*MultiIndexedSetTableEditor[V]) Insert

func (e *MultiIndexedSetTableEditor[V]) Insert(ctx *sql.Context, row sql.Row) error

func (*MultiIndexedSetTableEditor[V]) StatementBegin

func (e *MultiIndexedSetTableEditor[V]) StatementBegin(ctx *sql.Context)

func (*MultiIndexedSetTableEditor[V]) StatementComplete

func (e *MultiIndexedSetTableEditor[V]) StatementComplete(ctx *sql.Context) error

func (*MultiIndexedSetTableEditor[V]) Update

func (e *MultiIndexedSetTableEditor[V]) Update(ctx *sql.Context, old, new sql.Row) error

type MultiMap

type MultiMap[V any] struct {
	Equals func(v1, v2 V) bool
	// contains filtered or unexported fields
}

func NewMultiMap

func NewMultiMap[V any](f func(v1, v2 V) bool) MultiMap[V]

func (MultiMap[V]) Clear

func (m MultiMap[V]) Clear()

func (MultiMap[V]) Get

func (m MultiMap[V]) Get(k any, v V) (res V, found bool)

func (MultiMap[V]) GetMany

func (m MultiMap[V]) GetMany(k any) []V

func (MultiMap[V]) Put

func (m MultiMap[V]) Put(k any, v V)

func (MultiMap[V]) Remove

func (m MultiMap[V]) Remove(k any, v V) (res V, found bool)

func (MultiMap[V]) VisitEntries

func (m MultiMap[V]) VisitEntries(f func(v V))

type MultiValueOps

type MultiValueOps[V any] struct {
	ToRows    func(*sql.Context, V) ([]sql.Row, error)
	FromRow   func(*sql.Context, sql.Row) (V, error)
	AddRow    func(*sql.Context, sql.Row, V) (V, error)
	DeleteRow func(*sql.Context, sql.Row, V) (V, error)
}

type OperationLockingTableEditor

type OperationLockingTableEditor struct {
	L sync.Locker
	E sql.TableEditor
}

func (OperationLockingTableEditor) Close

Close implements the sql.Closer interface.

func (OperationLockingTableEditor) Delete

func (e OperationLockingTableEditor) Delete(ctx *sql.Context, row sql.Row) error

Delete implements the sql.RowDeleter interface.

func (OperationLockingTableEditor) DiscardChanges

func (e OperationLockingTableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error

DiscardChanges implements the sql.TableEditor interface.

func (OperationLockingTableEditor) Insert

func (e OperationLockingTableEditor) Insert(ctx *sql.Context, row sql.Row) error

Insert implements the sql.RowInserter interface.

func (OperationLockingTableEditor) StatementBegin

func (e OperationLockingTableEditor) StatementBegin(ctx *sql.Context)

StatementBegin implements the sql.TableEditor interface.

func (OperationLockingTableEditor) StatementComplete

func (e OperationLockingTableEditor) StatementComplete(ctx *sql.Context) error

OperationComplete implements the sql.TableEditor interface.

func (OperationLockingTableEditor) Update

func (e OperationLockingTableEditor) Update(ctx *sql.Context, old sql.Row, new sql.Row) error

Update implements the sql.RowUpdater interface.

type StatementLockingTableEditor

type StatementLockingTableEditor struct {
	L sync.Locker
	E sql.TableEditor
}

func (StatementLockingTableEditor) Close

Close implements the sql.Closer interface.

func (StatementLockingTableEditor) Delete

func (e StatementLockingTableEditor) Delete(ctx *sql.Context, row sql.Row) error

Delete implements the sql.RowDeleter interface.

func (StatementLockingTableEditor) DiscardChanges

func (e StatementLockingTableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error

DiscardChanges implements the sql.TableEditor interface.

func (StatementLockingTableEditor) Insert

func (e StatementLockingTableEditor) Insert(ctx *sql.Context, row sql.Row) error

Insert implements the sql.RowInserter interface.

func (StatementLockingTableEditor) StatementBegin

func (e StatementLockingTableEditor) StatementBegin(ctx *sql.Context)

StatementBegin implements the sql.TableEditor interface.

func (StatementLockingTableEditor) StatementComplete

func (e StatementLockingTableEditor) StatementComplete(ctx *sql.Context) error

StatementComplete implements the sql.TableEditor interface.

func (StatementLockingTableEditor) Update

func (e StatementLockingTableEditor) Update(ctx *sql.Context, old sql.Row, new sql.Row) error

Update implements the sql.RowUpdater interface.

type ValueOps

type ValueOps[V any] struct {
	ToRow         func(*sql.Context, V) (sql.Row, error)
	FromRow       func(*sql.Context, sql.Row) (V, error)
	UpdateWithRow func(*sql.Context, sql.Row, V) (V, error)
}

Jump to

Keyboard shortcuts

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