Documentation
¶
Overview ¶
package object_kvstore define a generic wrapper store for a protobuff serializable entity
package raccoon is a lightweight and minimal graph store library
Index ¶
- Constants
- Variables
- func ProduceTrue[T any](t T) bool
- type Data
- type DirectedEdge
- type Edge
- type EdgeKeyer
- type EdgeStore
- func (s *EdgeStore[Edg, N]) Delete(edg Edg) error
- func (s *EdgeStore[Edg, N]) GetAncestors(node N) ([]Edg, error)
- func (s *EdgeStore[Edg, N]) GetEdg(source, dest N) (Option[Edg], error)
- func (s *EdgeStore[Edg, N]) GetSucessors(node N) ([]Edg, error)
- func (s *EdgeStore[Edg, N]) List() ([]Edg, error)
- func (s *EdgeStore[Edg, N]) Set(edg Edg) error
- type Ider
- type Iterator
- type Json
- type KVStore
- type Key
- type Mapper
- type Marshaler
- type NodeKeyer
- type ObjKV
- type ObjectPredicate
- type ObjectStore
- func (s *ObjectStore[Obj]) Delete(obj Obj) error
- func (s *ObjectStore[Obj]) DeleteById(id []byte) error
- func (s *ObjectStore[Obj]) Filter(predicate ObjectPredicate[Obj]) ([]Obj, error)
- func (s *ObjectStore[Obj]) GetObject(id []byte) (Option[Obj], error)
- func (s *ObjectStore[Obj]) Has(obj Obj) (bool, error)
- func (s *ObjectStore[Obj]) HasById(id []byte) (bool, error)
- func (s *ObjectStore[Obj]) List() ([]Obj, error)
- func (s *ObjectStore[Obj]) ListIds() ([][]byte, error)
- func (s *ObjectStore[Obj]) SetObject(obj Obj) error
- type Option
- type Predicate
- type ProtoConstraint
- type RaccoonSchema
- type RaccoonStore
- func (s *RaccoonStore[Edg, N]) Delete(edg Edg) error
- func (s *RaccoonStore[Edg, N]) FilterByIdx(idxName string, value []byte, predicate Predicate[Edg]) ([]Edg, error)
- func (s *RaccoonStore[Edg, N]) Get(source, dest N) (Option[Edg], error)
- func (s *RaccoonStore[Edg, N]) GetAncestors(node N) ([]Edg, error)
- func (s *RaccoonStore[Edg, N]) GetByIdx(idxName string, value []byte) ([]Edg, error)
- func (s *RaccoonStore[Edg, N]) GetSucessors(node N) ([]Edg, error)
- func (s *RaccoonStore[Edg, N]) List() ([]Edg, error)
- func (s *RaccoonStore[Edg, N]) Set(edg Edg) error
- type SecondaryIdxKeyer
- type SecondaryIndex
- type SecondaryIndexStore
- type TypePointer
- type UndirectedEdge
- type WrapperKV
Constants ¶
const Separator = '/'
Separator used to build keys
Variables ¶
var File_data_proto protoreflect.FileDescriptor
Functions ¶
func ProduceTrue ¶
Types ¶
type Data ¶
type Data struct { Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*Data) Descriptor
deprecated
func (*Data) ProtoMessage ¶
func (*Data) ProtoMessage()
func (*Data) ProtoReflect ¶
func (x *Data) ProtoReflect() protoreflect.Message
type DirectedEdge ¶
DirectedEdge specialization of an Edge.
type Edge ¶
type Edge[Node any] interface { GetSource() Node GetDest() Node }
Edge represents a protobuff serializable type which is persisted. Edge contains a source and a target Node. Users implementing the Edge interface are free to add extra data to the edge type. Edges are uniquely identified through their nodes
type EdgeKeyer ¶
type EdgeKeyer[Node any] struct { // contains filtered or unexported fields }
func NewEdgeKeyer ¶
func (*EdgeKeyer[Node]) AllEdges ¶
AllEdges return a pair of keys which span through all possible set of edges
func (*EdgeKeyer[Node]) AncestorsIterKey ¶
func (*EdgeKeyer[Node]) IncomingKey ¶
OutgoingKey represents a key from target to source
func (*EdgeKeyer[Node]) OutgoingKey ¶
OutgoingKey represents a key from source to target
func (*EdgeKeyer[Node]) SucessorsIterKeys ¶
Build a pair of keys for iteration. IterKeys are used to return all edges starting from Node
type EdgeStore ¶
Store for Graph Edges
Provides the usual Get, Set, Delete operations for records. Also exposes a higher level operation to return all records which contain a Node's sucessor and ancestor.
EdgeStore maintains an internal index for a node's ancestors and sucessors, allowing for fast lookup. Setting and Deleting records updates internal indexes to guarantee consistency. TODO make it atomic
func NewEdgeStore ¶
func (*EdgeStore[Edg, N]) GetAncestors ¶
Return all Records in which `node` is the edge's target
func (*EdgeStore[Edg, N]) GetEdg ¶
Fetch stored Record for the given edge. Return record, an ok flag and a potential error If the OK flag is false, no record was found or an error ocurred
func (*EdgeStore[Edg, N]) GetSucessors ¶
Return all Records in which `node` is the edge's source
type Iterator ¶
type Iterator interface { // Valid returns whether the current iterator is valid. Once invalid, the Iterator remains // invalid forever. Valid() bool // Next moves the iterator to the next key in the database, as defined by order of iteration. // If Valid returns false, this method will panic. Next() // Key returns the key at the current position. Panics if the iterator is invalid. // CONTRACT: key readonly []byte Key() (key []byte) // Value returns the value at the current position. Panics if the iterator is invalid. // CONTRACT: value readonly []byte Value() (value []byte) // Error returns the last error encountered by the iterator, if any. Error() error // Close closes the iterator, relasing any allocated resources. Close() error }
type KVStore ¶
type KVStore interface { Get(key []byte) ([]byte, error) Has(key []byte) (bool, error) Set(key, value []byte) error Delete(key []byte) error Iterator(start, end []byte) Iterator }
Type alias for KVStore
func KvFromCosmosKv ¶
func NewLevelDB ¶
func NewWrapperKV ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents a hiearachical key built from fragments. Key fragments are ordered and the final key is built joining fragments with a a constant separator.
type Marshaler ¶
Marshaler marshalls and unmarshalls objects into a byte array, which gets persisted in the underlying store
func ProtoMarshaler ¶
type NodeKeyer ¶
type NodeKeyer[T any] interface { // Maps a Node into a key. Key(T) []byte // Return the lowest possible key MinKey() []byte // Return the highest possible key MaxKey() []byte }
NodeKeyer interface specify methods to map a node into an identifier key. Keys are an user defined byte array. Key values are opaque to the library however they must be deterministic and unique. Furthermore, keys should have known bounds, which are used for iteration.
NodeKeyer decouples node identification from data, which allows for different key generation strategies based on usage patterns.
type ObjKV ¶
type ObjKV[T any] interface { // Fetch object from store using the given key Get(key []byte) (Option[T], error) // Check whether key exists in KVStore Has(key []byte) (bool, error) // Set key with obj Set(key []byte, obj T) error // Remove key from store Delete(key []byte) error }
Type ObjKV wraps KVStore by abstracting object marshaling
type ObjectPredicate ¶
type ObjectStore ¶
type ObjectStore[Obj any] struct { // contains filtered or unexported fields }
func NewObjStore ¶
func NewObjStore[O any](kv KVStore, marshaler Marshaler[O], ider Ider[O]) ObjectStore[O]
func (*ObjectStore[Obj]) Delete ¶
func (s *ObjectStore[Obj]) Delete(obj Obj) error
func (*ObjectStore[Obj]) DeleteById ¶
func (s *ObjectStore[Obj]) DeleteById(id []byte) error
func (*ObjectStore[Obj]) Filter ¶
func (s *ObjectStore[Obj]) Filter(predicate ObjectPredicate[Obj]) ([]Obj, error)
func (*ObjectStore[Obj]) GetObject ¶
func (s *ObjectStore[Obj]) GetObject(id []byte) (Option[Obj], error)
func (*ObjectStore[Obj]) Has ¶
func (s *ObjectStore[Obj]) Has(obj Obj) (bool, error)
func (*ObjectStore[Obj]) List ¶
func (s *ObjectStore[Obj]) List() ([]Obj, error)
func (*ObjectStore[Obj]) ListIds ¶
func (s *ObjectStore[Obj]) ListIds() ([][]byte, error)
func (*ObjectStore[Obj]) SetObject ¶
func (s *ObjectStore[Obj]) SetObject(obj Obj) error
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Option type is a container for a value Option may or may not contain value
type ProtoConstraint ¶
type RaccoonSchema ¶
type RaccoonSchema[Edg Edge[N], N any] struct { Indexes []SecondaryIndex[Edg, N] Store KVStore KeysPrefix []byte Keyer NodeKeyer[N] Marshaler Marshaler[Edg] }
Raccoon Store schema
type RaccoonStore ¶
RaccoonStore is a general purpose Graph store. It's built on top of a kv-store backend and provides common operations required while working with graphs.
RaccoonStore has a lightweight secondary indexing framework, which can be used to optimize recurring access patterns.
The main RaccoonStore type is a lightweight orchestrator on top of the primary index store and additional secondary index stores.
TODO Make these atomic
func NewRaccoonStore ¶
func NewRaccoonStore[Edg Edge[N], N any](schema RaccoonSchema[Edg, N]) RaccoonStore[Edg, N]
Build a Raccoon instance from a schema definition
func (*RaccoonStore[Edg, N]) Delete ¶
func (s *RaccoonStore[Edg, N]) Delete(edg Edg) error
Delete edg from the persistent storage
func (*RaccoonStore[Edg, N]) FilterByIdx ¶
func (s *RaccoonStore[Edg, N]) FilterByIdx(idxName string, value []byte, predicate Predicate[Edg]) ([]Edg, error)
Filter and return all Edges from index idxName, indexed by value that match the given predicate
func (*RaccoonStore[Edg, N]) Get ¶
func (s *RaccoonStore[Edg, N]) Get(source, dest N) (Option[Edg], error)
Fetch and Edge from the source and destiniation nodes
func (*RaccoonStore[Edg, N]) GetAncestors ¶
func (s *RaccoonStore[Edg, N]) GetAncestors(node N) ([]Edg, error)
Return the direct ancestors of a Node, that is, returns all edges that have node as dest. Note: Does not recursively fetch Ancestors
func (*RaccoonStore[Edg, N]) GetByIdx ¶
func (s *RaccoonStore[Edg, N]) GetByIdx(idxName string, value []byte) ([]Edg, error)
Fetch all Edges from index idxName indexed by value
func (*RaccoonStore[Edg, N]) GetSucessors ¶
func (s *RaccoonStore[Edg, N]) GetSucessors(node N) ([]Edg, error)
Return all direct sucessors of a Node, that is, returns all edges that have node as source. Note: Does not recursively fetch Ancestors
func (*RaccoonStore[Edg, N]) List ¶
func (s *RaccoonStore[Edg, N]) List() ([]Edg, error)
List returns all Edges in RaccoonStore
type SecondaryIdxKeyer ¶
func NewSecIdxKeyer ¶
func (*SecondaryIdxKeyer[Edg, N]) IterKeys ¶
func (k *SecondaryIdxKeyer[Edg, N]) IterKeys(idx []byte) (Key, Key)
func (*SecondaryIdxKeyer[Edg, N]) Key ¶
func (k *SecondaryIdxKeyer[Edg, N]) Key(edg Edg) Key
Return key for a record Format: /{prefix}/{idxName}/{val}/{recordKey}
type SecondaryIndex ¶
Secondary Index schema definition Specifies the index name and a mapper function.
type SecondaryIndexStore ¶
Store Wrapper for records indexed by a certain field Keys in store have the pattern: {prefix}/{indexName}/{mappedValue}/{edgeKey}
func NewSecondaryIdxStore ¶
func (*SecondaryIndexStore[Edg, N]) Delete ¶
func (s *SecondaryIndexStore[Edg, N]) Delete(edg Edg) error
func (*SecondaryIndexStore[Edg, N]) FilterByIdx ¶
func (s *SecondaryIndexStore[Edg, N]) FilterByIdx(idx []byte, predicate Predicate[Edg]) ([]Edg, error)
func (*SecondaryIndexStore[Edg, N]) GetByIdx ¶
func (s *SecondaryIndexStore[Edg, N]) GetByIdx(idx []byte) ([]Edg, error)
func (*SecondaryIndexStore[Edg, N]) Set ¶
func (s *SecondaryIndexStore[Edg, N]) Set(edg Edg) error
type TypePointer ¶
type TypePointer[T any] interface { *T }
type UndirectedEdge ¶
UndirectedEdge specialization of an Edge.