Documentation
¶
Index ¶
- func FirstInRange[R any](me relation[R], gte, lt R) (ret g.Option[R])
- func GetEq[R any](r relation[R], key R) (eq g.Option[R])
- func Iter2[K, V any](me tableInterface[Pair[K, V]]) iter.Seq2[K, V]
- func IterFirst[K, V any](me tableInterface[Pair[K, V]]) iter.Seq[K]
- func IterRange[R any](me relation[R], gte, lt R) iter.Seq[R]
- func IterSecond[K, V any](me tableInterface[Pair[K, V]]) iter.Seq[V]
- func MapPairIterLeft[K, V any](i iter.Seq[Pair[K, V]]) iter.Seq[K]
- func MapPairIterRight[K, V any](i iter.Seq[Pair[K, V]]) iter.Seq[V]
- type CompareFunc
- type Index
- type InsteadOf
- type Iter
- type Map
- func (me *Map[K, V]) Alter(key K, updateFunc func(V, bool) (V, bool))
- func (me Map) Change(old, new g.Option[R]) bool
- func (me Map) Changed(old, new g.Option[R])
- func (me Map) Contains(r R) bool
- func (me *Map[K, V]) ContainsKey(k K) bool
- func (me Map) CreateOrReplace(r R)
- func (me *Map[K, V]) Delete(k K) (removed bool)
- func (me *Map[K, V]) Get(k K) (v V, ok bool)
- func (me Map) GetCmp() CompareFunc[R]
- func (me Map) GetFirst() (r R, ok bool)
- func (me Map) GetGte(r R) (ret g.Option[R])
- func (me *Map[K, V]) Init(cmp func(a, b K) int)
- func (me Map) Iter(yield func(R) bool)
- func (me Map) IterFrom(start R) iter.Seq[R]
- func (me Map) IterFromWhile(gte R, while func(R) bool) iter.Seq[R]
- func (me Map) Len() int
- func (me Map) MinRecord() (_ R)
- func (me Map) OnChange(t triggerFunc[R])
- func (me *Map[K, V]) OnValueChange(do mapTriggerFunc[K, V])
- func (me Map) Poison()
- func (me Map) SelectFirstIf(gte R, filter func(r R) bool) (ret g.Option[R])
- func (me Map) SelectFirstWhere(gte R, where func(r R) bool) (ret g.Option[R])
- func (me *Map[K, V]) SetMinRecord(min K)
- func (me Map) Unpoison()
- func (me *Map[K, V]) Update(key K, updateFunc func(V) V) (res UpdateResult)
- func (me *Map[K, V]) UpdateOrCreate(k K, updateFunc func(old V) V) (created bool)
- type Pair
- type Record
- type Table
- func (me *Table[R]) AddInsteadOf(f InsteadOf[R])
- func (me *Table) Change(old, new g.Option[R]) bool
- func (me *Table) Changed(old, new g.Option[R])
- func (me *Table) Contains(r R) bool
- func (me *Table) Create(r R) (created bool)
- func (me *Table) CreateOrReplace(r R)
- func (me *Table) Delete(r R) (removed bool)
- func (me *Table) GetCmp() CompareFunc[R]
- func (me *Table) GetFirst() (r R, ok bool)
- func (me *Table) GetGte(r R) (ret g.Option[R])
- func (me *Table) Init(cmp CompareFunc[R])
- func (me *Table) Iter(yield func(R) bool)
- func (me *Table) IterFrom(start R) iter.Seq[R]
- func (me *Table) IterFromWhile(gte R, while func(R) bool) iter.Seq[R]
- func (me *Table) Len() int
- func (me *Table) MinRecord() (_ R)
- func (me *Table) OnChange(t triggerFunc[R])
- func (me *Table) Poison()
- func (me *Table) SelectFirstIf(gte R, filter func(r R) bool) (ret g.Option[R])
- func (me *Table) SelectFirstWhere(gte R, where func(r R) bool) (ret g.Option[R])
- func (me *Table) SetMinRecord(min R)
- func (me *Table) Unpoison()
- func (me *Table) Update(start R, updateFunc func(r R) R) (res UpdateResult)
- type Table2
- func (me Table2) Change(old, new g.Option[R]) bool
- func (me Table2) Changed(old, new g.Option[R])
- func (me Table2) Contains(r R) bool
- func (me *Table2[K, V]) Create(first K, second V) bool
- func (me Table2) CreateOrReplace(r R)
- func (me Table2) Delete(r R) (removed bool)
- func (me Table2) GetCmp() CompareFunc[R]
- func (me Table2) GetFirst() (r R, ok bool)
- func (me Table2) GetGte(r R) (ret g.Option[R])
- func (me *Table2[K, V]) Init(cmpFunc CompareFunc[Pair[K, V]])
- func (me Table2) Iter(yield func(R) bool)
- func (me Table2) IterFrom(start R) iter.Seq[R]
- func (me Table2) IterFromWhile(gte R, while func(R) bool) iter.Seq[R]
- func (me *Table2[K, V]) IterKeysFrom(start K) iter.Seq[K]
- func (me Table2) Len() int
- func (me Table2) MinRecord() (_ R)
- func (me Table2) OnChange(t triggerFunc[R])
- func (me Table2) Poison()
- func (me Table2) SelectFirstIf(gte R, filter func(r R) bool) (ret g.Option[R])
- func (me Table2) SelectFirstWhere(gte R, where func(r R) bool) (ret g.Option[R])
- func (me Table2) SetMinRecord(min R)
- func (me Table2) Unpoison()
- func (me Table2) Update(start R, updateFunc func(r R) R) (res UpdateResult)
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstInRange ¶
Types ¶
type CompareFunc ¶
type Index ¶
type Index[R any] interface { SelectFirstIf(gte R, filter func(r R) bool) g.Option[R] SelectFirstWhere(gte R, filter func(r R) bool) g.Option[R] GetFirst() (R, bool) // contains filtered or unexported methods }
func NewFullIndex ¶
func NewFullIndex[R comparable](from tableInterface[R], cmpFunc CompareFunc[R], minRecord R) (index Index[R])
A full index that doesn't require mapping records.
func NewFullMappedIndex ¶
func NewFullMappedIndex[F, T comparable]( from tableInterface[F], cmpFunc CompareFunc[T], mapFunc func(F) T, minRecord T, ) Index[T]
An index on a mapped form of the upstream data. What about cross-table and partial indexes?
type Iter ¶
func IterClusteredWhere ¶
Iters from a point, assuming that where can only be true consecutively from that point and nowhere else.
type Map ¶
A table where the record has a key and value. Currently maps onto Table2 using Pair, but perhaps requiring the record implements a KeyValue interface would be better. K and V are Record to propagate the comparable requirement for now. TODO: We could use an actual map, and implement relation. Another thing we can do is actually use btree.Map's value, I'm not sure if btree is smarter about that.
func (Map) Change ¶
When you know the existing state and the destination state. Most efficient. This is used by indexes, but allows insteadOf. Not sure if that's a good idea.
func (Map) Contains ¶
func (me Map) Contains(r R) bool
Should this only return a single value ever? Should we check?
func (*Map[K, V]) ContainsKey ¶
func (Map) CreateOrReplace ¶
func (me Map) CreateOrReplace(r R)
func (Map) GetCmp ¶
func (me Map) GetCmp() CompareFunc[R]
func (Map) GetGte ¶
Gets the first record greater than or equal. Hope to avoid allocation for iterator.
func (Map) IterFromWhile ¶
func (Map) MinRecord ¶
func (me Map) MinRecord() (_ R)
Returns the minimal record of type R, which may not be the same as the zero value for the record. Convenient to avoid having to look up complex types for small expressions. Could be a global function. Should definitely be if this is invoked through an interface. Panics if the min record wasn't set. The concept of MinRecord might be flawed if there are conditions in the ordering of values in a record. In that case the user may have to modify "intermediate" fields in order to set a GTE record that's appropriate midway in the table.
func (*Map[K, V]) OnValueChange ¶
func (me *Map[K, V]) OnValueChange(do mapTriggerFunc[K, V])
func (Map) Poison ¶ added in v1.79.5
func (me Map) Poison()
Detect recursive use of table when it's a bad idea. To be replaced with a better fix sometime.
func (Map) SelectFirstIf ¶
func (Map) SelectFirstWhere ¶
func (*Map[K, V]) SetMinRecord ¶
func (me *Map[K, V]) SetMinRecord(min K)
Maps don't compare on the value, so we can leave them as zeroes.
func (*Map[K, V]) Update ¶
func (me *Map[K, V]) Update(key K, updateFunc func(V) V) (res UpdateResult)
Inner table update is unimplemented, because
func (*Map[K, V]) UpdateOrCreate ¶
Update the function otherwise create it, in both cases using the update function provided.
type Record ¶
type Record comparable
Comparable for value-comparison on update function. I think it might be a reasonable requirement. I could add others for the Table2 style, and Map, and allow some global functions to require conforming record types.
type Table ¶
type Table[R comparable] struct { // contains filtered or unexported fields }
Table-only stuff. table is the internal common-relation stuff.
func (*Table[R]) AddInsteadOf ¶ added in v1.79.5
func (*Table) Change ¶
When you know the existing state and the destination state. Most efficient. This is used by indexes, but allows insteadOf. Not sure if that's a good idea.
func (*Table) Contains ¶
func (me *Table) Contains(r R) bool
Should this only return a single value ever? Should we check?
func (*Table) CreateOrReplace ¶
func (me *Table) CreateOrReplace(r R)
func (*Table) GetCmp ¶
func (me *Table) GetCmp() CompareFunc[R]
func (*Table) GetGte ¶
Gets the first record greater than or equal. Hope to avoid allocation for iterator.
func (*Table) Init ¶
func (me *Table) Init(cmp CompareFunc[R])
func (*Table) IterFromWhile ¶
func (*Table) Len ¶
func (me *Table) Len() int
Not count because that could imply more than O(1) work.
func (*Table) MinRecord ¶
func (me *Table) MinRecord() (_ R)
Returns the minimal record of type R, which may not be the same as the zero value for the record. Convenient to avoid having to look up complex types for small expressions. Could be a global function. Should definitely be if this is invoked through an interface. Panics if the min record wasn't set. The concept of MinRecord might be flawed if there are conditions in the ordering of values in a record. In that case the user may have to modify "intermediate" fields in order to set a GTE record that's appropriate midway in the table.
func (*Table) Poison ¶ added in v1.79.5
func (me *Table) Poison()
Detect recursive use of table when it's a bad idea. To be replaced with a better fix sometime.
func (*Table) SelectFirstIf ¶
func (*Table) SelectFirstWhere ¶
func (*Table) SetMinRecord ¶
func (me *Table) SetMinRecord(min R)
func (*Table) Update ¶
func (me *Table) Update(start R, updateFunc func(r R) R) (res UpdateResult)
Doesn't currently allow replacing items other than itself.
type Table2 ¶
type Table2[K, V comparable] struct { *Table[Pair[K, V]] }
func (Table2) Change ¶
When you know the existing state and the destination state. Most efficient. This is used by indexes, but allows insteadOf. Not sure if that's a good idea.
func (Table2) Contains ¶
func (me Table2) Contains(r R) bool
Should this only return a single value ever? Should we check?
func (Table2) CreateOrReplace ¶
func (me Table2) CreateOrReplace(r R)
func (Table2) GetCmp ¶
func (me Table2) GetCmp() CompareFunc[R]
func (Table2) GetGte ¶
Gets the first record greater than or equal. Hope to avoid allocation for iterator.
func (*Table2[K, V]) Init ¶
func (me *Table2[K, V]) Init(cmpFunc CompareFunc[Pair[K, V]])
func (Table2) IterFromWhile ¶
func (*Table2[K, V]) IterKeysFrom ¶
func (Table2) Len ¶
func (me Table2) Len() int
Not count because that could imply more than O(1) work.
func (Table2) MinRecord ¶
func (me Table2) MinRecord() (_ R)
Returns the minimal record of type R, which may not be the same as the zero value for the record. Convenient to avoid having to look up complex types for small expressions. Could be a global function. Should definitely be if this is invoked through an interface. Panics if the min record wasn't set. The concept of MinRecord might be flawed if there are conditions in the ordering of values in a record. In that case the user may have to modify "intermediate" fields in order to set a GTE record that's appropriate midway in the table.
func (Table2) Poison ¶ added in v1.79.5
func (me Table2) Poison()
Detect recursive use of table when it's a bad idea. To be replaced with a better fix sometime.
func (Table2) SelectFirstIf ¶
func (Table2) SelectFirstWhere ¶
func (Table2) SetMinRecord ¶
func (me Table2) SetMinRecord(min R)
func (Table2) Update ¶
func (me Table2) Update(start R, updateFunc func(r R) R) (res UpdateResult)
Doesn't currently allow replacing items other than itself.