Documentation ¶
Index ¶
- Constants
- Variables
- type Action
- type ClientConfig
- type DB
- func (db *DB) CreateIndex(indexDefinition *api.IndexDefinition) (*Index, error)
- func (db *DB) DeleteIndex(name string) (*Index, error)
- func (db *DB) DeleteSegment(indexName string, segmentKey string) (*Segment, error)
- func (db *DB) GetAllSegments(indexName string, iter func(segment *api.Segment) bool) error
- func (db *DB) GetIndexByName(name string) (*Index, error)
- func (db *DB) GetSegmentByKey(indexName string, segmentKey string) (*Segment, error)
- func (db *DB) InsertSegment(indexName string, segment *api.Segment) (*Segment, error)
- func (db *DB) ListIndexes() []*api.IndexDefinition
- func (db *DB) Lookup(indexName string, lookup *api.Lookup) (*Iterator, error)
- func (db *DB) LookupSegments(indexName string, lookup *api.Lookup) (*Iterator, error)
- func (db *DB) NewSegment(indexName string, segment *api.Segment) (*Segment, error)
- func (db *DB) ReplaceSegment(indexName string, segmentKey string, newSegment *api.Segment) (*Segment, error)
- func (db *DB) TruncateIndex(name string) error
- type DurabilityProfile
- type Index
- func (i *Index) Create() error
- func (i *Index) Definition() *api.IndexDefinition
- func (i *Index) Delete() error
- func (i *Index) DeleteSegment(key string) (*Segment, error)
- func (i *Index) Exists() (bool, error)
- func (i *Index) GetAllSegments(iter func(segment *api.Segment) bool) error
- func (i *Index) GetSegmentByKey(key string) (*Segment, error)
- func (i *Index) InsertSegment(segment *api.Segment) (*Segment, error)
- func (i *Index) Lookup(lookup *api.Lookup) (*Iterator, error)
- func (i *Index) LookupSegments(lookup *api.Lookup) (*Iterator, error)
- func (i *Index) NewSegment(segment *api.Segment) (*Segment, error)
- func (i *Index) Proto() *api.IndexDefinition
- func (i *Index) ReplaceSegment(key string, newSegment *api.Segment) (*Segment, error)
- func (i *Index) Truncate() error
- func (i *Index) UnmarshallPrimaryValue(value string) (*api.SegmentField, error)
- type Iterator
- type Key
- type Lookup
- type Segment
- type Stringer
- type Txn
Constants ¶
const ( RAM DurabilityProfile = 0 FastSync DurabilityProfile = 1 Disk DurabilityProfile = 2 InMemory string = ":memory:" )
Variables ¶
var ( // ErrInternalDBError is used when the internal database returns an error ErrInternalDBError = errors.New("internal database returned an error") ErrIndexExists = errors.New("index already exists") ErrIndexUnknown = errors.New("index is unknown") ErrUnknownDataType = errors.New("data type not supported") ErrFieldUnknown = errors.New("field not part of the index") ErrIndexNotSet = errors.New("index must be set before lookup") ErrLookupFailure = errors.New("could not complete lookup") ErrLookupEmpty = errors.New("no results for lookup") ErrSegmentMissing = errors.New("segment was not available for lookup") ErrSegmentNotFound = errors.New("segment does not exist") ErrMarshallingFailed = errors.New("marshalling failed") ErrPrimaryKeyMissing = errors.New("index is missing a primary key") )
Functions ¶
This section is empty.
Types ¶
type ClientConfig ¶
type ClientConfig struct { Path string Durability DurabilityProfile }
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func NewDBWithConfig ¶
func NewDBWithConfig(ctx context.Context, config *ClientConfig) (*DB, error)
NewDBWithConfig creates a database using a ClientConfig you specify
func (*DB) CreateIndex ¶
func (db *DB) CreateIndex(indexDefinition *api.IndexDefinition) (*Index, error)
CreateIndex takes an IndexDefinition and returns an Index
func (*DB) DeleteIndex ¶
DeleteIndex deletes all segments and the index itself
func (*DB) DeleteSegment ¶
func (*DB) GetAllSegments ¶
func (*DB) GetIndexByName ¶
GetIndexByName returns the index with the specified name
func (*DB) GetSegmentByKey ¶
func (*DB) InsertSegment ¶
func (*DB) ListIndexes ¶
func (db *DB) ListIndexes() []*api.IndexDefinition
ListIndexes returns an unbuffered list of all indexes TODO maybe some limit to this?
func (*DB) LookupSegments ¶
LookupSegments returns full segment objects and is slower than Lookup
func (*DB) NewSegment ¶
func (*DB) ReplaceSegment ¶
func (db *DB) ReplaceSegment(indexName string, segmentKey string, newSegment *api.Segment) (*Segment, error)
ReplaceSegment TODO change this to take the Segment as an arg instead of proto
func (*DB) TruncateIndex ¶
TruncateIndex is a convenience method to call the Truncate method of an Index, which removes all segments
type DurabilityProfile ¶
type DurabilityProfile int
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
func (*Index) Definition ¶
func (i *Index) Definition() *api.IndexDefinition
func (*Index) GetAllSegments ¶
func (*Index) Lookup ¶
Lookup is a convenience method on the index object which only returns segment keys
func (*Index) LookupSegments ¶
LookupSegments returns full segment objects and is slower than Lookup
func (*Index) Proto ¶
func (i *Index) Proto() *api.IndexDefinition
func (*Index) ReplaceSegment ¶
func (*Index) UnmarshallPrimaryValue ¶
func (i *Index) UnmarshallPrimaryValue(value string) (*api.SegmentField, error)
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func (*Key) FieldNameAtIndex ¶
FieldNameAtIndex gets the field name from a key at the given index, root == 0
func (*Key) FieldValueIndex ¶
FieldValueIndex finds the value index of the segments field value
func (*Key) SegmentKey ¶
SegmentKey finds the value of the segments primary key
type Lookup ¶
type Lookup struct {
// contains filtered or unexported fields
}
func (*Lookup) RunOnIndex ¶
type Stringer ¶
type Stringer struct {
// contains filtered or unexported fields
}
func NewFieldDefinitionStringer ¶
func NewFieldDefinitionStringer(fieldDefinition *api.FieldDefinition) *Stringer
func NewLookupStringer ¶
func NewLookupStringer(field *api.LookupField, iter func(key, value string) bool) *Stringer
func NewSegmentStringer ¶
func NewSegmentStringer(field *api.SegmentField, iter func(key, value string) bool) *Stringer
func (*Stringer) MarshallText ¶
func (*Stringer) UnmarshallText ¶
func (s *Stringer) UnmarshallText(value string) (*api.SegmentField, error)