goleveldb: github.com/syndtr/goleveldb/leveldb/opt Index | Files

package opt

import "github.com/syndtr/goleveldb/leveldb/opt"

Package opt provides sets of options used by LevelDB.

Index

Package Files

options.go

Constants

const (
    KiB = 1024
    MiB = KiB * 1024
    GiB = MiB * 1024
)

Variables

var (
    DefaultBlockCacher                   = LRUCacher
    DefaultBlockCacheCapacity            = 8 * MiB
    DefaultBlockRestartInterval          = 16
    DefaultBlockSize                     = 4 * KiB
    DefaultCompactionExpandLimitFactor   = 25
    DefaultCompactionGPOverlapsFactor    = 10
    DefaultCompactionL0Trigger           = 4
    DefaultCompactionSourceLimitFactor   = 1
    DefaultCompactionTableSize           = 2 * MiB
    DefaultCompactionTableSizeMultiplier = 1.0
    DefaultCompactionTotalSize           = 10 * MiB
    DefaultCompactionTotalSizeMultiplier = 10.0
    DefaultCompressionType               = SnappyCompression
    DefaultIteratorSamplingRate          = 1 * MiB
    DefaultOpenFilesCacher               = LRUCacher
    DefaultOpenFilesCacheCapacity        = 500
    DefaultWriteBuffer                   = 4 * MiB
    DefaultWriteL0PauseTrigger           = 12
    DefaultWriteL0SlowdownTrigger        = 8
)
var (
    // LRUCacher is the LRU-cache algorithm.
    LRUCacher = &CacherFunc{cache.NewLRU}

    // NoCacher is the value to disable caching algorithm.
    NoCacher = &CacherFunc{}
)

func GetStrict Uses

func GetStrict(o *Options, ro *ReadOptions, strict Strict) bool

type Cacher Uses

type Cacher interface {
    New(capacity int) cache.Cacher
}

Cacher is a caching algorithm.

type CacherFunc Uses

type CacherFunc struct {
    NewFunc func(capacity int) cache.Cacher
}

func (*CacherFunc) New Uses

func (f *CacherFunc) New(capacity int) cache.Cacher

type Compression Uses

type Compression uint

Compression is the 'sorted table' block compression algorithm to use.

const (
    DefaultCompression Compression = iota
    NoCompression
    SnappyCompression
)

func (Compression) String Uses

func (c Compression) String() string

