Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeFieldToIndexValue(val document.Value) ([]byte, error)
- type Index
- type ListIndex
- func (i *ListIndex) AscendGreaterOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) error) error
- func (i *ListIndex) Delete(val document.Value, key []byte) error
- func (i *ListIndex) DescendLessOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) error) error
- func (i *ListIndex) Set(val document.Value, key []byte) error
- func (i *ListIndex) Truncate() error
- type Pivot
- type Type
- type UniqueIndex
- func (i *UniqueIndex) AscendGreaterOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) error) error
- func (i *UniqueIndex) Delete(val document.Value, key []byte) error
- func (i *UniqueIndex) DescendLessOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) error) error
- func (i *UniqueIndex) Set(val document.Value, key []byte) error
- func (i *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 ¶
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. AscendGreaterOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) 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. DescendLessOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) 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 ¶ added in v0.4.0
type ListIndex struct {
// contains filtered or unexported fields
}
ListIndex is an implementation that associates a value with a list of keys.
func NewListIndex ¶ added in v0.4.0
func NewListIndex(tx engine.Transaction, idxName string) *ListIndex
NewListIndex creates an index that associates a value with a list of keys.
func (*ListIndex) AscendGreaterOrEqual ¶ added in v0.4.0
func (i *ListIndex) AscendGreaterOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) 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 ¶ added in v0.4.0
func (i *ListIndex) DescendLessOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) 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 Pivot ¶ added in v0.4.0
A Pivot is a value that is used to seek for a particular value in an index. A Pivot is typed and can only be used to seek for values of the same type.
func EmptyPivot ¶ added in v0.3.0
EmptyPivot returns a pivot that starts at the beginning of any indexed values compatible with the given type.
type Type ¶ added in v0.3.0
type Type byte
Type of the index. Values are stored in different sub indexes depending on their types. They are automatically converted to one of the following types:
Text and Blob values are stored in Bytes indexes. Signed, unsigned integers, and floats are stored in Float indexes. Booleans are stores in Bool indexes.
func NewTypeFromValueType ¶ added in v0.3.0
NewTypeFromValueType returns the right index type associated with t.
type UniqueIndex ¶ added in v0.4.0
type UniqueIndex struct {
// contains filtered or unexported fields
}
UniqueIndex is an implementation that associates a value with a exactly one key.
func NewUniqueIndex ¶ added in v0.4.0
func NewUniqueIndex(tx engine.Transaction, idxName string) *UniqueIndex
NewUniqueIndex creates an index that associates a value with a exactly one key.
func (*UniqueIndex) AscendGreaterOrEqual ¶ added in v0.4.0
func (i *UniqueIndex) AscendGreaterOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) 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 ¶ added in v0.4.0
func (i *UniqueIndex) Delete(val document.Value, key []byte) error
Delete all the references to the key from the index.
func (*UniqueIndex) DescendLessOrEqual ¶ added in v0.4.0
func (i *UniqueIndex) DescendLessOrEqual(pivot *Pivot, fn func(val document.Value, key []byte) 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 ¶ added in v0.4.0
func (i *UniqueIndex) Set(val document.Value, key []byte) error
Set associates a value with exactly one key. If the association already exists, it returns an error.
func (*UniqueIndex) Truncate ¶ added in v0.4.0
func (i *UniqueIndex) Truncate() error
Truncate deletes all the index data.