table

package
v0.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2016 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Overview

Package table implements lookup table interfaces for protobufs.

Index

Constants

This section is empty.

Variables

View Source
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

type KVInverted struct{ keyvalue.DB }

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.

func (*KVInverted) Lookup

func (i *KVInverted) Lookup(_ context.Context, val []byte, prefixLookup bool) ([][]byte, error)

Lookup implements part of the Inverted interface.

func (*KVInverted) Put

func (i *KVInverted) Put(ctx context.Context, key, val []byte) error

Put implements part of the Inverted interface.

type KVProto

type KVProto struct{ keyvalue.DB }

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.

func (*KVProto) Close added in v0.0.9

func (t *KVProto) Close(_ context.Context) error

Close implements part of the Proto interface.

func (*KVProto) Lookup

func (t *KVProto) Lookup(_ context.Context, key []byte, msg proto.Message) error

Lookup implements part of the Proto interface.

func (*KVProto) Put

func (t *KVProto) Put(ctx context.Context, key []byte, msg proto.Message) error

Put 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.

type ProtoResult added in v0.0.9

type ProtoResult struct {
	Key   []byte
	Value proto.Message
	Err   error
}

ProtoResult is a result for a single key given to a LookupBatch call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL