api

package
v0.0.0-...-5d1c7d3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2014 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	View    IndexType = "view"
	Llrb              = "llrb"
	LevelDB           = "leveldb"
	RocksDB           = "rocksdb"
	HyperDB           = "hyperdb"
	RBTree            = "rbtree"
	CBTree            = "cbtree"
)
View Source
const (
	Unsorted SortOrder = "none"
	Asc                = "asc"
	Desc               = "desc"
)
View Source
const (
	Simple     string = "simple"
	JavaScript        = "javascript"
	N1QL              = "n1ql"
)
View Source
const MAX_VBUCKETS = 1024

Variables

View Source
var (
	DuplicateIndex   = errors.New("Index by the specified name already exists")
	NoSuchIndex      = errors.New("Index by the specified name does not exist")
	NoSuchType       = errors.New("The specified index type is not defined")
	DDocChanged      = errors.New("The design doc has been changed externally")
	DDocCreateFailed = errors.New("Unable to create design doc for index")
	ExprNotSupported = errors.New("Expression type is not supported")
)
View Source
var DebugLog bool
View Source
var KEY_SEPARATOR []byte = []byte{0xff, 0xff, 0xff, 0xff}

Functions

This section is empty.

Types

type Accuracy

type Accuracy float64

Accuracy characterizes if the results of the index is subject to probabilistic errors. When an algorithm that is not Perfect is used, the caller must verify the results.

const (
	Useless Accuracy = 0.0
	Perfect          = 1.0
)

type Complexity

type Complexity int

Complexity characterizes space and time characteristics of the algorithm

const (
	O1 Complexity = iota
	Ologm
	Ologn
	Om
	Omlogm
	Omlogn
	On
	Onlogn
	Om2
	On2
	Ounknown
)

type Counter

type Counter interface {
	Finder
	CountTotal() (uint64, error)
}

Counter is a class of algorithms that return total node count efficiently

type Exister

type Exister interface {
	Finder
	Exists(key Key) bool // TODO: Should we have the `error` part of return ?
}

Exister is a class of algorithms that allow testing if a key exists in the index

type ExprType

type ExprType string

Expression to be applied on the document to get the secondary key.

type Finder

type Finder interface {
	Name() string
	//  Purge()
	Trait(operator interface{}) TraitInfo
	Persister
}

Algorithm is the basic capability of any index algorithm

type Inclusion

type Inclusion int

Inclusion controls how the boundaries values of a range are treated

const (
	Neither Inclusion = iota
	Low
	High
	Both
)

type IndexError

type IndexError struct {
	Code string `json:"code,omitempty"`
	Msg  string `json:"msg,omitempty"`
}

type IndexInfo

type IndexInfo struct {
	Name       string    `json:"name,omitempty"`       // Name of the index
	Uuid       string    `json:"uuid,omitempty"`       // unique id for every index
	Using      IndexType `json:"using,omitempty"`      // indexing algorithm
	OnExprList []string  `json:"onExprList,omitempty"` // expression list
	Bucket     string    `json:"bucket,omitempty"`     // bucket name
	IsPrimary  bool      `json:"isPrimary,omitempty"`
	Exprtype   ExprType  `json:"exprType,omitempty"`
}

Every index ever created and maintained by this package will have an associated index-info structure.

type IndexList

type IndexList []string

list of index UUIDs

type IndexMetaResponse

type IndexMetaResponse struct {
	Status     ResponseStatus `json:"status,omitempty"`
	Indexes    []IndexInfo    `json:"indexes,omitempty"`
	ServerUuid string         `json:"serverUuid,omitempty"`
	Nodes      []NodeInfo     `json:"nodes,omitempty"`
	Errors     []IndexError   `json:"errors,omitempty"`
}

type IndexRequest

type IndexRequest struct {
	Type       RequestType `json:"type,omitempty"`
	Index      IndexInfo   `json:"index,omitempty"`
	ServerUuid string      `json:"serverUuid,omitempty"`
	Params     QueryParams `json:"params,omitempty"`
}

All API accept IndexRequest structure and returns IndexResponse structure. If application is written in Go, and compiled with `indexing` package then they can choose the access the underlying interfaces directly.

type IndexRow

type IndexRow struct {
	Key   [][]byte `json:"key,omitempty"`
	Value string   `json:"value,omitempty"`
}

type IndexScanResponse

type IndexScanResponse struct {
	Status    ResponseStatus `json:"status,omitempty"`
	TotalRows uint64         `json:"totalrows,omitempty"`
	Rows      []IndexRow     `json:"rows,omitempty"`
	Errors    []IndexError   `json:"errors,omitempty"`
}

type IndexSequenceMap

type IndexSequenceMap map[string]SequenceVector // indexed with index-uuid

map of <Index, SequenceVector>

type IndexType

type IndexType string

Known index types

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is an array of JSON objects, per encoding/json

func NewKey

func NewKey(data [][]byte, docid string) (Key, error)

func NewKeyFromEncodedBytes

