Documentation
¶
Index ¶
- func DefaultBoltPath() string
- func GetBoltDb(file string) (*bolt.DB, error)
- func GetItemKey(item search.ExternalResultItem) ([]byte, error)
- type BoltStorage
- func (b *BoltStorage) Close()
- func (b *BoltStorage) Create(item search.Record, additionalPK *indexing.Key) error
- func (b *BoltStorage) CreateWithId(keyParts *indexing.Key, item search.Record, uniqueIndexKeys *indexing.Key) error
- func (b *BoltStorage) Find(query indexing.Query, result interface{}) error
- func (b *BoltStorage) ForEach(callback func(record interface{}))
- func (b *BoltStorage) GetBucket(tx *bolt.Tx, children ...string) *bolt.Bucket
- func (b *BoltStorage) GetIndexFromQuery(bucket *bolt.Bucket, query indexing.Query) (indexing.Index, error)
- func (b *BoltStorage) GetNewest(count int) []search.ExternalResultItem
- func (b *BoltStorage) GetSearchResults(categoryId int) ([]search.ExternalResultItem, error)
- func (b *BoltStorage) GetUniqueIndexFromKeys(bucket *bolt.Bucket, keyParts *indexing.Key) (indexing.Index, error)
- func (b *BoltStorage) HasIndex(meta *indexing.IndexMetadata) bool
- func (b *BoltStorage) SetNamespace(namespace string)
- func (b *BoltStorage) Size() int64
- func (b *BoltStorage) StoreSearchResults(items []search.ExternalResultItem) error
- func (b *BoltStorage) Truncate() error
- func (b *BoltStorage) Update(query indexing.Query, item interface{}) error
- type IndexDoesNotExistAndNotWritable
- type ListIndex
- func (ix *ListIndex) Add(val []byte, id []byte) error
- func (ix *ListIndex) All(indexValue []byte, opts *indexing.CursorOptions) [][]byte
- func (ix *ListIndex) AllRecords(opts *indexing.CursorOptions) [][]byte
- func (ix *ListIndex) Get(indexValue []byte) []byte
- func (ix *ListIndex) Prefix(prefix []byte, opts *indexing.CursorOptions) [][]byte
- func (ix *ListIndex) Range(min []byte, max []byte, opts *indexing.CursorOptions) [][]byte
- func (ix *ListIndex) Remove(indexValue []byte) error
- func (ix *ListIndex) RemoveById(id []byte) error
- type Metadata
- type PrefixCursor
- type RangeCursor
- type ReversibleCursor
- type UniqueIndex
- func (ix *UniqueIndex) Add(indexValue []byte, id []byte) error
- func (ix *UniqueIndex) All(indexValue []byte, _ *indexing.CursorOptions) [][]byte
- func (ix *UniqueIndex) AllRecords(ops *indexing.CursorOptions) [][]byte
- func (ix *UniqueIndex) AllWithPrefix(prefix []byte, ops *indexing.CursorOptions) [][]byte
- func (ix *UniqueIndex) Get(indexValue []byte) []byte
- func (ix *UniqueIndex) Range(min []byte, max []byte, ops *indexing.CursorOptions) [][]byte
- func (ix *UniqueIndex) Remove(indexValue []byte) error
- func (ix *UniqueIndex) RemoveById(id []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBoltPath ¶
func DefaultBoltPath() string
func GetItemKey ¶ added in v0.3.4
func GetItemKey(item search.ExternalResultItem) ([]byte, error)
Types ¶
type BoltStorage ¶
func NewBoltStorage ¶
func NewBoltStorage(dbPath string, recordTypePtr interface{}) (*BoltStorage, error)
func (*BoltStorage) Close ¶
func (b *BoltStorage) Close()
func (*BoltStorage) Create ¶
Create a new record. This uses a new random UUID in order to identify the record.
func (*BoltStorage) CreateWithId ¶
func (b *BoltStorage) CreateWithId(keyParts *indexing.Key, item search.Record, uniqueIndexKeys *indexing.Key) error
CreateWithId a new record for a result. The key is used if you have a custom object that uses a different key, not the UUIDValue
func (*BoltStorage) Find ¶
func (b *BoltStorage) Find(query indexing.Query, result interface{}) error
Find something by it's index keys. Todo: refactor this
func (*BoltStorage) ForEach ¶ added in v0.3.0
func (b *BoltStorage) ForEach(callback func(record interface{}))
ForEach Goes through all the records
func (*BoltStorage) GetBucket ¶
GetBucket returns the given bucket. You can use an array of strings for sub-buckets.
func (*BoltStorage) GetIndexFromQuery ¶ added in v0.3.1
func (b *BoltStorage) GetIndexFromQuery(bucket *bolt.Bucket, query indexing.Query) (indexing.Index, error)
getIndexFromQuery gets the index from the fields in a query
func (*BoltStorage) GetNewest ¶
func (b *BoltStorage) GetNewest(count int) []search.ExternalResultItem
func (*BoltStorage) GetSearchResults ¶
func (b *BoltStorage) GetSearchResults(categoryId int) ([]search.ExternalResultItem, error)
GetSearchResults by a given category id
func (*BoltStorage) GetUniqueIndexFromKeys ¶ added in v0.3.1
func (b *BoltStorage) GetUniqueIndexFromKeys(bucket *bolt.Bucket, keyParts *indexing.Key) (indexing.Index, error)
GetUniqueIndexFromKeys gets the index from a key.
func (*BoltStorage) HasIndex ¶ added in v0.3.3
func (b *BoltStorage) HasIndex(meta *indexing.IndexMetadata) bool
func (*BoltStorage) SetNamespace ¶
func (b *BoltStorage) SetNamespace(namespace string)
func (*BoltStorage) Size ¶
func (b *BoltStorage) Size() int64
func (*BoltStorage) StoreSearchResults ¶
func (b *BoltStorage) StoreSearchResults(items []search.ExternalResultItem) error
StoreSearchResults stores the given results
func (*BoltStorage) Truncate ¶
func (b *BoltStorage) Truncate() error
type IndexDoesNotExistAndNotWritable ¶ added in v0.3.0
type IndexDoesNotExistAndNotWritable struct{}
func (*IndexDoesNotExistAndNotWritable) Error ¶ added in v0.3.0
func (e *IndexDoesNotExistAndNotWritable) Error() string
type ListIndex ¶
type ListIndex struct { ParentBucket *bolt.Bucket //Bucket that contains all the index values, with values being the ID IndexBucket *bolt.Bucket //An index that contains all of our IDs, with values being the index values IDs *UniqueIndex }
ListIndex is an index that references values and the matching IDs
func NewListIndex ¶
NewListIndex creates a new list index with it's sub-buckets.
func (*ListIndex) All ¶
func (ix *ListIndex) All(indexValue []byte, opts *indexing.CursorOptions) [][]byte
All the IDs corresponding to the given value
func (*ListIndex) AllRecords ¶
func (ix *ListIndex) AllRecords(opts *indexing.CursorOptions) [][]byte
AllRecords returns all the IDs of this index
func (*ListIndex) Prefix ¶
func (ix *ListIndex) Prefix(prefix []byte, opts *indexing.CursorOptions) [][]byte
Prefix returns the ids whose values have the given prefix.
func (*ListIndex) RemoveById ¶
RemoveById removes an index and the matching ID using an ID.
type Metadata ¶ added in v0.3.1
type Metadata struct {
Indexes map[string]indexing.IndexMetadata `json:"indexes"`
}
type PrefixCursor ¶
func (*PrefixCursor) CanContinue ¶
func (c *PrefixCursor) CanContinue(value []byte) bool
CanContinue figures out if the cursor can continue
func (*PrefixCursor) First ¶
func (c *PrefixCursor) First() ([]byte, []byte)
First item in the cursor that matches the prefix.
type RangeCursor ¶
type RangeCursor struct { C *bolt.Cursor Reverse bool Min []byte Max []byte Comparator func(a []byte, b []byte) int }
func (*RangeCursor) CanContinue ¶
func (r *RangeCursor) CanContinue(value []byte) bool
CanContinue checks if the cursor can continue to the given value
func (*RangeCursor) First ¶
func (r *RangeCursor) First() ([]byte, []byte)
First gets the first element in the range.
func (*RangeCursor) Next ¶
func (r *RangeCursor) Next() ([]byte, []byte)
Next gets the next element in the cursor.
type ReversibleCursor ¶
func (*ReversibleCursor) CanContinue ¶
func (c *ReversibleCursor) CanContinue(val []byte) bool
func (*ReversibleCursor) First ¶
func (c *ReversibleCursor) First() ([]byte, []byte)
func (*ReversibleCursor) Next ¶
func (c *ReversibleCursor) Next() ([]byte, []byte)
type UniqueIndex ¶
UniqueIndex ensures the indexed values are all unique.
func NewUniqueIndex ¶
func NewUniqueIndex(parentBucket *bolt.Bucket, name []byte) (*UniqueIndex, error)
NewUniqueIndex creates a new unique index bucket
func (*UniqueIndex) Add ¶
func (ix *UniqueIndex) Add(indexValue []byte, id []byte) error
Add a value to the unique index. We're using the index value as a keyParts and we're storing the id in there.
func (*UniqueIndex) All ¶
func (ix *UniqueIndex) All(indexValue []byte, _ *indexing.CursorOptions) [][]byte
All returns all the IDs corresponding to the given index value. For unique indexes this should be a single ID.
func (*UniqueIndex) AllRecords ¶
func (ix *UniqueIndex) AllRecords(ops *indexing.CursorOptions) [][]byte
AllRecords returns all the IDs.
func (*UniqueIndex) AllWithPrefix ¶
func (ix *UniqueIndex) AllWithPrefix(prefix []byte, ops *indexing.CursorOptions) [][]byte
AllWithPrefix finds all the IDs that are prefixed with a given byte array
func (*UniqueIndex) Get ¶
func (ix *UniqueIndex) Get(indexValue []byte) []byte
Get the id behind an indexed value.
func (*UniqueIndex) Range ¶
func (ix *UniqueIndex) Range(min []byte, max []byte, ops *indexing.CursorOptions) [][]byte
Range gets the IDs in the given range.
func (*UniqueIndex) Remove ¶
func (ix *UniqueIndex) Remove(indexValue []byte) error
Remove a index value from the unique index.
func (*UniqueIndex) RemoveById ¶
func (ix *UniqueIndex) RemoveById(id []byte) error
RemoveById removes the first id from the index that matches the given id.