peripheral

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2018 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package peripheral provides a secondary index layer for badger key-value store - see examples.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrNoIndexNameProvided = fmt.Errorf("no index name provided")
)

error

Functions

func Emit

func Emit(txn *layer.Txn, ix *Index, key, val []byte) (reserr error)

Emit .

Types

type Index

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

Index .

func NewIndex

func NewIndex(name string, indexFn IndexFn) (res *Index)

NewIndex .

Example
Output:

<nil>
<nil>
<nil>

type IndexEntry

type IndexEntry struct {
	Index, Val []byte
}

IndexEntry .

type IndexFn

type IndexFn func(key, val []byte) ([]IndexEntry, error)

IndexFn .

type Q

type Q struct {
	Index              string
	Start, End, Prefix []byte
	Skip, Limit        int
	Count              bool
}

Q query parameters

type Res

type Res struct {
	Key, Val []byte
	Index    []byte
}

Res .

func QueryIndex

func QueryIndex(params Q, txn *layer.Txn, forIndexedKeys ...bool) (reslist []Res, rescount int, reserr error)

QueryIndex .

Example
Output:

2
CMNT::001
CMNT::001
nosql
CMNT::002
CMNT::002
nosql
1
CMNT::002
CMNT::002
golang
2
CMNT::001
CMNT::001
Frodo Baggins
CMNT::002
CMNT::002
Frodo Baggins
Example (With)
Output:

2
CMNT::001
CMNT::001
nosql
CMNT::002
CMNT::002
nosql
1
CMNT::002
CMNT::002
golang
2
CMNT::001
CMNT::001
Frodo Baggins
CMNT::002
CMNT::002
Frodo Baggins

Jump to

Keyboard shortcuts

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