func NewKeyFromEncodedBytes(b []byte) (Key, error)

func (*Key) Compare

func (k *Key) Compare(than Key) int

func (*Key) EncodedBytes

func (k *Key) EncodedBytes() []byte

func (*Key) String

func (k *Key) String() string

type Keybytes

type Keybytes [][]byte

type Looker

type Looker interface {
	Exister
	Lookup(key Key) (chan Value, chan error)
	KeySet() (chan Key, chan error)
	ValueSet() (chan Value, chan error)
}

Looker is a class of algorithms that allow looking up a key in an index. Usually, being able to look up a key means we can iterate through all keys too, and so that is introduced here as well.

TODO: Define the semantics of buffer size of channels that are returned by the following method receiver.

type Mutation

type Mutation struct {
	Type         UprEventName
	Indexid      string
	SecondaryKey [][]byte
	Docid        string
	Vbucket      uint16
	Seqno        uint64
}

Mutations from projector to indexer.

type NodeInfo

type NodeInfo struct {
	IndexerURL string `json:"indexerURL,omitempty"`
}

Indexer Node Info

type Persister

type Persister interface {

	//Persist a key/value pair
	InsertMutation(key Key, value Value) error

	//Persist meta key/value in back index
	InsertMeta(metaid string, metavalue string) error

	//Return meta value based on metaid from back index
	GetMeta(metaid string) (string, error)

	//Delete a key/value pair by docId
	DeleteMutation(docid string) error

	//Get an existing key/value pair by key
	GetBackIndexEntry(docid string) (Key, error)

	//Close the db. Should be able to reopen after this operation
	Close() error

	//Destroy/Wipe the DB completely
	Destroy() error
}

type QueryParams

type QueryParams struct {
	ScanType  ScanType  `json:"scanType,omitempty"`
	Low       [][]byte  `json:"low,omitempty"`
	High      [][]byte  `json:"high,omitempty"`
	Inclusion Inclusion `json:"inclusion,omitempty"`
	Limit     int64     `json:"limit,omitempty"`
}

URL encoded query params

type RangeCounter

type RangeCounter interface {
	Finder
	CountRange(low Key, high Key, inclusion Inclusion) (uint64, error)
}

RangeCounter is a class of algorithms that can count a range efficiently

type Ranger

type Ranger interface {
	Looker
	KeyRange(low, high Key, inclusion Inclusion) (chan Key, chan error, SortOrder)
	ValueRange(low, high Key, inclusion Inclusion) (chan Value, chan error, SortOrder)
}

Ranger is a class of algorithms that can extract a range of keys from the index.

type RequestType

type RequestType string
const (
	CREATE RequestType = "create"
	DROP   RequestType = "drop"
	LIST   RequestType = "list"
	NOTIFY RequestType = "notify"
	NODES  RequestType = "nodes"
	SCAN   RequestType = "scan"
	STATS  RequestType = "stats"
)

type ResponseStatus

type ResponseStatus string

RESPONSE DATA FORMATS

const (
	SUCCESS       ResponseStatus = "success"
	ERROR         ResponseStatus = "error"
	INVALID_CACHE ResponseStatus = "invalid_cache"
)

type ScanType

type ScanType string
const (
	COUNT      ScanType = "count"
	EXISTS     ScanType = "exists"
	LOOKUP     ScanType = "lookup"
	RANGESCAN  ScanType = "rangeScan"
	FULLSCAN   ScanType = "fullScan"
	RANGECOUNT ScanType = "rangeCount"
)

type SequenceVector

type SequenceVector []uint64

sequence number for each of 1024 vbuckets

type SortOrder

type SortOrder string

SortOrder characterizes if the algorithm emits keys in a predictable order

type TraitInfo

type TraitInfo struct {
	Unique     Uniqueness
	Order      SortOrder
	Accuracy   Accuracy
	AvgTime    Complexity
	AvgSpace   Complexity
	WorstTime  Complexity
	WorstSpace Complexity
}

TraitInfo is collection of traits of an algorithm. One can query the traits of an entire indexing algorithm, or traits of a specific operation. May change soon.

type Uniqueness

type Uniqueness bool

Uniqueness, characterizes if the algorithm demands unique keys

const (
	Unique    Uniqueness = true
	NonUnique            = false
)

type UprEventName

type UprEventName string
const (
	INSERT UprEventName = "UPR_MUTATION"
	DELETE              = "UPR_DELETION"
)

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value is the primary key of the relavent document

func NewValue

func NewValue(data [][]byte, docid string, vbucket uint16, seqno uint64) (Value, error)

func NewValueFromEncodedBytes

func NewValueFromEncodedBytes(b []byte) (Value, error)

func (*Value) Docid

func (v *Value) Docid() string

func (*Value) EncodedBytes

func (v *Value) EncodedBytes() []byte

func (*Value) KeyBytes

func (v *Value) KeyBytes() Keybytes

func (*Value) String

func (v *Value) String() string

Jump to

Keyboard shortcuts

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