index

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StorePrefix is the prefix used to name the index store.
	StorePrefix = "i" + string(separator)
)

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 interface {
	// Set associates a value with a key.
	Set(val document.Value, key []byte) error

	// Delete all the references to the key from the index.
	Delete(val document.Value, key []byte) 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 nil, starts from the beginning.
	// If val is equal to the pivot, isEqual is set to true.
	AscendGreaterOrEqual(pivot document.Value, fn func(val []byte, 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 nil, starts from the end.
	// If val is equal to the pivot, isEqual is set to true.
	DescendLessOrEqual(pivot document.Value, fn func(val []byte, key []byte, isEqual bool) error) error

	// Truncate deletes all the index data.
	Truncate() error
}

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

type ListIndex

type ListIndex struct {
	// contains filtered or unexported fields
}

ListIndex is an implementation that associates a value with a list of keys.

func NewListIndex

func NewListIndex(tx engine.Transaction, idxName string) *ListIndex

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

func (*ListIndex) AscendGreaterOrEqual

func (idx *ListIndex) 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 nil, starts from the beginning.

func (*ListIndex) Delete

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

Delete all the references to the key from the index.

func (*ListIndex) DescendLessOrEqual

func (idx *ListIndex) 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 nil, starts from the end.

func (*ListIndex) Set

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

Set associates a value with a key. It is possible to associate multiple keys for the same value but a key can be associated to only one value.

func (*ListIndex) Truncate

func (idx *ListIndex) Truncate() error

Truncate deletes all the index data.

type UniqueIndex

type UniqueIndex struct {
	// contains filtered or unexported fields
}

UniqueIndex is an implementation that associates a value with a exactly one key.

func NewUniqueIndex

func NewUniqueIndex(tx engine.Transaction, idxName string) *UniqueIndex

NewUniqueIndex creates an index that associates a value with a exactly one key.

func (*UniqueIndex) AscendGreaterOrEqual

func (idx *UniqueIndex) 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 nil, starts from the beginning.

func (*UniqueIndex) Delete

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

Delete all the references to the key from the index.

func (*UniqueIndex) DescendLessOrEqual

func (idx *UniqueIndex) 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 nil, starts from the end.

func (*UniqueIndex) Set

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

Set associates a value with exactly one key. If the association already exists, it returns an error. It stores integers as doubles.

func (*UniqueIndex) Truncate

func (idx *UniqueIndex) Truncate() error

Truncate deletes all the index data.

Jump to

Keyboard shortcuts

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