Documentation
¶
Index ¶
- Constants
- Variables
- func CopyAll(ctx context.Context, b *Builder, it kvstreams.Iterator) error
- func DebugTree(ctx context.Context, s stores.Reading, root Root, w io.Writer) error
- func Get(ctx context.Context, s Getter, x Root, key []byte) ([]byte, error)
- func GetF(ctx context.Context, s Getter, x Root, key []byte, fn func([]byte) error) error
- func IsErrKeyNotFound(err error) bool
- func KeyAfter(x []byte) []byte
- func PrefixEnd(prefix []byte) []byte
- type Builder
- type DEntry
- type Decoder
- type Differ
- type Edit
- type Encoder
- type Entry
- type Getter
- type ID
- type Index
- type IndexDecoder
- type IndexEncoder
- type Iterator
- type Machine
- func (a *Machine) AddPrefix(x Root, prefix []byte) Root
- func (a *Machine) Concat(ctx context.Context, s stores.RW, iters ...kvstreams.Iterator) (*Root, error)
- func (a *Machine) Delete(ctx context.Context, s stores.RW, x Root, key []byte) (*Root, error)
- func (a *Machine) DeleteSpan(ctx context.Context, s stores.RW, x Root, span Span) (*Root, error)
- func (a *Machine) Edit(ctx context.Context, s stores.RW, x Root, edits ...Edit) (*Root, error)
- func (a *Machine) ForEach(ctx context.Context, s Getter, root Root, span Span, fn func(Entry) error) error
- func (a *Machine) Get(ctx context.Context, s stores.Reading, x Root, key []byte) ([]byte, error)
- func (a *Machine) GetF(ctx context.Context, s stores.Reading, x Root, key []byte, ...) error
- func (a *Machine) HasPrefix(ctx context.Context, s stores.Reading, x Root, prefix []byte) (bool, error)
- func (a *Machine) MaxEntry(ctx context.Context, s stores.Reading, x Root, span Span) (*Entry, error)
- func (a *Machine) MaxSize() int
- func (a *Machine) MeanSize() int
- func (a *Machine) NewBuilder(s stores.RW) *Builder
- func (ag *Machine) NewDiffer(s stores.Reading, left, right Root, span Span) *Differ
- func (a *Machine) NewEmpty(ctx context.Context, s stores.RW) (*Root, error)
- func (a *Machine) NewIterator(s stores.Reading, root Root, span Span) *Iterator
- func (m *Machine) NewTx(s stores.RW, prev Root) *Tx
- func (a *Machine) Populate(ctx context.Context, s stores.Reading, x Root, set cadata.Set, ...) error
- func (a *Machine) Put(ctx context.Context, s stores.RW, x Root, key, value []byte) (*Root, error)
- func (a *Machine) RemovePrefix(ctx context.Context, s stores.RW, x Root, prefix []byte) (*Root, error)
- func (a *Machine) Sync(ctx context.Context, src stores.Reading, dst stores.Writing, x Root, ...) error
- type Option
- type Ref
- type Root
- type Span
- type Store
- type Tx
- func (tx *Tx) Delete(ctx context.Context, key []byte) error
- func (tx *Tx) Flush(ctx context.Context) (*Root, error)
- func (tx *Tx) Get(ctx context.Context, key []byte, dst *[]byte) (bool, error)
- func (tx *Tx) Iterate(ctx context.Context, span Span) *TxIterator
- func (tx *Tx) Put(ctx context.Context, key, value []byte) error
- type TxIterator
Constants ¶
const (
MaxKeySize = 4096
)
Variables ¶
var (
ErrKeyNotFound = fmt.Errorf("key not found")
)
Functions ¶
func IsErrKeyNotFound ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to construct GotKV instances by adding keys in lexicographical order.
type Edit ¶
Edit represents a declarative change to a Span of entries. The result of applying a Edit is that the entire contents of the Span are replaced with Entries.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a ptree.Encoder
func (*Encoder) EncodedLen ¶
type IndexDecoder ¶
type IndexDecoder struct {
// contains filtered or unexported fields
}
func (*IndexDecoder) Reset ¶
func (d *IndexDecoder) Reset(parent Index)
type IndexEncoder ¶
type IndexEncoder struct {
Encoder
}
IndexEncoder encodes indexes
func (*IndexEncoder) EncodedLen ¶
func (e *IndexEncoder) EncodedLen(x Index) int
func (*IndexEncoder) Reset ¶
func (e *IndexEncoder) Reset()
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is used to iterate through entries in GotKV instances.
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine 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 NewMachine ¶
NewMachine returns an operator which will create nodes with mean size `meanSize` and maximum size `maxSize`.
func (*Machine) AddPrefix ¶
AddPrefix prepends prefix to all the keys in instance x. This is a O(1) operation.
func (*Machine) Concat ¶
func (a *Machine) Concat(ctx context.Context, s stores.RW, iters ...kvstreams.Iterator) (*Root, error)
Concat copies data from the iterators in order. If the iterators produce out of order keys concat errors.
func (*Machine) 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 (*Machine) DeleteSpan ¶
DeleteSpan returns a new version of the instance x where there are no entries contained in span.
func (*Machine) Edit ¶
Edit applies a batch of edits to the tree x. If edits overlap, the later edit takes prescendence.
func (*Machine) ForEach ¶
func (a *Machine) ForEach(ctx context.Context, s Getter, 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 (*Machine) GetF ¶
func (a *Machine) GetF(ctx context.Context, s stores.Reading, 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 (*Machine) MaxEntry ¶
func (a *Machine) MaxEntry(ctx context.Context, s stores.Reading, x Root, span Span) (*Entry, error)
MaxEntry returns the entry in the instance x, within span, with the greatest lexicographic value.
func (*Machine) NewBuilder ¶
NewBuilder returns a Builder for constructing a GotKV instance. Data will be persisted to s.
func (*Machine) NewIterator ¶
NewIterator returns an iterator for the instance rooted at x, which will emit all keys within span in the instance.
func (*Machine) Populate ¶
func (a *Machine) Populate(ctx context.Context, s stores.Reading, 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 (*Machine) Put ¶
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.
type Option ¶
type Option func(ag *Machine)
Option is used to configure an Machine
func WithDataMachine ¶
type Root ¶
type Root struct {
Ref gdat.Ref `json:"ref"`
Depth uint8 `json:"depth"`
First []byte `json:"first,omitempty"`
}
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx allows operations to be batched.
type TxIterator ¶
type TxIterator struct {
// contains filtered or unexported fields
}