Documentation ¶
Overview ¶
Package index contains Index engines used to store values and their corresponding IDs
Index ¶
- Variables
- type Index
- type ListIndex
- func (idx *ListIndex) Add(newValue []byte, targetID []byte) error
- func (idx *ListIndex) All(value []byte, opts *Options) ([][]byte, error)
- func (idx *ListIndex) AllRecords(opts *Options) ([][]byte, error)
- func (idx *ListIndex) Get(value []byte) []byte
- func (idx *ListIndex) Prefix(prefix []byte, opts *Options) ([][]byte, error)
- func (idx *ListIndex) Range(min []byte, max []byte, opts *Options) ([][]byte, error)
- func (idx *ListIndex) Remove(value []byte) error
- func (idx *ListIndex) RemoveID(targetID []byte) error
- type Options
- type UniqueIndex
- func (idx *UniqueIndex) Add(value []byte, targetID []byte) error
- func (idx *UniqueIndex) All(value []byte, opts *Options) ([][]byte, error)
- func (idx *UniqueIndex) AllRecords(opts *Options) ([][]byte, error)
- func (idx *UniqueIndex) Get(value []byte) []byte
- func (idx *UniqueIndex) Prefix(prefix []byte, opts *Options) ([][]byte, error)
- func (idx *UniqueIndex) Range(min []byte, max []byte, opts *Options) ([][]byte, error)
- func (idx *UniqueIndex) Remove(value []byte) error
- func (idx *UniqueIndex) RemoveID(id []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when the specified record is not saved in the bucket. ErrNotFound = errors.New("not found") // ErrAlreadyExists is returned uses when trying to set an existing value on a field that has a unique index. ErrAlreadyExists = errors.New("already exists") // ErrNilParam is returned when the specified param is expected to be not nil. ErrNilParam = errors.New("param must not be nil") )
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index interface { Add(value []byte, targetID []byte) error Remove(value []byte) error RemoveID(id []byte) error Get(value []byte) []byte All(value []byte, opts *Options) ([][]byte, error) AllRecords(opts *Options) ([][]byte, error) Range(min []byte, max []byte, opts *Options) ([][]byte, error) Prefix(prefix []byte, opts *Options) ([][]byte, error) }
Index interface
type ListIndex ¶
type ListIndex struct { Parent *bolt.Bucket IndexBucket *bolt.Bucket IDs *UniqueIndex }
ListIndex is an index that references values and the corresponding IDs.
func NewListIndex ¶
NewListIndex loads a ListIndex
func (*ListIndex) AllRecords ¶
AllRecords returns all the IDs of this index
func (*ListIndex) Prefix ¶ added in v1.1.0
Prefix returns the ids whose values have the given prefix.
type UniqueIndex ¶
UniqueIndex is an index that references unique values and the corresponding ID.
func NewUniqueIndex ¶
func NewUniqueIndex(parent *bolt.Bucket, indexName []byte) (*UniqueIndex, error)
NewUniqueIndex loads a UniqueIndex
func (*UniqueIndex) Add ¶
func (idx *UniqueIndex) Add(value []byte, targetID []byte) error
Add a value to the unique index
func (*UniqueIndex) All ¶
func (idx *UniqueIndex) All(value []byte, opts *Options) ([][]byte, error)
All returns all the ids corresponding to the given value
func (*UniqueIndex) AllRecords ¶
func (idx *UniqueIndex) AllRecords(opts *Options) ([][]byte, error)
AllRecords returns all the IDs of this index
func (*UniqueIndex) Get ¶
func (idx *UniqueIndex) Get(value []byte) []byte
Get the id corresponding to the given value
func (*UniqueIndex) Prefix ¶ added in v1.1.0
func (idx *UniqueIndex) Prefix(prefix []byte, opts *Options) ([][]byte, error)
Prefix returns the ids whose values have the given prefix.
func (*UniqueIndex) Remove ¶
func (idx *UniqueIndex) Remove(value []byte) error
Remove a value from the unique index
func (*UniqueIndex) RemoveID ¶
func (idx *UniqueIndex) RemoveID(id []byte) error
RemoveID removes an ID from the unique index