Documentation
¶
Index ¶
- Constants
- Variables
- type Index
- type ListIndex
- func (idx *ListIndex) AscendGreaterOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error
- func (idx *ListIndex) Delete(v document.Value, k []byte) error
- func (idx *ListIndex) DescendLessOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error
- func (idx *ListIndex) Set(v document.Value, k []byte) error
- func (idx *ListIndex) Truncate() error
- type UniqueIndex
- func (idx *UniqueIndex) AscendGreaterOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error
- func (idx *UniqueIndex) Delete(v document.Value, k []byte) error
- func (idx *UniqueIndex) DescendLessOrEqual(pivot document.Value, fn func(val, key []byte, isEqual bool) error) error
- func (idx *UniqueIndex) Set(v document.Value, k []byte) error
- func (idx *UniqueIndex) Truncate() error
Constants ¶
const ( // StorePrefix is the prefix used to name the index store. StorePrefix = "i" + string(separator) )
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 ¶
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) 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.
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.