sublevel

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2015 License: MIT Imports: 5 Imported by: 0

README

sublevel

Separate sections of the same LevelDB. Compatible (at least in the basics -- I didn't test it minuciously) with the nodejs sublevel.

Travis-CI build status API documentation on Godoc.org

import "github.com/fiatjaf/sublevel"

sub := sublevel.MustOpen("example.db").Sub("specific-stuff")

sub.Put([]byte("this"), []byte("2007-04-01"), nil)
dateOfThis := sub.Get([]byte("this"), nil)
sub.Delete([]byte("this"))
Batch operations
db, err := sublevel.Open("example.db")
if err != nil {
    panic(err)
}

// batch on a single sublevel:
sub := db.Sub("some-things")
batch := sub.NewBatch()
batch.Put([]byte("newthing"), []byte("true"))
batch.Delete([]byte("oldthing"))
_ := sub.Write(batch)
// committed.
// ~
// batch on different sublevels:
othersub := db.Sub("other-things")
otherbatch := othersub.NewBatch()
otherbatch.Put([]byte("new-other-thing"), []byte("true"))
otherbatch.Delete([]byte("old-other-thing"))

batchagain := sub.NewBatch()
batchagain.Delete([]byte("newthing"))
batchagain.Put([]byte("newestthing"), []byte("true"))

superbatch := db.MultiBatch(otherbatch, batchagain)
_ := db.Write(superbatch, nil)
// committed.
// ~
// or
b := db.NewBatch()
b.Put("some-things", []byte("newthing"), []byte("true"))
b.Delete("other-things", []byte("old-other-thing"))
b.Put("other-things", []byte("new-other-thing"), []byte("true"))
b.Delete("some-things", []byte("newthing"))
b.Put("some-things", []byte("newestthing"), []byte("true"))
db.Write(b, nil)

sublevel is built on top of goleveldb and supports most methods from there (not all, but in most cases everything you'll need).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractBatchOperation

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

transactions

type AbstractLevel

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

func MustOpen

func MustOpen(dbfile string, o *opt.Options) *AbstractLevel

func Open

func Open(dbfile string, o *opt.Options) (*AbstractLevel, error)

opens an abstract DB for the given file.

the abstract DB is said to be "abstract" because it cannot
do any operation, it is there only to generate sublevels.

It is not possible to access the underlying leveldb with this
package.

func (AbstractLevel) Close

func (a AbstractLevel) Close() error

func (AbstractLevel) MultiBatch

func (a AbstractLevel) MultiBatch(subbatches ...*SubBatch) *SuperBatch

func (AbstractLevel) NewBatch

func (a AbstractLevel) NewBatch() *SuperBatch

transactions on different stores

func (AbstractLevel) Sub

func (a AbstractLevel) Sub(store string) *Sublevel

func (AbstractLevel) Write

func (a AbstractLevel) Write(sb *SuperBatch, wo *opt.WriteOptions) error

type SubBatch

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

func (*SubBatch) Delete

func (b *SubBatch) Delete(key []byte)

func (*SubBatch) Dump

func (b *SubBatch) Dump() []byte

func (*SubBatch) Len

func (b *SubBatch) Len() int

func (*SubBatch) Put

func (b *SubBatch) Put(key []byte, value []byte)

func (*SubBatch) Reset

func (b *SubBatch) Reset()

type SubIterator

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

func (SubIterator) Error

func (si SubIterator) Error() error

func (SubIterator) First

func (si SubIterator) First() bool

func (SubIterator) Key

func (si SubIterator) Key() []byte

func (SubIterator) Last

func (si SubIterator) Last() bool

func (SubIterator) Next

func (si SubIterator) Next() bool

func (SubIterator) Prev

func (si SubIterator) Prev() bool

func (SubIterator) Release

func (si SubIterator) Release()

func (SubIterator) Seek

func (si SubIterator) Seek(key []byte) bool

func (SubIterator) Value

func (si SubIterator) Value() []byte

type Sublevel

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

func (Sublevel) Close

func (s Sublevel) Close() error

func (Sublevel) Delete

func (s Sublevel) Delete(key []byte, wo *opt.WriteOptions) error

func (Sublevel) Get

func (s Sublevel) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)

func (Sublevel) Has

func (s Sublevel) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error)

func (Sublevel) NewBatch

func (s Sublevel) NewBatch() *SubBatch

starts a new batch write for the specified sublevel.

func (Sublevel) NewIterator

func (s Sublevel) NewIterator(slice *util.Range, ro *opt.ReadOptions) SubIterator

iterator

func (Sublevel) Put

func (s Sublevel) Put(key []byte, value []byte, wo *opt.WriteOptions) error

func (Sublevel) Write

