Documentation ¶
Index ¶
- Variables
- func InjectStateTransaction(ctx context.Context, tx StateTransaction) context.Context
- func TestDequeIterator(iter *DequeIterator, expectedValues []octosql.Value) (bool, error)
- func TestMapIteratorCorrectness(iter *MapIterator, expectedKeys, expectedValues []octosql.Value) (bool, error)
- func TestSetIteratorCorrectness(iter *MultiSetIterator, expectedValues []octosql.Value, expectedCounts []int) error
- type BadgerIterator
- type BadgerStorage
- type ChangesNotifierFunc
- type Deque
- func (dq *Deque) Clear() error
- func (dq *Deque) GetIterator(opts ...IteratorOption) *DequeIterator
- func (dq *Deque) Length() (int, error)
- func (dq *Deque) PeekBack(value proto.Message) error
- func (dq *Deque) PeekFront(value proto.Message) error
- func (dq *Deque) PopBack(value proto.Message) error
- func (dq *Deque) PopFront(value proto.Message) error
- func (dq *Deque) PushBack(value proto.Message) error
- func (dq *Deque) PushFront(value proto.Message) error
- type DequeIterator
- type Iterator
- type IteratorOption
- type IteratorOptions
- type Map
- func (hm *Map) Clear() error
- func (hm *Map) Delete(key MonotonicallySerializable) error
- func (hm *Map) Get(key MonotonicallySerializable, value proto.Message) error
- func (hm *Map) GetIterator(opts ...IteratorOption) *MapIterator
- func (hm *Map) GetIteratorWithPrefix(prefix []byte) *MapIterator
- func (hm *Map) Set(key MonotonicallySerializable, value proto.Message) error
- type MapIterator
- type MonotonicallySerializable
- type MultiSet
- func (set *MultiSet) Clear() error
- func (set *MultiSet) Contains(value octosql.Value) (bool, error)
- func (set *MultiSet) Erase(value octosql.Value) error
- func (set *MultiSet) GetCount(value octosql.Value) (int, error)
- func (set *MultiSet) GetIterator() *MultiSetIterator
- func (set *MultiSet) Insert(value octosql.Value) error
- func (set *MultiSet) ReadAll() ([]octosql.Value, error)
- type MultiSetIterator
- type StateTransaction
- type Storage
- type Subscription
- type ValueState
Constants ¶
This section is empty.
Variables ¶
var ErrChangeSent = errors.New("change sent")
var ErrEndOfIterator = errors.New("end of iterator")
var ErrNotFound = errors.New("couldn't find element")
Functions ¶
func InjectStateTransaction ¶
func InjectStateTransaction(ctx context.Context, tx StateTransaction) context.Context
For now save in context
func TestDequeIterator ¶
func TestDequeIterator(iter *DequeIterator, expectedValues []octosql.Value) (bool, error)
func TestMapIteratorCorrectness ¶
func TestMapIteratorCorrectness(iter *MapIterator, expectedKeys, expectedValues []octosql.Value) (bool, error)
func TestSetIteratorCorrectness ¶
func TestSetIteratorCorrectness(iter *MultiSetIterator, expectedValues []octosql.Value, expectedCounts []int) error
The iterator of a set has no determined order
Types ¶
type BadgerIterator ¶
type BadgerIterator struct {
// contains filtered or unexported fields
}
BadgerIterator is a wrapper around *badger.Iterator that implements the Iterator interface
func NewBadgerIterator ¶
func NewBadgerIterator(it *badger.Iterator, prefixLength int) *BadgerIterator
func (*BadgerIterator) Close ¶
func (bi *BadgerIterator) Close() error
func (*BadgerIterator) NextWithKey ¶
func (bi *BadgerIterator) NextWithKey(key MonotonicallySerializable, value proto.Message) error
type BadgerStorage ¶
type BadgerStorage struct {
// contains filtered or unexported fields
}
func NewBadgerStorage ¶
func NewBadgerStorage(db *badger.DB) *BadgerStorage
func (*BadgerStorage) BeginTransaction ¶
func (bs *BadgerStorage) BeginTransaction() StateTransaction
func (*BadgerStorage) Close ¶
func (bs *BadgerStorage) Close() error
func (*BadgerStorage) DropAll ¶
func (bs *BadgerStorage) DropAll(prefix []byte) error
func (*BadgerStorage) Subscribe ¶
func (bs *BadgerStorage) Subscribe(ctx context.Context) *Subscription
func (*BadgerStorage) WithPrefix ¶
func (bs *BadgerStorage) WithPrefix(prefix []byte) Storage
type ChangesNotifierFunc ¶
type Deque ¶
type Deque struct {
// contains filtered or unexported fields
}
func NewDeque ¶
func NewDeque(tx StateTransaction) *Deque
func (*Deque) GetIterator ¶
func (dq *Deque) GetIterator(opts ...IteratorOption) *DequeIterator
func (*Deque) PeekBack ¶
Returns the last element of the queue without removing it. Returns ErrNotFound if the queue is empty.
func (*Deque) PeekFront ¶
Returns the first element of the queue without removing it. Returns ErrNotFound if the queue is empty.
func (*Deque) PopBack ¶
Removes the last element from the queue and returns it. Returns ErrNotFound if the list is empty.
func (*Deque) PopFront ¶
Removes the first element from the queue and returns it. Returns ErrNotFound if the list is empty.
type DequeIterator ¶
type DequeIterator struct {
// contains filtered or unexported fields
}
func NewDequeIterator ¶
func NewDequeIterator(it Iterator) *DequeIterator
func (*DequeIterator) Close ¶
func (lli *DequeIterator) Close() error
type IteratorOption ¶
type IteratorOption func(*IteratorOptions)
func WithDefault ¶
func WithDefault() IteratorOption
func WithPrefix ¶
func WithPrefix(prefix []byte) IteratorOption
func WithReverse ¶
func WithReverse() IteratorOption
type IteratorOptions ¶
type IteratorOptions struct { PrefetchValues bool PrefetchSize int Reverse bool AllVersions bool Prefix []byte InternalAccess bool }
IteratorOptions are a copy of badger.IteratorOptions They are used so that there is no explicit badger dependency in StateTransaction
func (*IteratorOptions) ToBadgerOptions ¶
func (io *IteratorOptions) ToBadgerOptions() badger.IteratorOptions
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func NewMap ¶
func NewMap(tx StateTransaction) *Map
func (*Map) Clear ¶
Clears the contents of the map. Important: To call map.Clear() one must close any iterators opened on that map
func (*Map) Delete ¶
func (hm *Map) Delete(key MonotonicallySerializable) error
Removes a key from the map even if it wasn't present in it to begin with.
func (*Map) Get ¶
func (hm *Map) Get(key MonotonicallySerializable, value proto.Message) error
Returns the value corresponding to key. Returns ErrNotFound if the given key doesn't correspond to a value in the map.
func (*Map) GetIterator ¶
func (hm *Map) GetIterator(opts ...IteratorOption) *MapIterator
func (*Map) GetIteratorWithPrefix ¶
func (hm *Map) GetIteratorWithPrefix(prefix []byte) *MapIterator
Returns an iterator with a specified prefix, that allows to iterate over a specified range of keys
type MapIterator ¶
type MapIterator struct {
// contains filtered or unexported fields
}
func NewMapIterator ¶
func NewMapIterator(it Iterator) *MapIterator
func (*MapIterator) Close ¶
func (mi *MapIterator) Close() error
func (*MapIterator) Next ¶
func (mi *MapIterator) Next(key MonotonicallySerializable, value proto.Message) error
type MonotonicallySerializable ¶
type MonotonicallySerializable interface { MonotonicMarshal() []byte MonotonicUnmarshal([]byte) error }
A type that implements this interface must have a MonotonicMarshal method, that has the property, that if x <= y (where <= is the less-equal relation defined on a certain type, for example lexicographical order on strings) then MonotonicMarshal(x) <= MonotonicMarshal(y) (where <= is the lexicographical order on []byte). Since in mathematics such a function is called Monotonous, thus the name. A MonotonicUnmarshal which is the inverse of MonotonicMarshal is also required.
type MultiSet ¶
type MultiSet struct {
// contains filtered or unexported fields
}
func NewMultiSet ¶
func NewMultiSet(tx StateTransaction) *MultiSet
func (*MultiSet) GetIterator ¶
func (set *MultiSet) GetIterator() *MultiSetIterator
type MultiSetIterator ¶
type MultiSetIterator struct {
// contains filtered or unexported fields
}
func NewSetIterator ¶
func NewSetIterator(it Iterator) *MultiSetIterator
func (*MultiSetIterator) Close ¶
func (msi *MultiSetIterator) Close() error
type StateTransaction ¶
type StateTransaction interface { Set(key, value []byte) error Get(key []byte) (value []byte, err error) Delete(key []byte) error WithPrefix(prefix []byte) StateTransaction GetPrefixLength() int Iterator(opts ...IteratorOption) Iterator Commit() error Abort() GetUnderlyingStorage() Storage Prefix() string }
func GetStateTransactionFromContext ¶
func GetStateTransactionFromContext(ctx context.Context) StateTransaction
For now save in context
type Storage ¶
type Storage interface { DropAll(prefix []byte) error BeginTransaction() StateTransaction WithPrefix(prefix []byte) Storage Subscribe(ctx context.Context) *Subscription Close() error }
func GetTestStorage ¶
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
A Subscription lets the client listen for changes in the given prefixed storage. Subscriptions must be closed when not needed anymore.
func ConcatSubscriptions ¶
func ConcatSubscriptions(ctx context.Context, subs ...*Subscription) *Subscription
func NewSubscription ¶
func NewSubscription(ctx context.Context, subscriptionFunc ChangesNotifierFunc) *Subscription
func (*Subscription) Close ¶
func (sub *Subscription) Close() error
func (*Subscription) ListenForChanges ¶
func (sub *Subscription) ListenForChanges(ctx context.Context) error
ListenForChanges returns nil in case a change has been detected. Otherwise it returns an error containing the cause of the termination.
type ValueState ¶
type ValueState struct {
// contains filtered or unexported fields
}
func NewValueState ¶
func NewValueState(tx StateTransaction) *ValueState
func (*ValueState) Clear ¶
func (vs *ValueState) Clear() error