indexing

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIndexNameFromQuery

func GetIndexNameFromQuery(query Query) string

GetIndexNameFromQuery gets the name of an index from a query.

func GetIndexValueFromItem

func GetIndexValueFromItem(keyParts *Key, item interface{}) []byte

GetIndexValueFromItem gets the index value from a key set and an item.

func GetIndexValueFromQuery

func GetIndexValueFromQuery(query Query) []byte

GetIndexValueFromQuery get the value of an index by a query.

func KeyHasValue

func KeyHasValue(key *Key, item interface{}) bool

KeyHasValue checks if all the key fields in an item have a value.

Types

type Cursor

type Cursor interface {
	First() ([]byte, []byte)
	Next() ([]byte, []byte)
	CanContinue(val []byte) bool
}

type CursorOptions

type CursorOptions struct {
	Limit   int
	Skip    int
	Reverse bool
}

func NewCursorOptions

func NewCursorOptions() *CursorOptions

func SingleItemCursor

func SingleItemCursor() *CursorOptions

type Index

type Index interface {
	Add(value []byte, targetID []byte) error
	Remove(value []byte) error
	RemoveById(id []byte) error
	Get(value []byte) []byte
	All(value []byte, opts *CursorOptions) [][]byte
	AllRecords(opts *CursorOptions) [][]byte
	Range(min []byte, max []byte, opts *CursorOptions) [][]byte
}

type IndexMetadata added in v0.3.3

type IndexMetadata struct {
	Name     string `json:"name"`
	Unique   bool   `json:"unique"`
	Location string
}

IndexMetadata is used to describe an index

type Key

type Key struct {
	Fields []string
	// contains filtered or unexported fields
}

Key is a primary key or an indexing key, this can be a composite key as well []string

func NewKey

func NewKey(fieldNames ...string) *Key

NewKey creates a new keyParts using an array of fields.

func (*Key) Add

func (k *Key) Add(s string)

Add a new key field

func (*Key) AddKeys

func (k *Key) AddKeys(newKeys *Key)

AddKeys adds multiple keys

func (*Key) IsEmpty

func (k *Key) IsEmpty() bool

type Query

type Query interface {
	Put(k, v interface{})
	Size() int
	Keys() []interface{}
	Values() []interface{}
	Get(key interface{}) (value interface{}, found bool)
}

func GetKeyQueryFromItem

func GetKeyQueryFromItem(keyParts *Key, item interface{}) Query

GetKeyQueryFromItem gets the query that matches an item with the given keyParts.

func NewQuery

func NewQuery() Query

Jump to

Keyboard shortcuts

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