indexer

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: MPL-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingValueForIndex = fmt.Errorf("object is missing a value for this index")

Functions

func IndexFromTimeQuery

func IndexFromTimeQuery(arg any) ([]byte, error)

IndexFromTimeQuery can be used as a memdb.Indexer query via ReadIndex and allows querying by time.

Types

type IndexBuilder

type IndexBuilder bytes.Buffer

IndexBuilder is a buffer used to construct memdb index values.

func (*IndexBuilder) Bytes

func (b *IndexBuilder) Bytes() []byte

Bytes returns the stored IndexBuilder value as a byte array.

func (*IndexBuilder) Time

func (b *IndexBuilder) Time(t time.Time)

Time is used to write the passed time into the IndexBuilder for use as a memdb index value.

type ReadIndex

type ReadIndex func(arg any) ([]byte, error)

ReadIndex implements memdb.Indexer. It exists so that a function can be used to provide the interface.

Unlike memdb.Indexer, a readIndex function accepts only a single argument. To generate an index from multiple values, use a struct type with multiple fields.

func (ReadIndex) FromArgs

func (f ReadIndex) FromArgs(args ...interface{}) ([]byte, error)

type SingleIndexer

type SingleIndexer struct {

	// readIndex is used by memdb for Txn.Get, Txn.First, and other operations
	// that read data.
	ReadIndex

	// writeIndex is used by memdb for Txn.Insert, Txn.Delete, and other
	// operations that write data to the index.
	WriteIndex
}

SingleIndexer implements both memdb.Indexer and memdb.SingleIndexer. It may be used in a memdb.IndexSchema to specify functions that generate the index value for memdb.Txn operations.

type TimeQuery

type TimeQuery struct {
	Value time.Time
}

type WriteIndex

type WriteIndex func(raw any) ([]byte, error)

WriteIndex implements memdb.SingleIndexer. It exists so that a function can be used to provide this interface.

Instead of a bool return value, writeIndex expects errMissingValueForIndex to indicate that an index could not be build for the object. It will translate this error into a false value to satisfy the memdb.SingleIndexer interface.

func (WriteIndex) FromObject

func (f WriteIndex) FromObject(raw any) (bool, []byte, error)

Jump to

Keyboard shortcuts

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