cellar

package module
v0.0.0-...-b5534bb Latest Latest
Warning

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

Go to latest
Published: May 26, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

Cellar

An experimental KV store, which implements an LSM on top of Bolt segments.

Status

EXPERIMENTAL – the API is evolving and the implementation is new

Build Status Coverage Status GoDoc codebeat badge Go Report Card

High Level Concept

  • Data coming into Cellar is batched. Each batch is written out to its own Bolt segment.
  • Reads from Cellar must navigate all the live Bolt segments.
  • Over time, you have too many segments, and must merge segments.

NOTE: if you can arrange to write all keys in a batch in sorted order, we can take advantage of Bolt's strengths. One way to build batches and write them to Cellar in sorted order is to place moss in front of Cellar. In the future we may offer another package to combine these two projects seamlessly.

Features

  • API inspired by Bolt
  • But, only 1 bucket. Support for nested or multiple buckets was removed.
  • Configurable merge policies. Currently only one really dumb implementation.

Performance

Is this actually faster for any use cases?

We don't know yet. This is an ongoing experiment.

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
var DefaultOptions = &Options{
	AutomaticMerge: true,
}

DefaultOptions give the standard cellar behavior

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

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

Functions

This section is empty.

Types

type Cellar

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

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

func Open

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

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

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

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

func (c *Cellar) GoString() string

GoString returns the Go string representation of the cellar.

func (*Cellar) Path

func (c *Cellar) Path() string

Path returns the path to root of the cellar.

func (*Cellar) Stats

func (c *Cellar) Stats() *Stats

Stats returns a structure containing interesting metrics about the cellar

func (*Cellar) String

func (c *Cellar) String() string

String returns the string representation of the cellar.

func (*Cellar) Update

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

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

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

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

func (*Cursor) Next

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

Next moves the cursor to the next key

func (*Cursor) Seek

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

Seek moves the cursor to the specified key

type Merge

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

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

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

type Options

type Options struct {
	AutomaticMerge bool
}

Options let you change configurable behavior within the cellar

type SimpleMergePolicy

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

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

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

type Stats

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

Stats returns interesting values about performance/behavior of the cellar

type Tx

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

Tx represents a cellar transaction

func (*Tx) Commit

func (tx *Tx) Commit() error

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

func (*Tx) Cursor

func (tx *Tx) Cursor() *Cursor

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

func (*Tx) Delete

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

Delete will remove the key from the cellar

func (*Tx) Get

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

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

Put will update the value for the specified key

func (*Tx) Rollback

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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