Documentation
¶
Index ¶
- Constants
- Variables
- func CopyAll(ctx context.Context, b *Builder, it kvstreams.Iterator) error
- func Get(ctx context.Context, s Store, x Root, key []byte) ([]byte, error)
- func GetF(ctx context.Context, s Store, x Root, key []byte, fn func([]byte) error) error
- func KeyAfter(x []byte) []byte
- func PrefixEnd(prefix []byte) []byte
- type Builder
- type Entry
- type ID
- type Iterator
- type Mutation
- type Operator
- func (o *Operator) AddPrefix(x Root, prefix []byte) Root
- func (o *Operator) Concat(ctx context.Context, s cadata.Store, iters ...kvstreams.Iterator) (*Root, error)
- func (o *Operator) Delete(ctx context.Context, s cadata.Store, x Root, key []byte) (*Root, error)
- func (o *Operator) DeleteSpan(ctx context.Context, s cadata.Store, x Root, span Span) (*Root, error)
- func (o *Operator) ForEach(ctx context.Context, s Store, root Root, span Span, fn func(Entry) error) error
- func (o *Operator) Get(ctx context.Context, s cadata.Store, x Root, key []byte) ([]byte, error)
- func (o *Operator) GetF(ctx context.Context, s cadata.Store, x Root, key []byte, fn func([]byte) error) error
- func (o *Operator) MaxEntry(ctx context.Context, s cadata.Store, x Root, span Span) (*Entry, error)
- func (o *Operator) MaxSize() int
- func (o *Operator) MeanSize() int
- func (o *Operator) Mutate(ctx context.Context, s cadata.Store, x Root, mutations ...Mutation) (*Root, error)
- func (o *Operator) NewBuilder(s Store) *Builder
- func (o *Operator) NewEmpty(ctx context.Context, s cadata.Store) (*Root, error)
- func (o *Operator) NewIterator(s Store, root Root, span Span) *Iterator
- func (o *Operator) Populate(ctx context.Context, s Store, x Root, set cadata.Set, ...) error
- func (o *Operator) Put(ctx context.Context, s cadata.Store, x Root, key, value []byte) (*Root, error)
- func (o *Operator) RemovePrefix(ctx context.Context, s cadata.Store, x Root, prefix []byte) (*Root, error)
- func (o *Operator) Sync(ctx context.Context, src, dst Store, x Root, entryFn func(Entry) error) error
- type Option
- type Ref
- type Root
- type Span
- type Store
Constants ¶
const (
MaxKeySize = ptree.MaxKeySize
)
Variables ¶
var ( ErrKeyNotFound = errors.Errorf("key not found") EOS = kvstreams.EOS )
Functions ¶
Types ¶
type Builder ¶
Builder is used to construct GotKV instances by adding keys in lexicographical order.
type Mutation ¶ added in v0.0.2
Mutation represents a declarative change to a Span of entries. The result of applying mutation is that
type Operator ¶
type Operator struct {
// contains filtered or unexported fields
}
Operator holds common configuration for operations on gotkv instances. It has nothing to do with the state of a particular gotkv instance. It is NOT analagous to a collection object. It is safe for use by multiple goroutines.
func NewOperator ¶
NewOperator returns an operator which will create nodes with average size `avgSize` and maximum size `maxSize`.
func (*Operator) AddPrefix ¶
AddPrefix prepends prefix to all the keys in instance x. This is a O(1) operation.
func (*Operator) Concat ¶ added in v0.0.2
func (o *Operator) Concat(ctx context.Context, s cadata.Store, iters ...kvstreams.Iterator) (*Root, error)
Concat copies data from the iterators in order. If the iterators produce out of order keys concat errors.
func (*Operator) Delete ¶
Delete returns a new version of the instance x where there is no entry for key. If key does not exist no error is returned.
func (*Operator) DeleteSpan ¶
func (o *Operator) DeleteSpan(ctx context.Context, s cadata.Store, x Root, span Span) (*Root, error)
DeleteSpan returns a new version of the instance x where there are no entries contained in span.
func (*Operator) ForEach ¶
func (o *Operator) ForEach(ctx context.Context, s Store, root Root, span Span, fn func(Entry) error) error
ForEach calls fn with every entry, in the GotKV instance rooted at root, contained in span, in lexicographical order. If fn returns an error, ForEach immediately returns that error.
func (*Operator) GetF ¶
func (o *Operator) GetF(ctx context.Context, s cadata.Store, x Root, key []byte, fn func([]byte) error) error
GetF calls fn with the value corresponding to key in the instance x. The value must not be used outside the callback.
func (*Operator) MaxEntry ¶ added in v0.0.2
MaxEntry returns the entry in the instance x, within span, with the greatest lexicographic value.
func (*Operator) Mutate ¶ added in v0.0.2
func (o *Operator) Mutate(ctx context.Context, s cadata.Store, x Root, mutations ...Mutation) (*Root, error)
Mutate applies a batch of mutations to the tree x.
func (*Operator) NewBuilder ¶
NewBuilder returns a Builder for constructing a GotKV instance. Data will be persisted to s.
func (*Operator) NewIterator ¶
NewIterator returns an iterator for the instance rooted at x, which will emit all keys within span in the instance.
func (*Operator) Populate ¶ added in v0.0.4
func (o *Operator) Populate(ctx context.Context, s Store, x Root, set cadata.Set, entryFn func(ent Entry) error) error
Populate adds all blobs reachable from x to set. If an item is in set all of the blobs reachable from it are also assumed to also be in set.
func (*Operator) Put ¶
func (o *Operator) Put(ctx context.Context, s cadata.Store, x Root, key, value []byte) (*Root, error)
Put returns a new version of the instance x with the entry at key corresponding to value. If an entry at key already exists it is overwritten, otherwise it will be created.
func (*Operator) RemovePrefix ¶
func (o *Operator) RemovePrefix(ctx context.Context, s cadata.Store, x Root, prefix []byte) (*Root, error)
RemovePrefix removes a prefix from all the keys in instance x. RemotePrefix errors if all the entries in x do not share a common prefix. This is a O(1) operation.
type Option ¶
type Option func(op *Operator)
Option is used to configure an Operator