store

package
v0.0.0-...-5ba0888 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear[V any, R Row](store Store[R], key R)

Clear clears the value for the given key.

func Get

func Get[V any, R Row](store Store[R], key R) (V, bool)

Get retrieves the given value. Get will not create a new column.

func Persist

func Persist[R Row](s Store[R], wr io.Writer) error

func PersistFS

func PersistFS[R Row](s Store[R], dir WritableFS, name string) error

func Push

func Push[V any](it Iterator[V]) iter.Seq[V]

func Push2

func Push2[U, V any](it Iterator2[U, V]) iter.Seq2[U, V]

func RegisterColumnImpl

func RegisterColumnImpl[C, D any]()

func RegisterColumnType

func RegisterColumnType[C any]()

func Restore

func Restore[R Row](store Store[R], rd io.Reader) error

func RestoreFS

func RestoreFS[R Row](s Store[R], dir WritableFS, name string) error

func Set

func Set[V any, R Row](store Store[R], key R, value V)

Set sets the value for the given key.

func SimpleValueAs

func SimpleValueAs[U valued[V], V any, R Row](v *Value[R]) (V, bool)

func SimpleValueMustBe

func SimpleValueMustBe[U valued[V], V any, R Row](v *Value[R]) V

Types

type AggregateFn

type AggregateFn[R Row] = func(arena *Arena[R], agg *Value[R], val *Value[R]) *Value[R]

type AllOf

type AllOf[R Row] struct {
	Source []Operation[R]
	Value  ExecuteFn[R, Composite[R]]
}

func (AllOf[R]) Execute

