opt

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2014 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package opt provides sets of options used by LevelDB.

Index

Constants

View Source
const (
	KiB = 1024
	MiB = KiB * 1024
	GiB = MiB * 1024
)
View Source
const (
	DefaultBlockCacheSize       = 8 * MiB
	DefaultBlockRestartInterval = 16
	DefaultBlockSize            = 4 * KiB
	DefaultCompressionType      = SnappyCompression
	DefaultCachedOpenFiles      = 500
	DefaultWriteBuffer          = 4 * MiB
)
View Source
const (
	// If present then a corrupted or invalid chunk or block in manifest
	// journal will cause an error istead of being dropped.
	StrictManifest Strict = 1 << iota

	// If present then a corrupted or invalid chunk or block in journal
	// will cause an error istead of being dropped.
	StrictJournal

	// If present then journal chunk checksum will be verified.
	StrictJournalChecksum

	// If present then an invalid key/value pair will cause an error
	// instead of being skipped.
	StrictIterator

	// If present then 'sorted table' block checksum will be verified.
	StrictBlockChecksum

	// StrictAll enables all strict flags.
	StrictAll = StrictManifest | StrictJournal | StrictJournalChecksum | StrictIterator | StrictBlockChecksum

	// DefaultStrict is the default strict flags. Specify any strict flags
	// will override default strict flags as whole (i.e. not OR'ed).
	DefaultStrict = StrictJournalChecksum | StrictBlockChecksum

	// NoStrict disables all strict flags. Override default strict flags.
	NoStrict = ^StrictAll
)

Variables

View Source
var NoCache cache.Cache = noCache{}

Functions

This section is empty.

Types

type Compression

type Compression uint

Compression is the per-block compression algorithm to use.

const (
	DefaultCompression Compression = iota
	NoCompression
	SnappyCompression
)

func (Compression) String

func (c Compression) String() string

type Options

type Options struct {
	// AltFilters defines one or more 'alternative filters'.
	// 'alternative filters' will be used during reads if a filter block
	// does not match with the 'effective filter'.
	//
	// The default value is nil
	AltFilters []filter.Filter

	// BlockCache provides per-block caching for LevelDB. Specify NoCache to
	// disable block caching.
	//
	// By default LevelDB will create LRU-cache with capacity of 8MiB.
	BlockCache cache.Cache

	// BlockRestartInterval is the number of keys between restart points for
	// delta encoding of keys.
	//
	// The default value is 16.
	BlockRestartInterval int

	// BlockSize is the minimum uncompressed size in bytes of each 'sorted table'
	// block.
	//
	// The default value is 4KiB.
	BlockSize int

	// CachedOpenFiles defines number of open files to kept around when not
	// in-use, the counting includes still in-use files.
	// Set this to negative value to disable caching.
	//
	// The default value is 500.
	CachedOpenFiles int

	// Comparer defines a total ordering over the space of []byte keys: a 'less
	// than' relationship. The same comparison algorithm must be used for reads
	// and writes over the lifetime of the DB.
	//
	// The default value uses the same ordering as bytes.Compare.
	Comparer comparer.Comparer

	// Compression defines the per-block compression to use.
	//
	// The default value (DefaultCompression) uses snappy compression.
	Compression Compression

	// ErrorIfExist defines whether an error should returned if the DB already
	// exist.
	//
	// The default value is false.
	ErrorIfExist bool

	// ErrorIfMissing defines whether an error should returned if the DB is
	// missing. If false then the database will be created if missing, otherwise
	// an error will be returned.
	//
	// The default value is false.
	ErrorIfMissing bool

	// Filter defines an 'effective filter' to use. An 'effective filter'
	// if defined will be used to generate per-table filter block.
	// The filter name will be stored on disk.
	// During reads LevelDB will try to find matching filter from
	// 'effective filter' and 'alternative filters'.
	//
	// Filter can be changed after a DB has been created. It is recommended
	// to put old filter to the 'alternative filters' to mitigate lack of
	// filter during transition period.
	//
	// A filter is used to reduce disk reads when looking for a specific key.
	//
	// The default value is nil.
	Filter filter.Filter

	// Strict defines the DB strict level.
	Strict Strict

	// WriteBuffer defines maximum size of a 'memdb' before flushed to
	// 'sorted table'. 'memdb' is an in-memory DB backed by an on-disk
	// unsorted journal.
	//
	// LevelDB may held up to two 'memdb' at the same time.
	//
	// The default value is 4MiB.
	WriteBuffer int
}

Options holds the optional parameters for the DB at large.

func (*Options) GetAltFilters

func (o *Options) GetAltFilters() []filter.Filter

func (*Options) GetBlockCache

func (o *Options) GetBlockCache() cache.Cache

func (*Options) GetBlockRestartInterval

func (o *Options) GetBlockRestartInterval() int

func (*Options) GetBlockSize

func (o *Options) GetBlockSize() int

func (*Options) GetCachedOpenFiles added in v0.9.14

func (o *Options) GetCachedOpenFiles() int

func (*Options) GetComparer

func (o *Options) GetComparer() comparer.Comparer

func (*Options) GetCompression

func (o *Options) GetCompression() Compression

func (*Options) GetErrorIfExist

func (o *Options) GetErrorIfExist() bool

func (*Options) GetErrorIfMissing

func (o *Options) GetErrorIfMissing() bool

func (*Options) GetFilter

func (o *Options) GetFilter() filter.Filter

func (*Options) GetStrict

func (o *Options) GetStrict(strict Strict) bool

func (*Options) GetWriteBuffer

func (o *Options) GetWriteBuffer() int

type ReadOptions

type ReadOptions struct {
	// DontFillCache defines whether block reads for this 'read operation'
	// should be cached. If false then the block will be cached. This does
	// not affects already cached block.
	//
	// The default value is false.
	DontFillCache bool

	// Strict overrides global DB strict level. Only StrictIterator and
	// StrictBlockChecksum that does have effects here.
	Strict Strict
}

ReadOptions holds the optional parameters for 'read operation'. The 'read operation' includes Get, Find and NewIterator.

func (*ReadOptions) GetDontFillCache

func (ro *ReadOptions) GetDontFillCache() bool

func (*ReadOptions) GetStrict

func (ro *ReadOptions) GetStrict(strict Strict) bool

type Strict

type Strict uint

Strict is the DB strict level.

type WriteOptions

type WriteOptions struct {
	// Sync is whether to sync underlying writes from the OS buffer cache
	// through to actual disk, if applicable. Setting Sync can result in
	// slower writes.
	//
	// If false, and the machine crashes, then some recent writes may be lost.
	// Note that if it is just the process that crashes (and the machine does
	// not) then no writes will be lost.
	//
	// In other words, Sync being false has the same semantics as a write
	// system call. Sync being true means write followed by fsync.
	//
	// The default value is false.
	Sync bool
}

WriteOptions holds the optional parameters for 'write operation'. The 'write operation' includes Write, Put and Delete.

func (*WriteOptions) GetSync

func (wo *WriteOptions) GetSync() bool

Jump to

Keyboard shortcuts

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