Documentation ¶
Overview ¶
Package keyvalue implements a generic GraphStore for anything that implements the DB interface.
Index ¶
- func EncodeKey(source *spb.VName, factName string, edgeKind string, target *spb.VName) ([]byte, error)
- func Entry(key []byte, val []byte) (*spb.Entry, error)
- func KeyPrefix(source *spb.VName, edgeKind string) ([]byte, error)
- type DB
- type Iterator
- type Options
- type Range
- type Snapshot
- type Store
- func (s *Store) Close(ctx context.Context) error
- func (s *Store) Count(ctx context.Context, req *spb.CountRequest) (int64, error)
- func (s *Store) Read(ctx context.Context, req *spb.ReadRequest, f graphstore.EntryFunc) error
- func (s *Store) Scan(ctx context.Context, req *spb.ScanRequest, f graphstore.EntryFunc) error
- func (s *Store) Shard(ctx context.Context, req *spb.ShardRequest, f graphstore.EntryFunc) error
- func (s *Store) Write(ctx context.Context, req *spb.WriteRequest) (err error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeKey ¶
func EncodeKey(source *spb.VName, factName string, edgeKind string, target *spb.VName) ([]byte, error)
EncodeKey returns a canonical encoding of an Entry (minus its value).
Types ¶
type DB ¶
type DB interface { io.Closer // ScanPrefix returns an Iterator for all key-values starting with the given // key prefix. Options may be nil to use the defaults. ScanPrefix([]byte, *Options) (Iterator, error) // ScanRange returns an Iterator for all key-values starting with the given // key range. Options may be nil to use the defaults. ScanRange(*Range, *Options) (Iterator, error) // Writer return a new write-access object Writer() (Writer, error) // NewSnapshot returns a new consistent view of the DB that can be passed as // an option to DB scan methods. NewSnapshot() Snapshot }
A DB is a sorted key-value store with read/write access. DBs must be Closed when no longer used to ensure resources are not leaked.
type Iterator ¶
type Iterator interface { io.Closer // Next returns the currently positioned key-value entry and moves to the next // entry. If there is no key-value entry to return, an io.EOF error is // returned. Next() (key, val []byte, err error) }
Iterator provides sequential access to a DB. Iterators must be Closed when no longer used to ensure that resources are not leaked.
type Options ¶
type Options struct { // LargeRead expresses the client's intent that the read will likely be // "large" and the implementation should usually avoid certain behaviors such // as caching the entire visited key-value range. Defaults to false. LargeRead bool // Snapshot causes the iterator to view the DB as it was at the Snapshot's // creation. Snapshot }
Options alters the behavior of an Iterator.
func (*Options) GetSnapshot ¶
GetSnapshot returns the Snapshot option or the default of nil when o==nil.
func (*Options) IsLargeRead ¶
IsLargeRead returns the LargeRead option or the default of false when o==nil.
type Range ¶
type Range struct {
Start, End []byte
}
Range is section of contiguous keys, including Start and excluding End.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store implements the graphstore.Service interface for a keyvalue DB
func NewGraphStore ¶
NewGraphStore returns a graphstore.Service backed by the given keyvalue DB.
func (*Store) Read ¶
func (s *Store) Read(ctx context.Context, req *spb.ReadRequest, f graphstore.EntryFunc) error
Read implements part of the graphstore.Service interface.
func (*Store) Scan ¶
func (s *Store) Scan(ctx context.Context, req *spb.ScanRequest, f graphstore.EntryFunc) error
Scan implements part of the graphstore.Service interface.
func (*Store) Shard ¶
func (s *Store) Shard(ctx context.Context, req *spb.ShardRequest, f graphstore.EntryFunc) error
Shard implements part of the graphstore.Sharded interface.