kvdb

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLevelDBCache               = 1024 // 1 GiB
	DefaultLevelDBHandles             = 512  // files handles to leveldb open files
	DefaultLevelDBBloomKeyBits        = 2048 // bloom filter bits (256 bytes)
	DefaultLevelDBCompactionTableSize = 4    // 4  MiB
	DefaultLevelDBCompactionTotalSize = 40   // 40 MiB
	DefaultLevelDBNoSync              = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KVBatch

type KVBatch interface {
	Set(k, v []byte)
	Write() error
}

type KVBatchStorage

type KVBatchStorage interface {
	KVStorage

	Iterator(*KVIteratorRange) KVIterator

	Batch() KVBatch
}

KVBatchStorage is a batch write for leveldb

type KVIterator added in v1.2.2

type KVIterator interface {
	// First moves the iterator to the first key/value pair. If the iterator
	// only contains one key/value pair then First and Last would moves
	// to the same key/value pair.
	// It returns whether such pair exist.
	First() bool

	// Last moves the iterator to the last key/value pair. If the iterator
	// only contains one key/value pair then First and Last would moves
	// to the same key/value pair.
	// It returns whether such pair exist.
	Last() bool

	// Seek moves the iterator to the first key/value pair whose key is greater
	// than or equal to the given key.
	// It returns whether such pair exist.
	//
	// It is safe to modify the contents of the argument after Seek returns.
	Seek(key []byte) bool

	// Next moves the iterator to the next key/value pair.
	// It returns false if the iterator is exhausted.
	Next() bool

	// Prev moves the iterator to the previous key/value pair.
	// It returns false if the iterator is exhausted.
	Prev() bool

	// Key returns the key of the current key/value pair, or nil if done.
	// The caller should not modify the contents of the returned slice, and
	// its contents may change on the next call to any 'seeks method'.
	Key() []byte

	// Value returns the value of the current key/value pair, or nil if done.
	// The caller should not modify the contents of the returned slice, and
	// its contents may change on the next call to any 'seeks method'.
	Value() []byte

	// Release releases associated resources. Release should always success
	// and can be called multiple times without causing error.
	Release()

	// Error returns any accumulated error. Exhausting all the key/value pairs
	// is not considered to be an error.
	Error() error
}

type KVIteratorRange added in v1.2.2

type KVIteratorRange struct {
	Start []byte
	Limit []byte
}

type KVStorage

type KVStorage interface {
	Set(k, v []byte) error
	Get(k []byte) ([]byte, bool, error)

	Close() error
}

KVStorage is a k/v storage on memory or leveldb

type LevelDBBuilder

type LevelDBBuilder interface {
	// set cache size
	SetCacheSize(int) LevelDBBuilder

	// set handles
	SetHandles(int) LevelDBBuilder

	// set bloom key bits
	SetBloomKeyBits(int) LevelDBBuilder

	// set compaction table size
	SetCompactionTableSize(int) LevelDBBuilder

	// set compaction table total size
	SetCompactionTotalSize(int) LevelDBBuilder

	// set no sync
	SetNoSync(bool) LevelDBBuilder

	// build the storage
	Build() (KVBatchStorage, error)
}

func NewLevelDBBuilder

func NewLevelDBBuilder(logger hclog.Logger, path string) LevelDBBuilder

NewBuilder creates the new leveldb storage builder

Jump to

Keyboard shortcuts

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