func (s Sublevel) Write(b *SubBatch, wo *opt.WriteOptions) error

type SuperBatch

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

func (*SuperBatch) Delete

func (sb *SuperBatch) Delete(store string, key []byte)

func (*SuperBatch) Dump

func (sb *SuperBatch) Dump() []byte

func (*SuperBatch) Len

func (sb *SuperBatch) Len() int

func (*SuperBatch) MergeSubBatch

func (sb *SuperBatch) MergeSubBatch(b *SubBatch)

func (*SuperBatch) Put

func (sb *SuperBatch) Put(store string, key []byte, value []byte)

func (*SuperBatch) Reset

func (sb *SuperBatch) Reset()

Directories

Path Synopsis
Godeps
_workspace/src/github.com/golang/snappy
Package snappy implements the snappy block-based compression format.
Package snappy implements the snappy block-based compression format.
_workspace/src/github.com/onsi/ginkgo
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
_workspace/src/github.com/onsi/ginkgo/config
Ginkgo accepts a number of configuration options.
Ginkgo accepts a number of configuration options.
_workspace/src/github.com/onsi/ginkgo/ginkgo
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) You can also learn more by running: ginkgo help Here are some of the more commonly used commands: To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To pass arguments/flags to your tests: ginkgo <flags> <packages> -- <pass-throughs> To run tests in parallel ginkgo -p this will automatically detect the optimal number of nodes to use.
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) You can also learn more by running: ginkgo help Here are some of the more commonly used commands: To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To pass arguments/flags to your tests: ginkgo <flags> <packages> -- <pass-throughs> To run tests in parallel ginkgo -p this will automatically detect the optimal number of nodes to use.
_workspace/src/github.com/onsi/ginkgo/internal/remote
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete.
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete.
_workspace/src/github.com/onsi/ginkgo/reporters
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
_workspace/src/github.com/onsi/gomega
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
_workspace/src/github.com/onsi/gomega/format
Gomega's format package pretty-prints objects.
Gomega's format package pretty-prints objects.
_workspace/src/github.com/onsi/gomega/gbytes
Package gbytes provides a buffer that supports incrementally detecting input.
Package gbytes provides a buffer that supports incrementally detecting input.
_workspace/src/github.com/onsi/gomega/gexec
Package gexec provides support for testing external processes.
Package gexec provides support for testing external processes.
_workspace/src/github.com/onsi/gomega/ghttp
Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports registering multiple handlers.
Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports registering multiple handlers.
_workspace/src/github.com/onsi/gomega/ghttp/protobuf
Package protobuf is a generated protocol buffer package.
Package protobuf is a generated protocol buffer package.
_workspace/src/github.com/onsi/gomega/matchers
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
_workspace/src/github.com/syndtr/goleveldb/leveldb
Package leveldb provides implementation of LevelDB key/value database.
Package leveldb provides implementation of LevelDB key/value database.
_workspace/src/github.com/syndtr/goleveldb/leveldb/cache
Package cache provides interface and implementation of a cache algorithms.
Package cache provides interface and implementation of a cache algorithms.
_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer
Package comparer provides interface and implementation for ordering sets of data.
Package comparer provides interface and implementation for ordering sets of data.
_workspace/src/github.com/syndtr/goleveldb/leveldb/errors
Package errors provides common error types used throughout leveldb.
Package errors provides common error types used throughout leveldb.
_workspace/src/github.com/syndtr/goleveldb/leveldb/filter
Package filter provides interface and implementation of probabilistic data structure.
Package filter provides interface and implementation of probabilistic data structure.
_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator
Package iterator provides interface and implementation to traverse over contents of a database.
Package iterator provides interface and implementation to traverse over contents of a database.
_workspace/src/github.com/syndtr/goleveldb/leveldb/journal
Package journal reads and writes sequences of journals.
Package journal reads and writes sequences of journals.
_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb
Package memdb provides in-memory key/value database implementation.
Package memdb provides in-memory key/value database implementation.
_workspace/src/github.com/syndtr/goleveldb/leveldb/opt
Package opt provides sets of options used by LevelDB.
Package opt provides sets of options used by LevelDB.
_workspace/src/github.com/syndtr/goleveldb/leveldb/storage
Package storage provides storage abstraction for LevelDB.
Package storage provides storage abstraction for LevelDB.
_workspace/src/github.com/syndtr/goleveldb/leveldb/table
Package table allows read and write sorted key/value.
Package table allows read and write sorted key/value.
_workspace/src/github.com/syndtr/goleveldb/leveldb/util
Package util provides utilities used throughout leveldb.
Package util provides utilities used throughout leveldb.

Jump to

Keyboard shortcuts

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