index

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicate is returned when a value is already associated with a key
	ErrDuplicate = errors.New("duplicate")
)

Functions

This section is empty.

Types

type Index

type Index struct {
	Unique bool
	Type   document.ValueType
	// contains filtered or unexported fields
}

An Index associates encoded values with keys. It is sorted by value following the lexicographic order.

func New added in v0.9.0

func New(tx engine.Transaction, idxName string, opts Options) *Index

New creates an index that associates a value with a list of keys.

func (*Index) AscendGreaterOrEqual

func (idx *Index) AscendGreaterOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error

AscendGreaterOrEqual seeks for the pivot and then goes through all the subsequent key value pairs in increasing order and calls the given function for each pair. If the given function returns an error, the iteration stops and returns that error. If the pivot is empty, starts from the beginning.

func (*Index) Delete

func (idx *Index) Delete(v document.Value, k []byte) error

Delete all the references to the key from the index.

func (*Index) DescendLessOrEqual

func (idx *Index) DescendLessOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error

DescendLessOrEqual seeks for the pivot and then goes through all the subsequent key value pairs in descreasing order and calls the given function for each pair. If the given function returns an error, the iteration stops and returns that error. If the pivot is empty, starts from the end.

func (*Index) EncodeValue added in v0.9.0

func (idx *Index) EncodeValue(v document.Value) ([]byte, error)

EncodeValue encodes the value we are going to use as a key, If the index is typed, encode the value without expecting the presence of other types. Ff not, encode so that order is preserved regardless of the type.

func (*Index) Set

func (idx *Index) Set(v document.Value, k []byte) error

Set associates a value with a key. If Unique is set to false, it is possible to associate multiple keys for the same value but a key can be associated to only one value.

func (*Index) Truncate

func (idx *Index) Truncate() error

Truncate deletes all the index data.

type Options added in v0.8.0

type Options struct {
	Unique bool

	// If specified, the indexed expects only one type.
	Type document.ValueType
}

Options of the index.

Jump to

Keyboard shortcuts

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