cellar: github.com/couchbaselabs/cellar Index | Files

package cellar

import "github.com/couchbaselabs/cellar"


Package Files

cellar.go cursor.go cursor_merge.go errors.go merge.go merge_manager.go merge_policy.go reader.go segment.go segment_builder.go segment_list.go stats.go tx.go


var (
    // ErrTxClosed is returned whe operating on a closed cellar/bolt
    ErrTxClosed = errors.New("tx closed")
    // ErrTxNotWritable is returned when attempting a write operation on a
    // read only transaction
    ErrTxNotWritable = errors.New("tx not writable")
    // ErrTxIsManaged is returned when commit/rollback has been performed
    // on a managed transaction (Update/View)
    ErrTxIsManaged = errors.New("managed tx rollback/commit not allowed")
var DefaultOptions = &Options{
    AutomaticMerge: true,

DefaultOptions give the standard cellar behavior

var Logger = log.New(ioutil.Discard, "cellar ", log.LstdFlags)

Logger is a configurable logger used by this package by default output is discarded

type Cellar Uses

type Cellar struct {
    // contains filtered or unexported fields

Cellar is a merged-multi-segment(bolt) k/v store

func Open Uses

func Open(path string, options *Options) (*Cellar, error)

Open is used to create/open a cellar path should be a directory to hold the cellar contents if options is nil, DefaultOptions will be used

func (*Cellar) Begin Uses

func (c *Cellar) Begin(writable bool) (*Tx, error)

Begin starts a new transaction writable controls whether or not this transaction supports Put/Delete

func (*Cellar) Close Uses

func (c *Cellar) Close() error

Close will release all resources associated with the cellar close may block while waiting for readers/mergers to complete or reach a resumable point

func (*Cellar) ForceMerge Uses

func (c *Cellar) ForceMerge()

ForceMerge will force the cellar to perform a merge operations this function does not wait for the merge to finish

func (*Cellar) GoString Uses

func (c *Cellar) GoString() string

GoString returns the Go string representation of the cellar.

func (*Cellar) Path Uses

func (c *Cellar) Path() string

Path returns the path to root of the cellar.

func (*Cellar) Stats Uses

func (c *Cellar) Stats() *Stats

Stats returns a structure containing interesting metrics about the cellar

func (*Cellar) String Uses

func (c *Cellar) String() string

String returns the string representation of the cellar.

func (*Cellar) Update Uses

func (c *Cellar) Update(fn func(*Tx) error) error

Update starts a managed transaction for wriring the provided function is executed within the transaction to abort the transaction the function should return an error to commit the transaction the function should return nil

func (*Cellar) View Uses

func (c *Cellar) View(fn func(*Tx) error) error

View starts a managed transaction for reading the provided function is executed within the transaction

type Cursor Uses

type Cursor struct {
    // contains filtered or unexported fields

Cursor is a tool for iterating through k/v pairs in the cellar

func (*Cursor) Next Uses

func (c *Cursor) Next() (key []byte, value []byte)

Next moves the cursor to the next key

func (*Cursor) Seek Uses

func (c *Cursor) Seek(seek []byte) (key []byte, value []byte)

Seek moves the cursor to the specified key

type Merge Uses

type Merge struct {
    // contains filtered or unexported fields

Merge represents an ordered set of adjacent segments to be merged dropDeletes specifies whether or not the deletes should be dropped deletes can only be dropped if the result of the merge is the final segment

type MergePolicy Uses

type MergePolicy interface {
    Merges(*Cellar, segmentList) []*Merge

MergePolicy is anything which can prescribe a set of Merges to be done

type Options Uses

type Options struct {
    AutomaticMerge bool

Options let you change configurable behavior within the cellar

type SimpleMergePolicy Uses

type SimpleMergePolicy struct{}

SimpleMergePolicy has no brain at all, it simply always chooses to merge two consecutive segments that are not already being merged

func (*SimpleMergePolicy) Merges Uses

func (s *SimpleMergePolicy) Merges(cellar *Cellar, segments segmentList) []*Merge

Merges returns the set of prescribed merge operations for this set of segments

type Stats Uses

type Stats struct {
    // contains filtered or unexported fields

Stats returns interesting values about performance/behavior of the cellar

type Tx Uses

type Tx struct {
    // contains filtered or unexported fields

Tx represents a cellar transaction

func (*Tx) Commit Uses

func (tx *Tx) Commit() error

Commit will atomically make all the operations in the transactions a part of this cellar

func (*Tx) Cursor Uses

func (tx *Tx) Cursor() *Cursor

Cursor returns an object which can be used to iterate k/v paris in the cellar

func (*Tx) Delete Uses

func (tx *Tx) Delete(key []byte) error

Delete will remove the key from the cellar

func (*Tx) Get Uses

func (tx *Tx) Get(key []byte) []byte

Get will look up the specified key if theere is no value, nil is returned NOTE: an empty byte slice is a valid value, and not the same as nil

func (*Tx) Put Uses

func (tx *Tx) Put(key []byte, value []byte) error

Put will update the value for the specified key

func (*Tx) Rollback Uses

func (tx *Tx) Rollback() error

Rollback will abort this transaction, none of the operations performed up to this point will be reflected in the cellar

Package cellar imports 13 packages (graph) and is imported by 1 packages. Updated 2016-07-25. Refresh now. Tools for package owners.