store

package
v0.0.0-...-4cb7ada Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IteratorForward  uint8 = 0
	IteratorBackward uint8 = 1
)
View Source
const (
	RangeOpen   uint8 = 0x00
	RangeClose  uint8 = 0x11
	RangeSClose uint8 = 0x01 // Start Open
	RangeEClose uint8 = 0x10 // End Open
)

Variables

View Source
var (
	ErrZeroBandwidth = errors.New("Bandwidth cannot be zero")
	ErrEmptyKey      = errors.New("Key cannot be empty")

	// ErrKeyNotFound is returned when key isn't found on a txn.Get.
	ErrKeyNotFound = errors.New("Key not found")

	// ErrConflict is returned when a transaction conflicts with another transaction. This can happen if
	// the read rows had been updated concurrently by another transaction.
	ErrConflict = errors.New("Transaction Conflict. Please retry")

	// ErrReadOnlyTxn is returned if an update function is called on a read-only transaction.
	ErrReadOnlyTxn = errors.New("No sets or deletes are allowed in a read-only transaction")

	// ErrDiscardedTxn is returned if a previously discarded transaction is re-used.
	ErrDiscardedTxn = errors.New("This transaction has been discarded. Create a new one")
)

Functions

func NewBackendError

func NewBackendError(err error) error

func RunTestItemCopy

func RunTestItemCopy(t *testing.T, idb IDB)

func RunTestIterator

func RunTestIterator(t *testing.T, idb IDB)

func RunTestReverseIterator

func RunTestReverseIterator(t *testing.T, idb IDB)

func RunTestShardFind

func RunTestShardFind(t *testing.T, idb IDB)

func RunTestUpdateView

func RunTestUpdateView(t *testing.T, idb IDB)

Types

type BackendError

type BackendError struct {
	Original error
}

func (BackendError) Error

func (e BackendError) Error() string

type DB

type DB struct {
	IDB
}

func NewDB

func NewDB(idb IDB) *DB

func (*DB) Update

func (db *DB) Update(domain []byte, f func(*Txn) error) error

func (*DB) View

func (db *DB) View(domain []byte, f func(*Txn) error) error

type IDB

type IDB interface {
	Close() error
	View(func(ITxn) error) error
	Update(func(ITxn) error) error
	Compact() error
}

type IItem

type IItem interface {
	Key() []byte
	Value() ([]byte, error)
	ValueCopy([]byte) ([]byte, error)
}

IItem is a Lazy Value

type IIterator

type IIterator interface {
	Close()

	Seek(key []byte)
	Next()
	Valid() bool

	Item() IItem
}

type ITxn

type ITxn interface {
	Get(key []byte) (IItem, error)
	NewIterator(prefetch int, direction uint8) IIterator
	Set(key []byte, value []byte) error
	Delete(key []byte) error
}

type Item

type Item struct {
	IItem
}

func (*Item) KeyCopy

func (it *Item) KeyCopy(b []byte) []byte

Copy key to b, if b len is small or nil, returns a new one.

type Iterator

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

Iterator is a high level abstraction of a prefix iterator that can go forward or backwards. It requires a prefix, start or end key, limit, and offset.

func (*Iterator) Close

func (it *Iterator) Close()

func (*Iterator) Item

func (it *Iterator) Item() *Item

Item reuses a shared item struct. You need to copy values before moving on to the next item.

func (*Iterator) Next

func (it *Iterator) Next()

func (*Iterator) Seek

func (it *Iterator) Seek(key []byte)

func (*Iterator) Start

func (it *Iterator) Start()

func (*Iterator) TrimPrefix

func (it *Iterator) TrimPrefix(s []byte) []byte

func (*Iterator) Valid

func (it *Iterator) Valid() bool

type IteratorOptions

type IteratorOptions struct {
	StartKey  []byte
	EndKey    []byte
	RangeType uint8
	Offset    int
	Count     int
	Prefetch  int
	Prefix    []byte
}

min must less or equal than max

range type:

close: [min, max]
open: (min, max)
sclose: [min, max)
eclose: (min, max]

type Txn

type Txn struct {
	ITxn
	// contains filtered or unexported fields
}

func (*Txn) CanWrite

func (rTxn *Txn) CanWrite() bool

func (*Txn) Delete

func (rTxn *Txn) Delete(key []byte) error

func (*Txn) Get

func (rTxn *Txn) Get(key []byte) (*Item, error)

func (*Txn) NewIterator

func (rTxn *Txn) NewIterator(opts *IteratorOptions) *Iterator

count < 0, unlimit. offset must >= 0, if < 0, will get nothing.

func (*Txn) NextShardSeq

func (rTxn *Txn) NextShardSeq() []byte

func (*Txn) Set

func (rTxn *Txn) Set(key []byte, val []byte) error

func (*Txn) TrimDomain

func (rTxn *Txn) TrimDomain(s []byte) []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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