type Options Uses

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

    // BlockCacher provides cache algorithm for LevelDB 'sorted table' block caching.
    // Specify NoCacher to disable caching algorithm.
    //
    // The default value is LRUCacher.
    BlockCacher Cacher

    // BlockCacheCapacity defines the capacity of the 'sorted table' block caching.
    // Use -1 for zero, this has same effect as specifying NoCacher to BlockCacher.
    //
    // The default value is 8MiB.
    BlockCacheCapacity int

    // BlockCacheEvictRemoved allows enable forced-eviction on cached block belonging
    // to removed 'sorted table'.
    //
    // The default if false.
    BlockCacheEvictRemoved bool

    // 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

    // CompactionExpandLimitFactor limits compaction size after expanded.
    // This will be multiplied by table size limit at compaction target level.
    //
    // The default value is 25.
    CompactionExpandLimitFactor int

    // CompactionGPOverlapsFactor limits overlaps in grandparent (Level + 2) that a
    // single 'sorted table' generates.
    // This will be multiplied by table size limit at grandparent level.
    //
    // The default value is 10.
    CompactionGPOverlapsFactor int

    // CompactionL0Trigger defines number of 'sorted table' at level-0 that will
    // trigger compaction.
    //
    // The default value is 4.
    CompactionL0Trigger int

    // CompactionSourceLimitFactor limits compaction source size. This doesn't apply to
    // level-0.
    // This will be multiplied by table size limit at compaction target level.
    //
    // The default value is 1.
    CompactionSourceLimitFactor int

    // CompactionTableSize limits size of 'sorted table' that compaction generates.
    // The limits for each level will be calculated as:
    //   CompactionTableSize * (CompactionTableSizeMultiplier ^ Level)
    // The multiplier for each level can also fine-tuned using CompactionTableSizeMultiplierPerLevel.
    //
    // The default value is 2MiB.
    CompactionTableSize int

    // CompactionTableSizeMultiplier defines multiplier for CompactionTableSize.
    //
    // The default value is 1.
    CompactionTableSizeMultiplier float64

    // CompactionTableSizeMultiplierPerLevel defines per-level multiplier for
    // CompactionTableSize.
    // Use zero to skip a level.
    //
    // The default value is nil.
    CompactionTableSizeMultiplierPerLevel []float64

    // CompactionTotalSize limits total size of 'sorted table' for each level.
    // The limits for each level will be calculated as:
    //   CompactionTotalSize * (CompactionTotalSizeMultiplier ^ Level)
    // The multiplier for each level can also fine-tuned using
    // CompactionTotalSizeMultiplierPerLevel.
    //
    // The default value is 10MiB.
    CompactionTotalSize int

    // CompactionTotalSizeMultiplier defines multiplier for CompactionTotalSize.
    //
    // The default value is 10.
    CompactionTotalSizeMultiplier float64

    // CompactionTotalSizeMultiplierPerLevel defines per-level multiplier for
    // CompactionTotalSize.
    // Use zero to skip a level.
    //
    // The default value is nil.
    CompactionTotalSizeMultiplierPerLevel []float64

    // 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 'sorted table' block compression to use.
    //
    // The default value (DefaultCompression) uses snappy compression.
    Compression Compression

    // DisableBufferPool allows disable use of util.BufferPool functionality.
    //
    // The default value is false.
    DisableBufferPool bool

    // DisableBlockCache allows disable use of cache.Cache functionality on
    // 'sorted table' block.
    //
    // The default value is false.
    DisableBlockCache bool

    // DisableCompactionBackoff allows disable compaction retry backoff.
    //
    // The default value is false.
    DisableCompactionBackoff bool

    // DisableLargeBatchTransaction allows disabling switch-to-transaction mode
    // on large batch write. If enable batch writes large than WriteBuffer will
    // use transaction.
    //
    // The default is false.
    DisableLargeBatchTransaction bool

    // DisableSeeksCompaction allows disabling 'seeks triggered compaction'.
    // The purpose of 'seeks triggered compaction' is to optimize database so
    // that 'level seeks' can be minimized, however this might generate many
    // small compaction which may not preferable.
    //
    // The default is false.
    DisableSeeksCompaction bool

    // 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

    // IteratorSamplingRate defines approximate gap (in bytes) between read
    // sampling of an iterator. The samples will be used to determine when
    // compaction should be triggered.
    // Use negative value to disable iterator sampling.
    // The iterator sampling is disabled if DisableSeeksCompaction is true.
    //
    // The default is 1MiB.
    IteratorSamplingRate int

    // NoSync allows completely disable fsync.
    //
    // The default is false.
    NoSync bool

    // NoWriteMerge allows disabling write merge.
    //
    // The default is false.
    NoWriteMerge bool

    // OpenFilesCacher provides cache algorithm for open files caching.
    // Specify NoCacher to disable caching algorithm.
    //
    // The default value is LRUCacher.
    OpenFilesCacher Cacher

    // OpenFilesCacheCapacity defines the capacity of the open files caching.
    // Use -1 for zero, this has same effect as specifying NoCacher to OpenFilesCacher.
    //
    // The default value is 500.
    OpenFilesCacheCapacity int

    // If true then opens DB in read-only mode.
    //
    // The default value is false.
    ReadOnly bool

    // 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

    // WriteL0StopTrigger defines number of 'sorted table' at level-0 that will
    // pause write.
    //
    // The default value is 12.
    WriteL0PauseTrigger int

    // WriteL0SlowdownTrigger defines number of 'sorted table' at level-0 that
    // will trigger write slowdown.
    //
    // The default value is 8.
    WriteL0SlowdownTrigger int
}

Options holds the optional parameters for the DB at large.

func (*Options) GetAltFilters Uses

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

func (*Options) GetBlockCacheCapacity Uses

func (o *Options) GetBlockCacheCapacity() int

func (*Options) GetBlockCacheEvictRemoved Uses

func (o *Options) GetBlockCacheEvictRemoved() bool

func (*Options) GetBlockCacher Uses

func (o *Options) GetBlockCacher() Cacher

func (*Options) GetBlockRestartInterval Uses

func (o *Options) GetBlockRestartInterval() int

func (*Options) GetBlockSize Uses

func (o *Options) GetBlockSize() int

func (*Options) GetCompactionExpandLimit Uses

func (o *Options) GetCompactionExpandLimit(level int) int

func (*Options) GetCompactionGPOverlaps Uses

func (o *Options) GetCompactionGPOverlaps(level int) int

func (*Options) GetCompactionL0Trigger Uses

