Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeSliceIndex(k Keypath) uint64
- func DecodeSliceLen(k Keypath) uint64
- func ParseKeypathAndRange(s []byte, keypathSeparator byte) (Keypath, *Range, error)
- type DBNode
- func (tx *DBNode) BoolValue(keypath Keypath) (bool, bool, error)
- func (tx *DBNode) BytesValue(keypath Keypath) ([]byte, bool, error)
- func (n *DBNode) ChildIterator(relKeypath Keypath, prefetchValues bool, prefetchSize int) Iterator
- func (tx *DBNode) Close()
- func (tx *DBNode) CopyToMemory(relKeypath Keypath, rng *Range) (n Node, err error)
- func (tx *DBNode) DebugPrint(printFn func(inFormat string, args ...interface{}), newlines bool, ...)
- func (tx *DBNode) Delete(relKeypath Keypath, rng *Range) (err error)
- func (n *DBNode) DepthFirstIterator(relKeypath Keypath, prefetchValues bool, prefetchSize int) Iterator
- func (tx *DBNode) Diff() *Diff
- func (n *DBNode) Exists(relKeypath Keypath) (bool, error)
- func (tx *DBNode) FloatValue(keypath Keypath) (float64, bool, error)
- func (node *DBNode) IndexOfMapSubkey(relKeypathOfMap Keypath, subkey Keypath) (uint64, error)
- func (tx *DBNode) IntValue(keypath Keypath) (int64, bool, error)
- func (n *DBNode) Iterator(relKeypath Keypath, prefetchValues bool, prefetchSize int) Iterator
- func (tx *DBNode) Keypath() Keypath
- func (tx *DBNode) Length() (uint64, error)
- func (tx *DBNode) MapValue(keypath Keypath) (map[string]interface{}, bool, error)
- func (n *DBNode) MarshalJSON() ([]byte, error)
- func (n *DBNode) NodeAt(keypath Keypath, rng *Range) Node
- func (n *DBNode) NodeInfo(keypath Keypath) (NodeType, ValueType, uint64, error)
- func (node *DBNode) NthMapSubkey(relKeypathOfMap Keypath, n uint64) Keypath
- func (tx *DBNode) NumSubkeys() uint64
- func (n *DBNode) ParentNodeFor(keypath Keypath) (Node, Keypath)
- func (tx *DBNode) ResetDiff()
- func (tx *DBNode) Save() error
- func (node *DBNode) Scan(into interface{}) error
- func (tx *DBNode) Set(relKeypath Keypath, rng *Range, val interface{}) error
- func (tx *DBNode) SliceValue(keypath Keypath) ([]interface{}, bool, error)
- func (tx *DBNode) StringValue(keypath Keypath) (string, bool, error)
- func (tx *DBNode) Subkeys() []Keypath
- func (tx *DBNode) UintValue(keypath Keypath) (uint64, bool, error)
- func (tx *DBNode) Value(relKeypath Keypath, rng *Range) (_ interface{}, _ bool, err error)
- type DBTree
- type Diff
- type EncryptionConfig
- type Indexer
- type Iterator
- type Keypath
- func (k Keypath) CommonAncestor(other Keypath) Keypath
- func (k Keypath) Compare(other Keypath) int
- func (k Keypath) ContainsByte(b byte) bool
- func (k Keypath) ContainsPart(part Keypath) bool
- func (k Keypath) ContainsSeparator() bool
- func (k Keypath) Copy() Keypath
- func (k Keypath) Equal(other Keypath) bool
- func (k Keypath) Equals(other Keypath) bool
- func (k Keypath) FirstNParts(n int) Keypath
- func (k Keypath) IndexByte(b byte) int
- func (k Keypath) LastNParts(n int) Keypath
- func (k Keypath) LengthAsParent() int
- func (k Keypath) Marshal() ([]byte, error)
- func (k Keypath) MarshalJSON() ([]byte, error)
- func (k *Keypath) MarshalTo(data []byte) (n int, err error)
- func (k Keypath) Normalized() Keypath
- func (k Keypath) NumParts() int
- func (k Keypath) Part(partIdx int) Keypath
- func (k Keypath) PartStrings() []string
- func (k Keypath) Parts() []Keypath
- func (k Keypath) Pop() (rest Keypath, top Keypath)
- func (k Keypath) Push(part Keypath) Keypath
- func (k Keypath) PushIndex(idx uint64) Keypath
- func (k Keypath) Pushb(part []byte) Keypath
- func (k Keypath) Pushs(part string) Keypath
- func (k Keypath) RelativeTo(root Keypath) Keypath
- func (k Keypath) Shift() (top Keypath, rest Keypath)
- func (k *Keypath) Size() int
- func (k Keypath) StartsWith(prefixParts Keypath) bool
- func (k Keypath) String() string
- func (k *Keypath) Unmarshal(data []byte) error
- func (k *Keypath) UnmarshalJSON(data []byte) error
- func (k Keypath) Unshift(part Keypath) Keypath
- type MapKey
- type MapKeyScanner
- type MemoryNode
- func (n *MemoryNode) BoolValue(keypath Keypath) (bool, bool, error)
- func (n *MemoryNode) BytesValue(keypath Keypath) ([]byte, bool, error)
- func (n *MemoryNode) ChildIterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator
- func (n *MemoryNode) Close()
- func (t *MemoryNode) CopyToMemory(keypath Keypath, rng *Range) (Node, error)
- func (n *MemoryNode) DebugContents(keypathPrefix Keypath, rng *[2]uint64) ([]Keypath, []interface{}, map[string]NodeType, error)
- func (t *MemoryNode) DebugPrint(printFn func(inFormat string, args ...interface{}), newlines bool, ...)
- func (n *MemoryNode) Delete(keypath Keypath, rng *Range) error
- func (n *MemoryNode) DepthFirstIterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator
- func (n *MemoryNode) Diff() *Diff
- func (n *MemoryNode) Exists(keypath Keypath) (bool, error)
- func (n *MemoryNode) FloatValue(keypath Keypath) (float64, bool, error)
- func (node *MemoryNode) IndexOfMapSubkey(rootKeypath Keypath, subkey Keypath) (uint64, error)
- func (n *MemoryNode) IntValue(keypath Keypath) (int64, bool, error)
- func (n *MemoryNode) Iterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator
- func (n *MemoryNode) Keypath() Keypath
- func (n *MemoryNode) Length() (uint64, error)
- func (n *MemoryNode) MapValue(keypath Keypath) (map[string]interface{}, bool, error)
- func (n *MemoryNode) MarshalJSON() ([]byte, error)
- func (n *MemoryNode) NodeAt(relKeypath Keypath, rng *Range) Node
- func (n *MemoryNode) NodeInfo(relKeypath Keypath) (NodeType, ValueType, uint64, error)
- func (node *MemoryNode) NthMapSubkey(rootKeypath Keypath, n uint64) (Keypath, error)
- func (n *MemoryNode) NumSubkeys() uint64
- func (n *MemoryNode) ParentNodeFor(relKeypath Keypath) (x Node, y Keypath)
- func (n *MemoryNode) ResetDiff()
- func (n *MemoryNode) Scan(into interface{}) error
- func (t *MemoryNode) Set(keypath Keypath, rng *Range, value interface{}) error
- func (n *MemoryNode) SliceValue(keypath Keypath) ([]interface{}, bool, error)
- func (n *MemoryNode) StringValue(keypath Keypath) (string, bool, error)
- func (n *MemoryNode) Subkeys() []Keypath
- func (n *MemoryNode) UintValue(keypath Keypath) (uint64, bool, error)
- func (n *MemoryNode) UnmarshalJSON(bs []byte) error
- func (n *MemoryNode) Value(keypath Keypath, rng *Range) (interface{}, bool, error)
- type Node
- type NodeRange
- type NodeType
- type Range
- type StateBytesMarshaler
- type StateBytesUnmarshaler
- type ValueType
- type Version
- func (id Version) Bytes() []byte
- func (id Version) Compare(other Version) int
- func (id Version) Equal(other Version) bool
- func (id Version) Hex() string
- func (id Version) MapKey() (Keypath, error)
- func (id Version) Marshal() ([]byte, error)
- func (id Version) MarshalJSON() ([]byte, error)
- func (id Version) MarshalText() ([]byte, error)
- func (id *Version) MarshalTo(data []byte) (n int, err error)
- func (id Version) Pretty() string
- func (id *Version) ScanMapKey(keypath Keypath) error
- func (id *Version) Size() int
- func (id Version) String() string
- func (id *Version) Unmarshal(data []byte) error
- func (id *Version) UnmarshalJSON(data []byte) error
- func (id *Version) UnmarshalText(text []byte) error
- type VersionSet
- type VersionedDBTree
- func (t *VersionedDBTree) BuildIndex(version *Version, node Node, indexName Keypath, indexer Indexer) (err error)
- func (t *VersionedDBTree) Close() error
- func (t *VersionedDBTree) CopyVersion(dstVersion, srcVersion Version) error
- func (t *VersionedDBTree) DeleteDB() error
- func (t *VersionedDBTree) IndexAtVersion(version *Version, keypath Keypath, indexName Keypath, mutable bool) *DBNode
- func (t *VersionedDBTree) StateAtVersion(version *Version, mutable bool) *DBNode
Constants ¶
const StructTag = "tree"
Variables ¶
var ( ErrWrongType = errors.New("wrong type") ErrNodeEncoding = errors.New("corrupted encoding for node") ErrInvalidRange = errors.New("invalid range") ErrRangeOverNonSlice = errors.New("range over non-slice") ErrNilKeypath = errors.New("nil keypath") )
var (
CurrentVersion = Version{}
)
var ErrBadKeypath = errors.New("bad keypath")
var KeypathSeparator = Keypath("/")
Functions ¶
func DecodeSliceIndex ¶
func DecodeSliceLen ¶
Types ¶
type DBNode ¶
type DBNode struct {
// contains filtered or unexported fields
}
func (*DBNode) ChildIterator ¶
func (*DBNode) CopyToMemory ¶
func (*DBNode) DebugPrint ¶
func (*DBNode) DepthFirstIterator ¶
func (*DBNode) IndexOfMapSubkey ¶
func (*DBNode) MarshalJSON ¶
func (*DBNode) NthMapSubkey ¶
NthSubkey finds the Nth direct subkey in a map.
func (*DBNode) NumSubkeys ¶
func (*DBNode) SliceValue ¶
type DBTree ¶
func (*DBTree) DebugPrint ¶
type Diff ¶
type Diff struct { Added map[string]struct{} AddedList []Keypath Removed map[string]struct{} RemovedList []Keypath // contains filtered or unexported fields }
func (*Diff) RemoveMany ¶
func (*Diff) SetEnabled ¶
type EncryptionConfig ¶
type Keypath ¶
type Keypath []byte
func EncodeSliceIndex ¶
func EncodeSliceLen ¶
func JoinKeypaths ¶
func NewPopulatedKeypath ¶
func NewPopulatedKeypath(_ gogoprotobufTest) *Keypath
func (Keypath) CommonAncestor ¶
func (Keypath) ContainsByte ¶
func (Keypath) ContainsPart ¶
func (Keypath) ContainsSeparator ¶
func (Keypath) FirstNParts ¶
func (Keypath) LastNParts ¶
LastNParts returns the N right-most Keypath components (or nil if there less than the requested number of components). Any trailing path sep chars are effectively ignored.
"1/22/333".LastNParts(1) => "333"
"1/22/333".LastNParts(2) => "22/333"
"1/22/333/".LastNParts(2) => "22/333"
"1/22/333/".LastNParts(4) => nil
func (Keypath) LengthAsParent ¶
func (Keypath) MarshalJSON ¶
func (Keypath) Normalized ¶
func (Keypath) PartStrings ¶
func (Keypath) RelativeTo ¶
func (Keypath) StartsWith ¶
func (*Keypath) UnmarshalJSON ¶
type MapKeyScanner ¶
type MemoryNode ¶
type MemoryNode struct {
// contains filtered or unexported fields
}
func NewMemoryNode ¶
func NewMemoryNode() *MemoryNode
func NewMemoryNodeWithValue ¶
func NewMemoryNodeWithValue(value interface{}) *MemoryNode
func (*MemoryNode) BytesValue ¶
func (n *MemoryNode) BytesValue(keypath Keypath) ([]byte, bool, error)
func (*MemoryNode) ChildIterator ¶
func (n *MemoryNode) ChildIterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator
func (*MemoryNode) Close ¶
func (n *MemoryNode) Close()
func (*MemoryNode) CopyToMemory ¶
func (t *MemoryNode) CopyToMemory(keypath Keypath, rng *Range) (Node, error)
CopyToMemory returns a copy of the node at the given keypath.
func (*MemoryNode) DebugContents ¶
func (*MemoryNode) DebugPrint ¶
func (t *MemoryNode) DebugPrint(printFn func(inFormat string, args ...interface{}), newlines bool, indentLevel int)
func (*MemoryNode) DepthFirstIterator ¶
func (n *MemoryNode) DepthFirstIterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator
func (*MemoryNode) Diff ¶
func (n *MemoryNode) Diff() *Diff
func (*MemoryNode) Exists ¶
func (n *MemoryNode) Exists(keypath Keypath) (bool, error)
Exists returns a boolean representing whether the given keypath has been set in the subtree for this node. For a MemoryNode, it never returns an error.
func (*MemoryNode) FloatValue ¶
func (n *MemoryNode) FloatValue(keypath Keypath) (float64, bool, error)
func (*MemoryNode) IndexOfMapSubkey ¶
func (node *MemoryNode) IndexOfMapSubkey(rootKeypath Keypath, subkey Keypath) (uint64, error)
func (*MemoryNode) Iterator ¶
func (n *MemoryNode) Iterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator
func (*MemoryNode) Keypath ¶
func (n *MemoryNode) Keypath() Keypath
func (*MemoryNode) Length ¶
func (n *MemoryNode) Length() (uint64, error)
func (*MemoryNode) MapValue ¶
func (n *MemoryNode) MapValue(keypath Keypath) (map[string]interface{}, bool, error)
func (*MemoryNode) MarshalJSON ¶
func (n *MemoryNode) MarshalJSON() ([]byte, error)
func (*MemoryNode) NodeAt ¶
func (n *MemoryNode) NodeAt(relKeypath Keypath, rng *Range) Node
NodeAt returns the tree.Node corresponding to the given keypath in the state tree. If the keypath doesn't exist, a MemoryNode is still returned, but calling .Value on it will return a result with NodeTypeInvalid.
func (*MemoryNode) NodeInfo ¶
NodeInfo returns metadata about the node: its NodeType, its ValueType (if applicable), and the Content-Length of its value.
func (*MemoryNode) NthMapSubkey ¶
func (node *MemoryNode) NthMapSubkey(rootKeypath Keypath, n uint64) (Keypath, error)
func (*MemoryNode) NumSubkeys ¶
func (n *MemoryNode) NumSubkeys() uint64
func (*MemoryNode) ParentNodeFor ¶
func (n *MemoryNode) ParentNodeFor(relKeypath Keypath) (x Node, y Keypath)
ParentNodeFor in most cases returns the method's receiver. But in the case where another tree.Node has been .Set into the receiver's state tree at some point in the provided keypath, it will return the deepest tree.Node corresponding to that keypath. The returned keypath is the provided keypath, relative to the deepest tree.Node.
func (*MemoryNode) ResetDiff ¶
func (n *MemoryNode) ResetDiff()
func (*MemoryNode) Scan ¶
func (n *MemoryNode) Scan(into interface{}) error
func (*MemoryNode) Set ¶
func (t *MemoryNode) Set(keypath Keypath, rng *Range, value interface{}) error
func (*MemoryNode) SliceValue ¶
func (n *MemoryNode) SliceValue(keypath Keypath) ([]interface{}, bool, error)
func (*MemoryNode) StringValue ¶
func (n *MemoryNode) StringValue(keypath Keypath) (string, bool, error)
func (*MemoryNode) Subkeys ¶
func (n *MemoryNode) Subkeys() []Keypath
Subkeys returns only the keys that are direct descendants of the given node.
func (*MemoryNode) UintValue ¶
func (n *MemoryNode) UintValue(keypath Keypath) (uint64, bool, error)
func (*MemoryNode) UnmarshalJSON ¶
func (n *MemoryNode) UnmarshalJSON(bs []byte) error
type Node ¶
type Node interface { Close() Keypath() Keypath NodeInfo(keypath Keypath) (NodeType, ValueType, uint64, error) Length() (uint64, error) Subkeys() []Keypath NumSubkeys() uint64 IndexOfMapSubkey(rootKeypath Keypath, subkey Keypath) (uint64, error) // NthMapSubkey(rootKeypath Keypath, n uint64) (Keypath, error) Exists(keypath Keypath) (bool, error) NodeAt(keypath Keypath, rng *Range) Node ParentNodeFor(keypath Keypath) (Node, Keypath) DebugPrint(printFn func(inFormat string, args ...interface{}), newlines bool, indentLevel int) Value(keypath Keypath, rng *Range) (interface{}, bool, error) UintValue(keypath Keypath) (uint64, bool, error) IntValue(keypath Keypath) (int64, bool, error) FloatValue(keypath Keypath) (float64, bool, error) BoolValue(keypath Keypath) (bool, bool, error) StringValue(keypath Keypath) (string, bool, error) BytesValue(keypath Keypath) ([]byte, bool, error) MapValue(keypath Keypath) (map[string]interface{}, bool, error) SliceValue(keypath Keypath) ([]interface{}, bool, error) Scan(into interface{}) error Set(keypath Keypath, rng *Range, val interface{}) error Delete(keypath Keypath, rng *Range) error Diff() *Diff ResetDiff() CopyToMemory(keypath Keypath, rng *Range) (Node, error) Iterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator ChildIterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator DepthFirstIterator(keypath Keypath, prefetchValues bool, prefetchSize int) Iterator // contains filtered or unexported methods }
A Node is a view over the database at a particular keypath
type StateBytesMarshaler ¶
type StateBytesUnmarshaler ¶
type Version ¶
type Version [32]byte
func NewPopulatedVersion ¶
func NewPopulatedVersion(_ gogoprotobufTest) *Version
func RandomVersion ¶
func RandomVersion() Version
func VersionFromBytes ¶
func VersionFromHex ¶
func VersionFromString ¶
func (Version) MarshalJSON ¶
func (Version) MarshalText ¶
func (*Version) ScanMapKey ¶
func (*Version) UnmarshalJSON ¶
func (*Version) UnmarshalText ¶
type VersionSet ¶
type VersionSet map[Version]struct{}
func NewVersionSet ¶
func NewVersionSet(vals []Version) VersionSet
func (VersionSet) Add ¶
func (s VersionSet) Add(val Version) VersionSet
func (VersionSet) Any ¶
func (s VersionSet) Any() Version
func (VersionSet) Copy ¶
func (s VersionSet) Copy() VersionSet
func (VersionSet) Remove ¶
func (s VersionSet) Remove(val Version) VersionSet
func (VersionSet) Slice ¶
func (s VersionSet) Slice() []Version
type VersionedDBTree ¶
func NewVersionedDBTree ¶
func NewVersionedDBTree(badgerOpts badger.Options) (*VersionedDBTree, error)
func (*VersionedDBTree) BuildIndex ¶
func (*VersionedDBTree) Close ¶
func (t *VersionedDBTree) Close() error
func (*VersionedDBTree) CopyVersion ¶
func (t *VersionedDBTree) CopyVersion(dstVersion, srcVersion Version) error
func (*VersionedDBTree) DeleteDB ¶
func (t *VersionedDBTree) DeleteDB() error
func (*VersionedDBTree) IndexAtVersion ¶
func (*VersionedDBTree) StateAtVersion ¶
func (t *VersionedDBTree) StateAtVersion(version *Version, mutable bool) *DBNode