rocksdb

package
v0.0.0-...-6719cd2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package rocksdb provides an implementation of the Database interface that is backed by a local RocksDB Key/Value store

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(args database.FactoryArgs) (database.DB, error)

New will create or open a database configured from the supplied FactoryArgs

func NewWithDir

func NewWithDir(dir string, cfg *config.DiskView) (database.DB, error)

NewWithDir will create or open a database in the supplied directory, taking configuration settings from the supplied config.DiskView

Types

type RocksConfig

type RocksConfig struct {
	// BlockBasedTableOptions
	BlockSizeKB                int
	CacheIndexAndFilterBlocks  bool
	PinL0Cache                 bool
	BloomFilterBitsPerKey      int
	BlockCacheSizeMB           int
	CompressedBlockCacheSizeMB int

	// Options
	IncreaseParallelism          *int // explict 0 will use NumCPU
	AllowConcurrentMemtableWrite bool
	BytesPerSyncKB               uint64
	Compression                  string // "none", "snappy", "zlib", "bz2", "lz4", "lz4hc" [uses "none" if not set]
	AdviseRandomOnOpen           bool
	AllowMmapReads               bool
	UseDirectReads               bool
	UseAdaptiveMutex             bool

	WriteBufferSizeMB        int
	MaxWriteBuffers          int
	MinWriteBuffersToMerge   int
	TargetFileSizeBaseKB     uint64
	TargetFileSizeMultiplier int

	// Stats Logging
	StatsIntervalMinutes float32
	// Metrics collection interval. Can't use time.Duration type as JSON
	// decoding in Go cannot populate a time.Duration and require extra code
	// effort.
	MetricsIntervalMinutes float32

	// Write Options
	DisableWAL bool
}

RocksConfig contains all the settings that are configurable. These are used to configure the underlying RocksDB instance.

func DefaultRocksConfig

func DefaultRocksConfig() *RocksConfig

DefaultRocksConfig returns a new RocksConfig instance configured with the recommened defaults.

func (*RocksConfig) Open

func (r *RocksConfig) Open(dir string) (*gorocksdb.DB, error)

Open will open the database stored at the supplied directory, if one doesn't exist, a new empty database will be created.

type RocksDB

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

RocksDB provides an implementation of the database.DB interface. Its is backed by an embeded rocksDB key/value store.

func (*RocksDB) BulkWrite

func (db *RocksDB) BulkWrite() database.BulkWriter

BulkWrite returns a new BulkWriter which can be used to buffer up a series of Puts & Deletes, which are applied in chunks. You must call Close() to ensure the last chunk is flushed to the database

func (*RocksDB) Close

func (db *RocksDB) Close() error

Close will close the database, freeing up any memory used by the underlying rocks cache

func (*RocksDB) Compact

func (db *RocksDB) Compact()

Compact runs a manual compaction on the entire keyspace. This is not likely to be needed for typical usage. (unless you've done a significant number of writes)

func (*RocksDB) Read

func (db *RocksDB) Read(key []byte) ([]byte, error)

Read returns the value currently stored for the provided key, if the key doesn't exist nil is returned [is this right?]

func (*RocksDB) Snapshot

func (db *RocksDB) Snapshot() database.Snapshot

Snapshot returns a snapshot of the database at the current point in time it can be used to perform consistent iterations of the database. You must call Close() when you're finished with it to release any related resources.

func (*RocksDB) Write

func (db *RocksDB) Write(key []byte, value []byte) error

Write will update the database with the one provided key/value pair

func (*RocksDB) Writes

func (db *RocksDB) Writes(writes []database.KV) error

Writes will write a batch of key/values to the database, they are written in chunks, so this may not be an atomic operation depending on how large writes is

Jump to

Keyboard shortcuts

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