func (o AllOf[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type AllOfExecutor

type AllOfExecutor[R Row] interface {
	ExecuteAllOf(*Arena[R], AllOf[R]) (Result[R], bool)
}

type Allocator

type Allocator[V any] interface {
	New() *V
	Slice(int) []V
	Append(s []V, v ...V) []V
	// contains filtered or unexported methods
}

func AllocatorFor

func AllocatorFor[V any, R Row](a *Arena[R]) Allocator[V]

type AnyOf

type AnyOf[R Row] []Operation[R]

func (AnyOf[R]) Execute

func (o AnyOf[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type Arena

type Arena[R Row] struct {
	// contains filtered or unexported fields
}

func (*Arena[R]) Copy

func (a *Arena[R]) Copy(v *Value[R]) *Value[R]

func (*Arena[R]) Empty

func (a *Arena[R]) Empty() *Value[R]

func (*Arena[R]) Group

func (a *Arena[R]) Group(key any, value *Value[R]) *Value[R]

func (*Arena[R]) Join

func (a *Arena[R]) Join(left, right *Value[R]) *Value[R]

func (*Arena[R]) Multi

func (a *Arena[R]) Multi(u []*Value[R]) *Value[R]

func (*Arena[R]) Release

func (a *Arena[R]) Release()

func (*Arena[R]) Simple

func (a *Arena[R]) Simple(u any) *Value[R]

func (*Arena[R]) Sub

func (a *Arena[R]) Sub() *Arena[R]

type Column

type Column[R Row, V any] interface {
	Get(R) (V, bool)
	GetAll(R) ([]V, bool)
	Set(R, V)
	Clear(R)
	ClearAll(R)
	Slot(int) Column[R, V]
	All() Iterator2[R, V]
	AllSlots() Iterator2[R, V]

	// Delete the whole column (including slots).
	Delete()
}

func ColumnAs

func ColumnAs[V any, R Row](c Column[R, any]) (Column[R, V], bool)

func ColumnFor

func ColumnFor[V any, R Row](s Store[R]) Column[R, V]

func ReadColumn

func ReadColumn[R Row](s Store[R], col reflect.Type) Column[R, any]

func ReadColumnFor

func ReadColumnFor[V any, R Row](s Store[R]) Column[R, V]

type Composite

type Composite[R Row] interface {
	Set(int, *Value[R])
	AsValue(*Arena[R]) *Value[R]
}

type Const

type Const[R Row] struct {
	Value *Value[R]
}

func (Const[R]) Execute

func (o Const[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type EmptyColumn

type EmptyColumn[R Row, V any] struct{}

func (EmptyColumn[R, V]) All

func (EmptyColumn[R, V]) All() Iterator2[R, V]

func (EmptyColumn[R, V]) AllSlots

func (EmptyColumn[R, V]) AllSlots() Iterator2[R, V]

func (EmptyColumn[R, V]) Clear

func (EmptyColumn[R, V]) Clear(R)

func (EmptyColumn[R, V]) ClearAll

func (EmptyColumn[R, V]) ClearAll(R)

func (EmptyColumn[R, V]) Delete

func (EmptyColumn[R, V]) Delete()

func (EmptyColumn[R, V]) Get

func (EmptyColumn[R, V]) Get(R) (V, bool)

func (EmptyColumn[R, V]) GetAll

func (EmptyColumn[R, V]) GetAll(R) ([]V, bool)

func (EmptyColumn[R, V]) Set

func (EmptyColumn[R, V]) Set(R, V)

func (EmptyColumn[R, V]) Slot

func (EmptyColumn[R, V]) Slot(int) Column[R, V]

type EmptyCursor

type EmptyCursor[R Row, V any] struct{}

func (EmptyCursor[R, V]) Next

func (EmptyCursor[R, V]) Next() (R, V, bool)

func (EmptyCursor[R, V]) Stop

func (EmptyCursor[R, V]) Stop()

type EmptyIterator

type EmptyIterator[V any] struct{}

func (EmptyIterator[V]) Next

func (EmptyIterator[V]) Next() (V, bool)

func (EmptyIterator[V]) Stop

func (EmptyIterator[V]) Stop()

type EmptyIterator2

type EmptyIterator2[U, V any] struct{}

func (EmptyIterator2[U, V]) Next

func (EmptyIterator2[U, V]) Next() (U, V, bool)

func (EmptyIterator2[U, V]) Stop

func (EmptyIterator2[U, V]) Stop()

type EmptyResult

type EmptyResult[R Row] struct{}

func (EmptyResult[R]) Next

func (EmptyResult[R]) Next(*Arena[R]) (*Value[R], bool)

func (EmptyResult[R]) Stop

func (EmptyResult[R]) Stop()

type ExecuteFn

type ExecuteFn[R Row, V any] = func(*Arena[R]) V

type GroupBy

type GroupBy[R Row, K cmp.Ordered] struct {
	Source    Operation[R]
	Key       ExecuteFn[R, KeyFn[R, K]]
	Aggregate ExecuteFn[R, AggregateFn[R]]
}

func (GroupBy[R, K]) Execute

func (o GroupBy[R, K]) Execute(a *Arena[R], s Store[R]) Result[R]

type Iterator

type Iterator[V any] interface {
	Next() (V, bool)
	Stop()
}

type Iterator2

type Iterator2[U, V any] interface {
	Next() (U, V, bool)
	Stop()
}

func All

func All[V any, R Row](store Store[R]) Iterator2[R, V]

All returns a new cursor for iterating over the column. All will not create a new column; if the column does not exist, All will return an empty cursor.

func CursorAs

func CursorAs[V any, R Row](c Iterator2[R, any]) (Iterator2[R, V], bool)

type Join

type Join[R Row] struct {
	Left, Right Operation[R]
	Join        ExecuteFn[R, JoinFn[R]]
}

func (Join[R]) Execute

func (o Join[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type JoinFn

type JoinFn[R Row] = func(arena *Arena[R], left, right *Value[R]) (*Value[R], bool)

type KeyFn

type KeyFn[R Row, K any] = func(*Arena[R], *Value[R]) K

type Marshaller

type Marshaller interface {
	cate.Marshaller
	cate.Unmarshaller
}

type Maybe

type Maybe[V any] struct {
	Value V
	Ok    bool
}

func NoneOf

func NoneOf[V any]() Maybe[V]

func SomeOf

func SomeOf[V any](v V) Maybe[V]

type None

type None struct{}

type Operation

type Operation[R Row] interface {
	Execute(*Arena[R], Store[R]) Result[R]
}

type Persister

type Persister[R Row] interface {
	Persist(R, Store[R], WritableFS) error
	Restore(R, Store[R], WritableFS) error
}

type Read

type Read[R Row] struct {
	Type    reflect.Type
	Slot    int
	Default ExecuteFn[R, *Value[R]]
}

func (Read[R]) Execute

func (o Read[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type ReadAll

type ReadAll[R Row] struct {
	Type reflect.Type
}

func (ReadAll[R]) Execute

func (o ReadAll[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type ReadExecutor

type ReadExecutor[R Row] interface {
	ExecuteRead(*Arena[R], Read[R]) (Result[R], bool)
}

type Result

type Result[R Row] interface {
	Next(*Arena[R]) (*Value[R], bool)
	Stop()
}

type Row

type Row interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type RowCursor

type RowCursor[R Row] struct {
	// contains filtered or unexported fields
}

func (*RowCursor[R]) Next

func (it *RowCursor[R]) Next() (R, bool)

func (*RowCursor[R]) Reset

func (it *RowCursor[R]) Reset()

func (*RowCursor[T]) Stop

func (it *RowCursor[T]) Stop()

type RowManager

type RowManager[R Row] interface {
	ManagedRows(R, Store[R]) RowSet[R]
}

type RowSet

type RowSet[R Row] struct {
	// contains filtered or unexported fields
}

func RowSetWith

func RowSetWith[R Row](rows ...R) RowSet[R]

func (*RowSet[R]) Add

func (s *RowSet[R]) Add(key R)

func (*RowSet[R]) AddAll

func (s *RowSet[R]) AddAll(r RowSet[R])

func (RowSet[R]) Copy

func (s RowSet[R]) Copy() RowSet[R]

func (RowSet[R]) Cursor

func (s RowSet[R]) Cursor() RowCursor[R]

func (RowSet[R]) Has

func (s RowSet[R]) Has(key R) bool

func (RowSet[R]) HasAny

func (s RowSet[R]) HasAny(r RowSet[R]) bool

func (*RowSet[R]) IntersectWith

func (s *RowSet[R]) IntersectWith(r RowSet[R])

func (RowSet[R]) IsEmpty

func (s RowSet[R]) IsEmpty() bool

func (*RowSet[R]) MarshalCATE

func (s *RowSet[R]) MarshalCATE(*cate.Encoder) (cate.Value, error)

func (*RowSet[R]) Remove

func (s *RowSet[R]) Remove(key R)

func (*RowSet[R]) RemoveAll

func (s *RowSet[R]) RemoveAll(r RowSet[R])

func (*RowSet[R]) Reset

func (s *RowSet[R]) Reset()

func (RowSet[R]) Size

func (s RowSet[R]) Size() int

func (RowSet[R]) Slice

func (s RowSet[R]) Slice() []R

func (*RowSet[R]) UnmarshalCATE

func (s *RowSet[R]) UnmarshalCATE(_ *cate.Decoder, value cate.Value) error

type Select

type Select[R Row] struct {
	Source Operation[R]
	Select ExecuteFn[R, SelectFn[R]]
}

func (Select[R]) Execute

func (o Select[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type SelectFn

type SelectFn[R Row] = func(*Arena[R], *Value[R]) (*Value[R], bool)

type SimpleValueSet

type SimpleValueSet[R Row, V any] struct {
	// contains filtered or unexported fields
}

func SimpleValueAllocatorFor

func SimpleValueAllocatorFor[V any, R Row](a *Arena[R]) SimpleValueSet[R, V]

func (SimpleValueSet[R, V]) Value

func (s SimpleValueSet[R, V]) Value(value V) *Value[R]

type SingleValueIterator

type SingleValueIterator[V any] struct {
	Value V
	Ok    bool
}

func (*SingleValueIterator[V]) Next

func (it *SingleValueIterator[V]) Next() (V, bool)

func (*SingleValueIterator[V]) Stop

func (it *SingleValueIterator[V]) Stop()

type SliceIterator

type SliceIterator[V any] []V

func (*SliceIterator[V]) Next

func (it *SliceIterator[V]) Next() (V, bool)

func (*SliceIterator[V]) Stop

func (it *SliceIterator[V]) Stop()

type Store

type Store[R Row] interface {
	// For creates a new store scoped to the given rows.
	For(RowSet[R]) Store[R]

	// Rows returns the set of all populated rows. Rows is optimistic - the
	// presence of a row in the row set does not guarantee that row is
	// present in any column.
	Rows() RowSet[R]

	// Row iterates over the attributes of a row.
	Row(R) Iterator2[reflect.Type, any]

	// HasRow returns true if any column contains an entry for the given
	// row.
	HasRow(row R) bool

	// Columns iterates over all populated columns.
	Columns() Iterator[reflect.Type]

	// Column returns a specific column.
	Column(reflect.Type) Column[R, any]
}

type Value

type Value[R Row] struct {
	// contains filtered or unexported fields
}

func NewSimpleValue

func NewSimpleValue[R Row, V any](value V) *Value[R]

func NewSimpleValueFrom

func NewSimpleValueFrom[V any, R Row](a *Arena[R], value V) *Value[R]

func (*Value[R]) Equal

func (v *Value[R]) Equal(u *Value[R]) bool

func (*Value[R]) Group

func (v *Value[R]) Group() (any, *Value[R])

func (*Value[R]) HasRow

func (v *Value[R]) HasRow() bool

func (*Value[R]) Join

func (v *Value[R]) Join() (left, right *Value[R])

func (*Value[R]) Kind

func (v *Value[R]) Kind() ValueKind

func (*Value[R]) Multi

func (v *Value[R]) Multi() []*Value[R]

func (*Value[R]) Row

func (v *Value[R]) Row() R

func (*Value[R]) Simple

func (v *Value[R]) Simple() any

func (*Value[R]) WithGroup

func (v *Value[R]) WithGroup(key any, value *Value[R]) *Value[R]

func (*Value[R]) WithJoin

func (v *Value[R]) WithJoin(left, right *Value[R]) *Value[R]

func (*Value[R]) WithMulti

func (v *Value[R]) WithMulti(u []*Value[R]) *Value[R]

func (*Value[R]) WithRow

func (v *Value[R]) WithRow(row R) *Value[R]

func (*Value[R]) WithSimple

func (v *Value[R]) WithSimple(u any) *Value[R]

type ValueKind

type ValueKind int
const (
	EmptyValue ValueKind = iota
	SimpleValue
	MultiValue
	GroupedValue
	JoinedValue
)

type Without

type Without[R Row] struct {
	Source Operation[R]
}

func (Without[R]) Execute

func (o Without[R]) Execute(a *Arena[R], s Store[R]) Result[R]

type WritableFS

type WritableFS interface {
	fs.FS
	Subdir(string) (WritableFS, error)
	Create(string) (WritableFile, error)
}

func DirFS

func DirFS(dir string) WritableFS

type WritableFile

type WritableFile interface {
	fs.File
	io.Writer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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