Documentation
¶
Index ¶
- Variables
- type Index
- func (idx *Index) AscendGreaterOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error
- func (idx *Index) Delete(v document.Value, k []byte) error
- func (idx *Index) DescendLessOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error
- func (idx *Index) EncodeValue(v document.Value) ([]byte, error)
- func (idx *Index) Set(v document.Value, k []byte) error
- func (idx *Index) Truncate() error
- type Options
Constants ¶
This section is empty.
Variables ¶
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 ¶
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) 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
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.