table

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2015 License: Apache-2.0 Imports: 7 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 Inverted

type Inverted interface {
	io.Closer

	// 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(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(key, val []byte, prefix bool) (bool, error)

	// Put writes an entry associating val with key.
	Put(key, val []byte) 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) Contains

func (i *KVInverted) Contains(key, val []byte, prefixLookup bool) (found bool, err error)

Contains implements part of the Inverted interface.

func (*KVInverted) Lookup

func (i *KVInverted) Lookup(val []byte, prefixLookup bool) ([][]byte, error)

Lookup implements part of the Inverted interface.

func (*KVInverted) Put

func (i *KVInverted) Put(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) Lookup

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

Lookup implements part of the Proto interface.

func (*KVProto) Put

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

Put implements part of the Proto interface.

type Proto

type Proto interface {
	io.Closer

	// Lookup unmarshals the value for the given key into msg, returning any
	// error.  If the key was not found, ErrNoSuchKey is returned.
	Lookup(key []byte, msg proto.Message) error

	// Put marshals msg and writes it as the value for the given key.
	Put(key []byte, msg proto.Message) error
}

Proto is a key-value direct lookup table with protobuf values.

Jump to

Keyboard shortcuts

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