func (o *Options) GetCompactionL0Trigger() int

func (*Options) GetCompactionSourceLimit Uses

func (o *Options) GetCompactionSourceLimit(level int) int

func (*Options) GetCompactionTableSize Uses

func (o *Options) GetCompactionTableSize(level int) int

func (*Options) GetCompactionTotalSize Uses

func (o *Options) GetCompactionTotalSize(level int) int64

func (*Options) GetComparer Uses

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

func (*Options) GetCompression Uses

func (o *Options) GetCompression() Compression

func (*Options) GetDisableBlockCache Uses

func (o *Options) GetDisableBlockCache() bool

func (*Options) GetDisableBufferPool Uses

func (o *Options) GetDisableBufferPool() bool

func (*Options) GetDisableCompactionBackoff Uses

func (o *Options) GetDisableCompactionBackoff() bool

func (*Options) GetDisableLargeBatchTransaction Uses

func (o *Options) GetDisableLargeBatchTransaction() bool

func (*Options) GetDisableSeeksCompaction Uses

func (o *Options) GetDisableSeeksCompaction() bool

func (*Options) GetErrorIfExist Uses

func (o *Options) GetErrorIfExist() bool

func (*Options) GetErrorIfMissing Uses

func (o *Options) GetErrorIfMissing() bool

func (*Options) GetFilter Uses

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

func (*Options) GetIteratorSamplingRate Uses

func (o *Options) GetIteratorSamplingRate() int

func (*Options) GetNoSync Uses

func (o *Options) GetNoSync() bool

func (*Options) GetNoWriteMerge Uses

func (o *Options) GetNoWriteMerge() bool

func (*Options) GetOpenFilesCacheCapacity Uses

func (o *Options) GetOpenFilesCacheCapacity() int

func (*Options) GetOpenFilesCacher Uses

func (o *Options) GetOpenFilesCacher() Cacher

func (*Options) GetReadOnly Uses

func (o *Options) GetReadOnly() bool

func (*Options) GetStrict Uses

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

func (*Options) GetWriteBuffer Uses

func (o *Options) GetWriteBuffer() int

func (*Options) GetWriteL0PauseTrigger Uses

func (o *Options) GetWriteL0PauseTrigger() int

func (*Options) GetWriteL0SlowdownTrigger Uses

func (o *Options) GetWriteL0SlowdownTrigger() int

type ReadOptions Uses

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 will be OR'ed with global DB 'strict level' unless StrictOverride
    // is present. Currently only StrictReader that has effect here.
    Strict Strict
}

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

func (*ReadOptions) GetDontFillCache Uses

func (ro *ReadOptions) GetDontFillCache() bool

func (*ReadOptions) GetStrict Uses

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

type Strict Uses

type Strict uint

Strict is the DB 'strict level'.

const (
    // If present then a corrupted or invalid chunk or block in manifest
    // journal will cause an error instead of being dropped.
    // This will prevent database with corrupted manifest to be opened.
    StrictManifest Strict = 1 << iota

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

    // If present then a corrupted or invalid chunk or block in journal
    // will cause an error instead of being dropped.
    // This will prevent database with corrupted journal to be opened.
    StrictJournal

    // If present then 'sorted table' block checksum will be verified.
    // This has effect on both 'read operation' and compaction.
    StrictBlockChecksum

    // If present then a corrupted 'sorted table' will fails compaction.
    // The database will enter read-only mode.
    StrictCompaction

    // If present then a corrupted 'sorted table' will halts 'read operation'.
    StrictReader

    // If present then leveldb.Recover will drop corrupted 'sorted table'.
    StrictRecovery

    // This only applicable for ReadOptions, if present then this ReadOptions
    // 'strict level' will override global ones.
    StrictOverride

    // StrictAll enables all strict flags.
    StrictAll = StrictManifest | StrictJournalChecksum | StrictJournal | StrictBlockChecksum | StrictCompaction | StrictReader | StrictRecovery

    // 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 | StrictCompaction | StrictReader

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

type WriteOptions Uses

type WriteOptions struct {
    // NoWriteMerge allows disabling write merge.
    //
    // The default is false.
    NoWriteMerge bool

    // 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) GetNoWriteMerge Uses

func (wo *WriteOptions) GetNoWriteMerge() bool

func (*WriteOptions) GetSync Uses

func (wo *WriteOptions) GetSync() bool

Package opt imports 4 packages (graph) and is imported by 1431 packages. Updated 2019-09-19. Refresh now. Tools for package owners.