Documentation
¶
Index ¶
- Constants
- func ValueFromAny[T any](value any) (T, error)
- type BinaryExpr
- type BitSet
- func (b *BitSet[V]) And(other *BitSet[V])
- func (b *BitSet[V]) AndNot(other *BitSet[V])
- func (b *BitSet[V]) Clear()
- func (b *BitSet[V]) Contains(value V) bool
- func (b *BitSet[V]) Copy() *BitSet[V]
- func (b *BitSet[V]) CopyInto(buf []uint64) *BitSet[V]
- func (b *BitSet[V]) Count() int
- func (b *BitSet[V]) IsEmpty() bool
- func (b *BitSet[V]) Len() int
- func (b *BitSet[V]) Max() int
- func (b *BitSet[V]) MaxSetIndex() int
- func (b *BitSet[V]) Min() int
- func (b *BitSet[V]) Or(other *BitSet[V])
- func (b *BitSet[V]) Range(from, to V, visit func(v V) bool)
- func (b *BitSet[V]) Set(value V)
- func (b *BitSet[V]) Shrink()
- func (b *BitSet[V]) ToSlice() []V
- func (b *BitSet[V]) UnSet(value V) bool
- func (b *BitSet[V]) Values(yield func(V) bool)
- func (b *BitSet[V]) ValuesBatch(yield func([]V) bool)
- func (b *BitSet[V]) Xor(other *BitSet[V])
- type Expr
- type ExprKind
- type Filter
- type Filter32
- type FilterByName
- type FilterByName32
- type FreeList
- func (l *FreeList[T]) CompactLinear(onMove func(oldIndex, newIndex int))
- func (l *FreeList[T]) CompactUnstable()
- func (l *FreeList[T]) Count() int
- func (l *FreeList[T]) Get(index int) (T, bool)
- func (l *FreeList[T]) Insert(item T) int
- func (l *FreeList[T]) Iter() iter.Seq2[int, T]
- func (l *FreeList[T]) Remove(index int) bool
- func (l *FreeList[T]) Set(index int, newItem T) (T, bool)
- type FromField
- type Handle
- type Index
- type Index32
- type InvalidArgsLenError
- type InvalidNameError
- type InvalidOperationError
- type InvalidValueTypeError
- type List
- func (l *List[T, ID]) Contains(id ID) bool
- func (l *List[T, ID]) Count() int
- func (l *List[T, ID]) CreateIndex(fieldName string, index Index32[T]) error
- func (l *List[T, ID]) Get(id ID) (T, error)
- func (l *List[T, ID]) Insert(item T) int
- func (l *List[T, ID]) Query(query Query32) (QueryResult[T, ID], error)
- func (l *List[T, ID]) QueryStr(queryStr string) (QueryResult[T, ID], error)
- func (l *List[T, ID]) Remove(id ID) (bool, error)
- func (l *List[T, ID]) RemoveIndex(fieldName string)
- func (l *List[T, ID]) Update(item T) error
- type MapIndex
- type NoIdIndexDefinedError
- type NotExpr
- type Op
- type OverflowError
- type PageInfo
- type Query
- type Query32
- func All() Query32
- func Eq(fieldName string, val any) Query32
- func Ge(fieldName string, val any) Query32
- func Gt(fieldName string, val any) Query32
- func ID(val any) Query32
- func In(fieldName string, vals ...any) Query32
- func IsNil[V any](fieldName string) Query32
- func Le(fieldName string, val any) Query32
- func Lt(fieldName string, val any) Query32
- func NotEq(fieldName string, val any) Query32
- func Parse(input string) (Query32, error)
- func WithPrefix(fieldName string, val string) Query32
- type QueryResult
- func (q *QueryResult[T, ID]) Count() int
- func (q *QueryResult[T, ID]) IsEmpty() bool
- func (q *QueryResult[T, ID]) Pagination(offset, limit uint32) ([]T, PageInfo)
- func (q *QueryResult[T, ID]) RemoveAll()
- func (q *QueryResult[T, ID]) Sort(less func(*T, *T) bool) []T
- func (q *QueryResult[T, ID]) Values() []T
- type SkipList
- func (sl *SkipList[K, V]) Delete(key K) bool
- func (sl *SkipList[K, V]) FindFromSortedKeys(visit VisitFn[K, V], keys ...K)
- func (sl *SkipList[K, V]) FirstValue() (V, bool)
- func (sl *SkipList[K, V]) Get(key K) (V, bool)
- func (sl *SkipList[K, V]) Greater(key K, visit VisitFn[K, V])
- func (sl *SkipList[K, V]) GreaterEqual(key K, visit VisitFn[K, V])
- func (sl *SkipList[K, V]) LastValue() (V, bool)
- func (sl *SkipList[K, V]) Less(key K, visit VisitFn[K, V])
- func (sl *SkipList[K, V]) LessEqual(key K, visit VisitFn[K, V])
- func (sl *SkipList[K, V]) MaxKey() (K, bool)
- func (sl *SkipList[K, V]) MinKey() (K, bool)
- func (sl *SkipList[K, V]) Put(key K, value V) bool
- func (sl *SkipList[K, V]) Range(from, to K, visit VisitFn[K, V])
- func (sl *SkipList[K, V]) StringStartsWith(prefix K, visit VisitFn[K, V]) bool
- func (sl *SkipList[K, V]) Traverse(visit VisitFn[K, V]) bool
- type SliceSet
- func (s *SliceSet[V]) And(other *SliceSet[V])
- func (s *SliceSet[V]) AndNot(other *SliceSet[V])
- func (s *SliceSet[V]) Contains(value V) bool
- func (s *SliceSet[V]) Copy() *SliceSet[V]
- func (s *SliceSet[V]) Count() int
- func (s *SliceSet[V]) Len() int
- func (s *SliceSet[V]) Max() int
- func (s *SliceSet[V]) MaxSetIndex() int
- func (s *SliceSet[V]) Min() int
- func (s *SliceSet[V]) Or(other *SliceSet[V])
- func (s *SliceSet[V]) Set(value V)
- func (s *SliceSet[V]) ToBitSet() *BitSet[V]
- func (s *SliceSet[V]) ToSlice() []V
- func (s *SliceSet[V]) UnSet(value V) bool
- func (s *SliceSet[V]) Values(yield func(V) bool)
- func (s *SliceSet[V]) Xor(other *SliceSet[V])
- type SlotMap
- type SortedIndex
- type TermExpr
- type TermManyExpr
- type TrigramIndex
- type UnexpectedTokenError
- type Value
- type ValueNotFoundError
- type VisitFn
Constants ¶
const ( // Structural & Literals OpUndefined Op = opStructural | iota OpEOF OpLParen OpRParen OpIdent OpComma OpString OpNumberInt OpNumberFloat OpBool // Logical OpAnd Op = opLogical | iota OpOr OpNot // Relation OpEq Op = opRelational | (1 << 0) OpNeq = opRelational | (1 << 1) OpLt = opRelational | (1 << 2) OpLe = opRelational | (1 << 3) OpGt = opRelational | (1 << 4) OpGe = opRelational | (1 << 5) OpBetween = opRelational | (1 << 6) OpIn = opRelational | (1 << 7) OpStartsWith = opRelational | (1 << 8) )
const IDIndexFieldName = "id"
const IDMapIndexName = "IDMapIndex"
const MapIndexName = "MapIndex"
const SortedIndexName = "SortedIndex"
Variables ¶
This section is empty.
Functions ¶
func ValueFromAny ¶
Types ¶
type BinaryExpr ¶
type BitSet ¶
type BitSet[V Value] struct { // contains filtered or unexported fields }
func NewBitSetFrom ¶
NewBitSetFrom creates a new BitSet from given values
func NewBitSetWithCapacity ¶
NewBitSetWithCapacity creates a new BitSet with starting capacity
func NewEmptyBitSet ¶
NewEmptyBitSet creates a new BitSet with len and cap = 0
func (*BitSet[V]) And ¶
And is the logical AND of two BitSet In this BitSet is the result, this means the values will be overwritten!
func (*BitSet[V]) AndNot ¶
AndNot removes all elements from the current set that exist in another set. Known as "Bit Clear" or "Set Difference"
Example: [1, 2, 110, 2345] AndNot [2, 110] => [1, 2345]
func (*BitSet[V]) CopyInto ¶
CopyInto copies the current BitSet into the provided buffer. It returns a new BitSet wrapper sharing the provided buffer. Assumption: cap(buf) >= len(b.data), if not, then panic.
func (*BitSet[V]) Max ¶
Max return the max value where an Bit is set [1, 3, 100] => 100 if no max found, return -1
func (*BitSet[V]) MaxSetIndex ¶
MaxSetIndex return the max index where an Bit is set
func (*BitSet[V]) Min ¶
Min return the min value where an Bit is set [1, 3, 100] => 1 if no max found, return -1
func (*BitSet[V]) Range ¶
Range iterates over set bits between 'from' and 'to' (inclusive). It calls 'visit' for each found bit. If 'visit' returns false, iteration stops.
func (*BitSet[V]) Set ¶
func (b *BitSet[V]) Set(value V)
Set inserts or updates the key in the BitSet
func (*BitSet[V]) Shrink ¶
func (b *BitSet[V]) Shrink()
Shrink trims the bitset to ensure that len(b.data) always points to the last truly useful word.
Operation Can Grow? Can Shrink? OR Yes No XOR Yes Yes AND No Yes AND NOT No Yes
func (*BitSet[V]) ToSlice ¶
func (b *BitSet[V]) ToSlice() []V
ToSlice create a new slice which contains all saved values
func (*BitSet[V]) Values ¶
Values iterate over the complete BitSet and call the yield function, for every value
func (*BitSet[V]) ValuesBatch ¶
type Filter ¶
type Filter[LI Value] interface { Match(op Op, value any) (*BitSet[LI], error) MatchMany(op Op, values ...any) (*BitSet[LI], error) }
Filter returns the BitSet or an error by a given Relation and Value
type FilterByName ¶
FilterByName finds the Filter by a given field-name
type FilterByName32 ¶
type FilterByName32 = FilterByName[uint32]
FilterByName32 supports only uint32 List-Indices
type FreeList ¶
type FreeList[T any] struct { // contains filtered or unexported fields }
FreeList don't delete an Item, instead mark it as not occupied. With one of the Compact Methods, you can remove thes palceholders and make the list smaller.
func NewFreeList ¶
func (*FreeList[T]) CompactLinear ¶
CompactLinear removes not used slote. If an Index has changed, yout get this Info with the Callback: onMove
func (*FreeList[T]) CompactUnstable ¶
func (l *FreeList[T]) CompactUnstable()
CompactUnstable removes not used slots. Unstable means, the Indices breaks.
func (*FreeList[T]) Get ¶
Get the Item on the given index, or the zero value and false, if it not exist. index must be >=0 and < len(slots), otherwise return Get zero value and false and do nothing.
func (*FreeList[T]) Insert ¶
Insert an Item to the end of the List or use a free slot, to add this item
func (*FreeList[T]) Remove ¶
Remove mark the Item on the given index as deleted. index must be >=0 and < len(slots), otherwise return Remove false and do nothing.
type FromField ¶
FromField is a function, which returns a value from an given object. example: Person{name string} func (p *Person) Name() { return p.name } (*Person).Name is the FieldGetFn
type Index ¶
Index is interface for handling the mapping of an Value: V to an List-Index: LI The Value V comes from a func(*OBJ) V
type InvalidArgsLenError ¶
type InvalidArgsLenError struct {
// contains filtered or unexported fields
}
func (InvalidArgsLenError) Error ¶
func (e InvalidArgsLenError) Error() string
type InvalidNameError ¶
type InvalidNameError struct {
// contains filtered or unexported fields
}
func (InvalidNameError) Error ¶
func (e InvalidNameError) Error() string
type InvalidOperationError ¶
type InvalidOperationError struct {
// contains filtered or unexported fields
}
func (InvalidOperationError) Error ¶
func (e InvalidOperationError) Error() string
type InvalidValueTypeError ¶
type InvalidValueTypeError[V any] struct { // contains filtered or unexported fields }
func (InvalidValueTypeError[V]) Error ¶
func (e InvalidValueTypeError[V]) Error() string
type List ¶
type List[T any, ID comparable] struct { // contains filtered or unexported fields }
List is a list (slice), which is extended by Indices for fast finding Items in the list.
func NewListWithID ¶
func NewListWithID[T any, ID comparable](fieldIDGetFn func(*T) ID) *List[T, ID]
NewList create a new List with an ID-Index
func (*List[T, ID]) CreateIndex ¶
CreateIndex create a new Index:
- fieldName: a name for a field of the saved Item
- fieldGetFn: a function, which returns the value of an field
- Index: a impl of the Index interface
Hint: empty field-name or the field-name ID are not allowed!
func (*List[T, ID]) Get ¶
Get returns an item by the given ID. This works ONLY, if an ID is defined (with calling: NewListWithID) errors: - wrong datatype - ID not found - no ID defined
func (*List[T, ID]) Insert ¶
Insert add the given Item to the list, There is NO check, for existing this Item in the list, it will ALWAYS inserting!
func (*List[T, ID]) Query ¶
func (l *List[T, ID]) Query(query Query32) (QueryResult[T, ID], error)
Query execute the given Query.
func (*List[T, ID]) QueryStr ¶
func (l *List[T, ID]) QueryStr(queryStr string) (QueryResult[T, ID], error)
func (*List[T, ID]) Remove ¶
Remove an item by the given ID. This works ONLY, if an ID is defined (with calling: NewListWithID) errors: - wrong datatype - ID not found - no ID defined
func (*List[T, ID]) RemoveIndex ¶
RemoveIndex removed a the Index with the given field-name (what the name of the Index is) With the field-name: ID you can remove the ID-Index
type MapIndex ¶
MapIndex is a mapping of any value to the Index in the List. This index only supported Queries with the Equal Ralation!
type NoIdIndexDefinedError ¶
type NoIdIndexDefinedError struct{}
func (NoIdIndexDefinedError) Error ¶
func (e NoIdIndexDefinedError) Error() string
type OverflowError ¶
type OverflowError struct {
// contains filtered or unexported fields
}
func (OverflowError) Error ¶
func (o OverflowError) Error() string
type Query ¶
type Query[LI Value] func(l FilterByName[LI], allIDs *BitSet[LI]) (bs *BitSet[LI], canMutate bool, err error)
Query is a filter function, find the correct Index an execute the Index.Get method and returns a BitSet pointer
type Query32 ¶
Query32 supports only uint32 List-Indices
type QueryResult ¶
type QueryResult[T any, ID comparable] struct { // contains filtered or unexported fields }
func (*QueryResult[T, ID]) Count ¶
func (q *QueryResult[T, ID]) Count() int
func (*QueryResult[T, ID]) IsEmpty ¶
func (q *QueryResult[T, ID]) IsEmpty() bool
func (*QueryResult[T, ID]) Pagination ¶
func (q *QueryResult[T, ID]) Pagination(offset, limit uint32) ([]T, PageInfo)
func (*QueryResult[T, ID]) RemoveAll ¶
func (q *QueryResult[T, ID]) RemoveAll()
func (*QueryResult[T, ID]) Sort ¶
func (q *QueryResult[T, ID]) Sort(less func(*T, *T) bool) []T
func (*QueryResult[T, ID]) Values ¶
func (q *QueryResult[T, ID]) Values() []T
type SkipList ¶
func NewSkipList ¶
NewSkipList creates a new SkipList
func (*SkipList[K, V]) Delete ¶
Delete removes the value for a given key If the key was not found: false, otherwise true, if the key was deleted.
func (*SkipList[K, V]) FindFromSortedKeys ¶
FindFromSortedKeys calls visit for all finding keys. Important: they keys slice MUST be sorted!
func (*SkipList[K, V]) FirstValue ¶
FirstValue returns the value associated with the smallest key or the zero value and false, if the list is empty.
func (*SkipList[K, V]) GreaterEqual ¶
GreaterEqual calls visit for all keys >= the given key
func (*SkipList[K, V]) LastValue ¶
LastValue returns the value associated with the largest key or the zero value and false, if the list is empty.
func (*SkipList[K, V]) MaxKey ¶
MaxKey returns the last (biggest) Key or the zero value and false, if the list is empty.
func (*SkipList[K, V]) MinKey ¶
MinKey returns the first (smallest) Key or the zero value and false, if the list is empty.
func (*SkipList[K, V]) Put ¶
Put inserts or updates a key with the given value. Returns true if a new node was inserted, false if an existing key was updated.
func (*SkipList[K, V]) Range ¶
Range traverse 'from' until 'to' over Skiplist and calling the visitor
func (*SkipList[K, V]) StringStartsWith ¶
StringStartsWith finds all keys with the given prefix. If prefix (K) is not a string, this method panics!
type SliceSet ¶
type SliceSet[V Value] struct { // contains filtered or unexported fields }
func NewSliceSetFrom ¶
NewSliceSetFrom creates a new SliceSet from given values
func NewSliceSetWithCapacity ¶
NewSliceSetWithCapacity creates a new SliceSet with starting capacity
func (*SliceSet[V]) AndNot ¶
AndNot removes all elements from the current Set that exist in another Set. Known as "Clear" or "Difference"
Example: [1, 2, 110, 2345] AndNot [2, 110] => [1, 2345]
func (*SliceSet[V]) Max ¶
Max return the max value of this Set [1, 3, 100] => 100 if the set is empty, return -1
func (*SliceSet[V]) MaxSetIndex ¶
MaxSetIndex return the max index the Set
func (*SliceSet[V]) Min ¶
Min return the min value of this Set [1, 3, 100] => 1 if the set is empty, return -1
func (*SliceSet[V]) Set ¶
func (s *SliceSet[V]) Set(value V)
Set inserts or updates the key in the Set
type SlotMap ¶
type SlotMap[T any] struct { // contains filtered or unexported fields }
func NewSlotMap ¶
func (*SlotMap[T]) Add ¶
Add an Item to the end of the List or use a free slot, to add this item. If the Item is insert on a free slot, the index is reused, but the generation will be increments by one.
func (*SlotMap[T]) Compact ¶
Compact removes all free slots from the SlotMap. This invalidates existing handles! It returns a map of {OldIndex -> NewIndex} so you can fix your handles.
func (*SlotMap[T]) Get ¶
Get the Item on the given index, or the zero value and false, if it not exist.
type SortedIndex ¶
type SortedIndex[OBJ any, V cmp.Ordered, LI Value] struct { // contains filtered or unexported fields }
SortedIndex is well suited for Queries with: Range, Min, Max, Greater and Less
func (*SortedIndex[OBJ, V, LI]) Match ¶
func (si *SortedIndex[OBJ, V, LI]) Match(op Op, value any) (*BitSet[LI], error)
func (*SortedIndex[OBJ, V, LI]) MatchMany ¶
func (si *SortedIndex[OBJ, V, LI]) MatchMany(op Op, values ...any) (*BitSet[LI], error)
func (*SortedIndex[OBJ, V, LI]) Set ¶
func (si *SortedIndex[OBJ, V, LI]) Set(obj *OBJ, lidx LI)
func (*SortedIndex[OBJ, V, LI]) UnSet ¶
func (si *SortedIndex[OBJ, V, LI]) UnSet(obj *OBJ, lidx LI)
type TermManyExpr ¶
type TrigramIndex ¶
type TrigramIndex struct {
// contains filtered or unexported fields
}
func NewTrigramIndex ¶
func NewTrigramIndex(s ...string) TrigramIndex
func (*TrigramIndex) Delete ¶
func (ti *TrigramIndex) Delete(li int) bool
func (*TrigramIndex) Len ¶
func (ti *TrigramIndex) Len() int
func (*TrigramIndex) Put ¶
func (ti *TrigramIndex) Put(s string, li int)
type UnexpectedTokenError ¶
type UnexpectedTokenError struct {
// contains filtered or unexported fields
}
func (UnexpectedTokenError) Error ¶
func (e UnexpectedTokenError) Error() string
type ValueNotFoundError ¶
type ValueNotFoundError struct {
// contains filtered or unexported fields
}
func (ValueNotFoundError) Error ¶
func (e ValueNotFoundError) Error() string