bolt

package
v0.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBoltPath

func DefaultBoltPath() string

func GetBoltDb

func GetBoltDb(file string) (*bolt.DB, error)

func GetItemKey added in v0.3.4

func GetItemKey(item search.ExternalResultItem) ([]byte, error)

Types

type BoltStorage

type BoltStorage struct {
	Database *bolt.DB
	// contains filtered or unexported fields
}

func NewBoltStorage

func NewBoltStorage(dbPath string, recordTypePtr interface{}) (*BoltStorage, error)

func (*BoltStorage) Close

func (b *BoltStorage) Close()

func (*BoltStorage) Create

func (b *BoltStorage) Create(item search.Record, additionalPK *indexing.Key) error

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

func (b *BoltStorage) GetBucket(tx *bolt.Tx, children ...string) *bolt.Bucket

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

func (*BoltStorage) Update

func (b *BoltStorage) Update(query indexing.Query, item interface{}) error

type IndexDoesNotExistAndNotWritable added in v0.3.0

type IndexDoesNotExistAndNotWritable struct{}

func (*IndexDoesNotExistAndNotWritable) Error added in v0.3.0

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

func NewListIndex(parent *bolt.Bucket, name []byte) (*ListIndex, error)

NewListIndex creates a new list index with it's sub-buckets.

func (*ListIndex) Add

func (ix *ListIndex) Add(val []byte, id []byte) error

Add a new index for an id.

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) Get

func (ix *ListIndex) Get(indexValue []byte) []byte

Get the first ID corresponding to the given value

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) Range

func (ix *ListIndex) Range(min []byte, max []byte, opts *indexing.CursorOptions) [][]byte

Range returns the ids corresponding to the given range of values

func (*ListIndex) Remove

func (ix *ListIndex) Remove(indexValue []byte) error

Remove an index

func (*ListIndex) RemoveById

func (ix *ListIndex) RemoveById(id []byte) error

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"`
}

func (*Metadata) AddIndex added in v0.3.1

func (m *Metadata) AddIndex(name string, location string, isUnique bool) bool

type PrefixCursor

type PrefixCursor struct {
	C       *bolt.Cursor
	Reverse bool
	Prefix  []byte
}

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.

func (*PrefixCursor) Next

func (c *PrefixCursor) Next() ([]byte, []byte)

Next item in the cursor

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

type ReversibleCursor struct {
	C       *bolt.Cursor
	Reverse bool
}

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

type UniqueIndex struct {
	ParentBucket *bolt.Bucket
	IndexBucket  *bolt.Bucket
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL