Documentation ¶
Overview ¶
Package table implements lookup table interfaces for protobufs.
Index ¶
- Variables
- type BufferedInverted
- type BufferedProto
- type Inverted
- type KVInverted
- func (i *KVInverted) Buffered() BufferedInverted
- func (i *KVInverted) Close(_ context.Context) error
- func (i *KVInverted) Contains(_ context.Context, key, val []byte, prefixLookup bool) (found bool, err error)
- func (i *KVInverted) Lookup(_ context.Context, val []byte, prefixLookup bool) ([][]byte, error)
- func (i *KVInverted) Put(ctx context.Context, key, val []byte) error
- type KVProto
- type Proto
- type ProtoBatch
- type ProtoBatchParallel
- type ProtoResult
Constants ¶
This section is empty.
Variables ¶
var ErrNoSuchKey = errors.New("no such key")
ErrNoSuchKey is returned when a value was not found for a particular key.
Functions ¶
This section is empty.
Types ¶
type BufferedInverted ¶ added in v0.0.16
type BufferedInverted interface { // Put writes an entry associating val with key. Put(ctx context.Context, key, val []byte) error // Flush sends all buffered writes to the underlying table. Flush(ctx context.Context) error }
BufferedInverted buffers calls to Put to provide a high throughput write interface to a Inverted table.
type BufferedProto ¶ added in v0.0.16
type BufferedProto interface { // Put marshals msg and writes it as the value for the given key. Put(ctx context.Context, key []byte, msg proto.Message) error // Flush sends all buffered writes to the underlying table. Flush(ctx context.Context) error }
BufferedProto buffers calls to Put to provide a high throughput write interface to a Proto table.
type Inverted ¶
type Inverted interface { // Lookup returns a slice of []byte keys associated with the given value. If // prefix is true, all keys associated with values with val as their prefix // will be returned, otherwise val is exactly matched. Lookup(ctx context.Context, val []byte, prefix bool) ([][]byte, error) // Contains determines whether there is an association between key and val. // If prefix is true, if key is associated with any value with val as its // prefix true will be returned, otherwise val must be exactly associated with // key. Contains(ctx context.Context, key, val []byte, prefix bool) (bool, error) // Put writes an entry associating val with key. Put(ctx context.Context, key, val []byte) error // Buffered returns a buffered write interface. Buffered() BufferedInverted // Close release the underlying resources for the table. Close(context.Context) error }
Inverted is an inverted index lookup table for []byte values with associated []byte keys. Keys and values should not contain \000 bytes.
type KVInverted ¶
KVInverted implements an Inverted table in a keyvalue.DB.
func (*KVInverted) Buffered ¶ added in v0.0.16
func (i *KVInverted) Buffered() BufferedInverted
Buffered implements part of the Inverted interface.
func (*KVInverted) Close ¶ added in v0.0.9
func (i *KVInverted) Close(_ context.Context) error
Close implements part of the Inverted interface.
func (*KVInverted) Contains ¶
func (i *KVInverted) Contains(_ context.Context, key, val []byte, prefixLookup bool) (found bool, err error)
Contains implements part of the Inverted interface.
type KVProto ¶
KVProto implements a Proto table using a keyvalue.DB.
func (*KVProto) Buffered ¶ added in v0.0.16
func (t *KVProto) Buffered() BufferedProto
Buffered implements part of the Proto interface.
type Proto ¶
type Proto interface { // Lookup unmarshals the value for the given key into msg, returning any // error. If the key was not found, ErrNoSuchKey is returned. Lookup(ctx context.Context, key []byte, msg proto.Message) error // Put marshals msg and writes it as the value for the given key. Put(ctx context.Context, key []byte, msg proto.Message) error // Buffered returns a buffered write interface. Buffered() BufferedProto // Close release the underlying resources for the table. Close(context.Context) error }
Proto is a key-value direct lookup table with protobuf values.
type ProtoBatch ¶ added in v0.0.9
type ProtoBatch interface { Proto // LookupBatch retrieves the values for the given slice of keys, unmarshaling // each value into a new proto.Message of the same type as msg, and sending it // as a ProtoResult to the returned channel. LookupBatch(ctx context.Context, keys [][]byte, msg proto.Message) (<-chan ProtoResult, error) }
ProtoBatch is a key-value lookup table with batch retrieval.
type ProtoBatchParallel ¶ added in v0.0.9
type ProtoBatchParallel struct{ Proto }
ProtoBatchParallel implements the ProtoBatch interface by parallelizing calls to Lookup.
func (ProtoBatchParallel) LookupBatch ¶ added in v0.0.9
func (p ProtoBatchParallel) LookupBatch(ctx context.Context, keys [][]byte, msg proto.Message) (<-chan ProtoResult, error)
LookupBatch implements the ProtoBatch interface.