Documentation
¶
Index ¶
- Constants
- func ListColumnFamilies(path string, opts *Options) ([]string, error)
- func OpenDBColumnFamilies(path string, opts *Options, cfNames []string, cfOpts []*Options) (*DB, ColumnFamilyHandles, error)
- func OpenDBForReadOnlyColumnFamilies(path string, opts *Options, cfNames []string, cfOpts []*Options, ...) (*DB, ColumnFamilyHandles, error)
- type BackupEngine
- func (b *BackupEngine) Close()
- func (b *BackupEngine) CreateNewBackup(db *DB) error
- func (b *BackupEngine) CreateNewBackupWithMetadata(db *DB, metadata string) error
- func (b *BackupEngine) DeleteBackup(backupID uint32) error
- func (b *BackupEngine) GetInfo() *BackupEngineInfo
- func (b *BackupEngine) RestoreDBFromBackup(backupID uint32, dbDir, walDir string, ro *RestoreOptions) error
- func (b *BackupEngine) RestoreDBFromLatestBackup(dbDir, walDir string, ro *RestoreOptions) error
- func (b *BackupEngine) UnsafeGetBackupEngine() unsafe.Pointer
- func (b *BackupEngine) VerifyBackup(index uint32) error
- type BackupEngineInfo
- func (b *BackupEngineInfo) Destroy()
- func (b *BackupEngineInfo) GetAppMetadata(index int) string
- func (b *BackupEngineInfo) GetBackupID(index int) int64
- func (b *BackupEngineInfo) GetCount() int
- func (b *BackupEngineInfo) GetNumFiles(index int) int32
- func (b *BackupEngineInfo) GetSize(index int) int64
- func (b *BackupEngineInfo) GetTimestamp(index int) int64
- type BlockBasedTableOptions
- func (o *BlockBasedTableOptions) Destroy()
- func (o *BlockBasedTableOptions) SetBlockCache(cache *Cache)
- func (o *BlockBasedTableOptions) SetBlockCacheCompressed(cache *Cache)
- func (o *BlockBasedTableOptions) SetBlockSize(blockSize int)
- func (o *BlockBasedTableOptions) SetBlockSizeDeviation(blockSizeDeviation int)
- func (o *BlockBasedTableOptions) SetCacheIndexAndFilterBlocks(value bool)
- func (o *BlockBasedTableOptions) SetCacheIndexAndFilterBlocksWithHighPriority(value bool)
- func (o *BlockBasedTableOptions) SetFilterPolicy(fp *FilterPolicy)
- func (o *BlockBasedTableOptions) SetHashIndexAllowCollision(value bool)
- func (o *BlockBasedTableOptions) SetIndexType(value IndexType)
- func (o *BlockBasedTableOptions) SetMetadataBlockSize(blockSize uint64)
- func (o *BlockBasedTableOptions) SetNoBlockCache(value bool)
- func (o *BlockBasedTableOptions) SetPartitionFilters(value bool)
- func (o *BlockBasedTableOptions) SetPinL0FilterAndIndexBlocksInCache(value bool)
- func (o *BlockBasedTableOptions) SetPinTopLevelIndexAndFilterInCache(value bool)
- func (o *BlockBasedTableOptions) SetWholeKeyFiltering(value bool)
- type COWList
- type Cache
- type Checkpoint
- type ColumnFamilyHandle
- type ColumnFamilyHandles
- type CompressionType
- type DB
- func (db *DB) Close() error
- func (db *DB) Delete(wo *WriteOptions, key []byte) error
- func (db *DB) DeleteCF(wo *WriteOptions, cf *ColumnFamilyHandle, key []byte) error
- func (db *DB) Flush(fo *FlushOptions) error
- func (db *DB) Get(ro *ReadOptions, key []byte) (*Slice, error)
- func (db *DB) GetBytes(ro *ReadOptions, key []byte) ([]byte, error)
- func (db *DB) GetBytesCF(ro *ReadOptions, cf *ColumnFamilyHandle, key []byte) ([]byte, error)
- func (db *DB) GetCF(ro *ReadOptions, cf *ColumnFamilyHandle, key []byte) (*Slice, error)
- func (db *DB) GetLatestSequenceNumber() uint64
- func (db *DB) GetProperty(propName string) string
- func (db *DB) GetPropertyCF(propName string, cf *ColumnFamilyHandle) string
- func (db *DB) GetUint64Property(propName string) uint64
- func (db *DB) GetUint64PropertyCF(propName string, cf *ColumnFamilyHandle) uint64
- func (db *DB) GetUpdatesSince(seqNum uint64) (*WALIterator, error)
- func (db *DB) NewCheckpoint() (*Checkpoint, error)
- func (db *DB) NewIterator(ro *ReadOptions) *Iterator
- func (db *DB) NewIteratorCF(ro *ReadOptions, cf *ColumnFamilyHandle) *Iterator
- func (db *DB) Put(wo *WriteOptions, key, value []byte) error
- func (db *DB) PutCF(wo *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) error
- func (db *DB) Write(wo *WriteOptions, batch *WriteBatch) error
- type Env
- type FilterPolicy
- type FlushOptions
- type HistogramData
- func (d *HistogramData) Destroy()
- func (d *HistogramData) GetAverage() float64
- func (d *HistogramData) GetCount() uint64
- func (d *HistogramData) GetMax() float64
- func (d *HistogramData) GetMedian() float64
- func (d *HistogramData) GetPercentile95() float64
- func (d *HistogramData) GetPercentile99() float64
- func (d *HistogramData) GetStandardDeviation() float64
- func (d *HistogramData) GetSum() uint64
- type HistogramType
- type IndexType
- type Iterator
- func (iter *Iterator) Close()
- func (iter *Iterator) Err() error
- func (iter *Iterator) Key() *Slice
- func (iter *Iterator) Next()
- func (iter *Iterator) Prev()
- func (iter *Iterator) Seek(key []byte)
- func (iter *Iterator) SeekForPrev(key []byte)
- func (iter *Iterator) SeekToFirst()
- func (iter *Iterator) SeekToLast()
- func (iter *Iterator) Valid() bool
- func (iter *Iterator) ValidForPrefix(prefix []byte) bool
- func (iter *Iterator) Value() *Slice
- type LogDataExtractor
- type Options
- func (o *Options) Destroy()
- func (o *Options) IncreaseParallelism(totalThreads int)
- func (o *Options) OptimizeForPointLookup(blockCacheSizeMb uint64)
- func (o *Options) SetAllowConcurrentMemtableWrites(allow bool)
- func (o *Options) SetAllowMmapReads(value bool)
- func (o *Options) SetAllowMmapWrites(value bool)
- func (o *Options) SetAtomicFlush(value bool)
- func (o *Options) SetBlockBasedTableFactory(value *BlockBasedTableOptions)
- func (o *Options) SetCompression(value CompressionType)
- func (o *Options) SetCreateIfMissing(value bool)
- func (o *Options) SetCreateIfMissingColumnFamilies(value bool)
- func (o *Options) SetDBLogDir(value string)
- func (o *Options) SetDbWriteBufferSize(value int)
- func (o *Options) SetEnablePipelinedWrite(value bool)
- func (o *Options) SetEnv(value *Env)
- func (o *Options) SetHashLinkListRep(bucketCount int)
- func (o *Options) SetHashSkipListRep(bucketCount int, skiplistHeight, skiplistBranchingFactor int32)
- func (o *Options) SetKeepLogFileNum(value int)
- func (o *Options) SetLevel0FileNumCompactionTrigger(value int)
- func (o *Options) SetLevel0SlowdownWritesTrigger(value int)
- func (o *Options) SetLevel0StopWritesTrigger(value int)
- func (o *Options) SetLogFileTimeToRoll(value int)
- func (o *Options) SetMaxBackgroundCompactions(value int)
- func (o *Options) SetMaxBackgroundFlushes(value int)
- func (o *Options) SetMaxBytesForLevelBase(value uint64)
- func (o *Options) SetMaxBytesForLevelMultiplier(value float64)
- func (o *Options) SetMaxFileOpeningThreads(value int)
- func (o *Options) SetMaxLogFileSize(value int)
- func (o *Options) SetMaxOpenFiles(value int)
- func (o *Options) SetMaxSubCompactions(value int)
- func (o *Options) SetMaxTotalWalSize(value uint64)
- func (o *Options) SetMaxWriteBufferNumber(value int)
- func (o *Options) SetMemtableVectorRep()
- func (o *Options) SetMinWriteBufferNumberToMerge(value int)
- func (o *Options) SetNumLevels(value int)
- func (o *Options) SetPlainTableFactory(keyLen uint32, bloomBitsPerKey int, hashTableRatio float64, ...)
- func (o *Options) SetPrefixExtractor(st SliceTransform)
- func (o *Options) SetStatistics(s *Statistics)
- func (o *Options) SetTargetFileSizeBase(value uint64)
- func (o *Options) SetTargetFileSizeMultiplier(value int)
- func (o *Options) SetUseDirectIOForFlushAndCompaction(value bool)
- func (o *Options) SetUseDirectReads(value bool)
- func (o *Options) SetUseFsync(value bool)
- func (o *Options) SetWALTtlSeconds(value uint64)
- func (o *Options) SetWalDir(value string)
- func (o *Options) SetWalSizeLimitMb(value uint64)
- func (o *Options) SetWriteBufferSize(value int)
- type ReadOptions
- type Registry
- type RestoreOptions
- type Slice
- type SliceTransform
- type Statistics
- func (s *Statistics) Destroy()
- func (s *Statistics) GetAndResetTickerCount(tickerType TickerType) uint64
- func (s *Statistics) GetHistogramData(histogramType HistogramType) *HistogramData
- func (s *Statistics) GetTickerCount(tickerType TickerType) uint64
- func (s *Statistics) Reset()
- func (s *Statistics) SetStatsLevel(statsLevel StatsLevel)
- func (s *Statistics) StatsLevel() StatsLevel
- type StatsLevel
- type TickerType
- type WALIterator
- type WriteBatch
- func (wb *WriteBatch) Clear()
- func (wb *WriteBatch) Count() int
- func (wb *WriteBatch) Data() []byte
- func (wb *WriteBatch) Delete(key []byte)
- func (wb *WriteBatch) DeleteCF(cf *ColumnFamilyHandle, key []byte)
- func (wb *WriteBatch) DeleteRange(beginKey, endKey []byte)
- func (wb *WriteBatch) DeleteRangeCF(cf *ColumnFamilyHandle, beginKey, endKey []byte)
- func (wb *WriteBatch) Destroy()
- func (wb *WriteBatch) GetLogData(extractor *LogDataExtractor) []byte
- func (wb *WriteBatch) Merge(key, value []byte)
- func (wb *WriteBatch) MergeCF(cf *ColumnFamilyHandle, key, value []byte)
- func (wb *WriteBatch) Put(key, value []byte)
- func (wb *WriteBatch) PutCF(cf *ColumnFamilyHandle, key, value []byte)
- func (wb *WriteBatch) PutLogData(blob []byte, size int)
- type WriteBatchHandler
- type WriteOptions
Constants ¶
const ( NoCompression = CompressionType(C.rocksdb_no_compression) SnappyCompression = CompressionType(C.rocksdb_snappy_compression) )
Compression types
const ( // LevelExceptHistogramOrTimers disables timer stats, and skip histogram stats. LevelExceptHistogramOrTimers = StatsLevel(C.EXCEPT_HISTOGRAM_OR_TIMERS) // LevelExceptTimers skips timer stats. LevelExceptTimers = StatsLevel(C.EXCEPT_TIMERS) // LevelExceptDetailedTimers collects all stats except time inside mutex lock // AND time spent on compression. LevelExceptDetailedTimers = StatsLevel(C.EXCEPT_DETAILED_TIMERS) // LevelExceptTimeForMutex collect all stats except the counters requiring to get time // inside the mutex lock. LevelExceptTimeForMutex = StatsLevel(C.EXCEPT_TIME_FOR_MUTEX) // LevelAll collects all stats, including measuring duration of mutex operations. // If getting time is expensive on the platform to run, it can // reduce scalability to more threads, especially for writes. LevelAll = StatsLevel(C.ALL) )
const ( // TickerBlockCacheMiss is the total number of block bache misses. TickerBlockCacheMiss = TickerType(C.BLOCK_CACHE_MISS) // TickerBlockCacheHit is the total number of block bache hits. TickerBlockCacheHit = TickerType(C.BLOCK_CACHE_HIT) // TickerBlockCacheAdd is the number of blocks added to block cache. TickerBlockCacheAdd = TickerType(C.BLOCK_CACHE_ADD) // TickerBlockCacheAddFailures is the number of failures when adding blocks to block cache. TickerBlockCacheAddFailures = TickerType(C.BLOCK_CACHE_ADD_FAILURES) // TickerBlockCacheIndexMiss is the number of cache misses when accessing index block from block cache. TickerBlockCacheIndexMiss = TickerType(C.BLOCK_CACHE_INDEX_MISS) // TickerBlockCacheIndexHit is the number cache hits when accessing index block from block cache. TickerBlockCacheIndexHit = TickerType(C.BLOCK_CACHE_INDEX_HIT) // TickerBlockCacheIndexAdd is the number of index blocks added to block cache. TickerBlockCacheIndexAdd = TickerType(C.BLOCK_CACHE_INDEX_ADD) // TickerBlockCacheIndexBytesInsert is the number of bytes of index blocks inserted into cache. TickerBlockCacheIndexBytesInsert = TickerType(C.BLOCK_CACHE_INDEX_BYTES_INSERT) // TickerBlockCacheIndexBytesEvict is the number of bytes of index block erased from cache. TickerBlockCacheIndexBytesEvict = TickerType(C.BLOCK_CACHE_INDEX_BYTES_EVICT) // TickerBlockCacheFilterMiss is the number of times cache misses when accessing filter block from block cache. TickerBlockCacheFilterMiss = TickerType(C.BLOCK_CACHE_FILTER_MISS) // TickerBlockCacheFilterHit is the number of times cache hits when accessing filter block from block cache. TickerBlockCacheFilterHit = TickerType(C.BLOCK_CACHE_FILTER_HIT) // TickerBlockCacheFilterAdd is the number of filter blocks added to block cache. TickerBlockCacheFilterAdd = TickerType(C.BLOCK_CACHE_FILTER_ADD) // TickerBlockCacheFilterBytesInsert is the number of bytes of bloom filter blocks inserted into cache. TickerBlockCacheFilterBytesInsert = TickerType(C.BLOCK_CACHE_FILTER_BYTES_INSERT) // TickerBlockCacheFilterBytesEvict is the number of bytes of bloom filter block erased from cache. TickerBlockCacheFilterBytesEvict = TickerType(C.BLOCK_CACHE_FILTER_BYTES_EVICT) // TickerBlockCacheDataMiss is the number of times cache misses when accessing data block from block cache. TickerBlockCacheDataMiss = TickerType(C.BLOCK_CACHE_DATA_MISS) // TickerBlockCacheDataHit is the number of times cache hits when accessing data block from block cache. TickerBlockCacheDataHit = TickerType(C.BLOCK_CACHE_DATA_HIT) // TickerBlockCacheDataAdd is the number of data blocks added to block cache. TickerBlockCacheDataAdd = TickerType(C.BLOCK_CACHE_DATA_ADD) // TickerBlockCacheDataBytesInsert is the number of bytes of data blocks inserted into cache. TickerBlockCacheDataBytesInsert = TickerType(C.BLOCK_CACHE_DATA_BYTES_INSERT) // TickerBlockCacheBytesRead is the number of bytes read from cache. TickerBlockCacheBytesRead = TickerType(C.BLOCK_CACHE_BYTES_READ) // TickerBlockCacheBytesWrite is the number of bytes written into cache. TickerBlockCacheBytesWrite = TickerType(C.BLOCK_CACHE_BYTES_WRITE) // TickerBloomFilterUseful is the number of times bloom filter has avoided file reads, i.e., negatives. TickerBloomFilterUseful = TickerType(C.BLOOM_FILTER_USEFUL) // TickerBloomFilterFullPositive is the number of times bloom FullFilter has not avoided the reads. TickerBloomFilterFullPositive = TickerType(C.BLOOM_FILTER_FULL_POSITIVE) // TickerBloomFilterFullTruePositive is the number of times bloom FullFilter has not avoided the reads and // data actually exist. TickerBloomFilterFullTruePositive = TickerType(C.BLOOM_FILTER_FULL_TRUE_POSITIVE) // TickerMemtableHit is the number of memtable hits. TickerMemtableHit = TickerType(C.MEMTABLE_HIT) // TickerMemtableMiss is the number of memtable misses. TickerMemtableMiss = TickerType(C.MEMTABLE_MISS) // TickerGetHitL0 is the number of Get() queries served by L0. TickerGetHitL0 = TickerType(C.GET_HIT_L0) // TickerGetHitL1 is the number of Get() queries served by L1. TickerGetHitL1 = TickerType(C.GET_HIT_L1) // TickerGetHitL2AndUp is the number of Get() queries served by L2 and up. TickerGetHitL2AndUp = TickerType(C.GET_HIT_L2_AND_UP) // TickerNumberKeysWritten is the number of keys written to the database via the Put and Write call's. TickerNumberKeysWritten = TickerType(C.NUMBER_KEYS_WRITTEN) // TickerNumberKeysRead is the number of Keys read. TickerNumberKeysRead = TickerType(C.NUMBER_KEYS_READ) // TickerNumberKeysUpdated is the number keys updated, if inplace update is enabled. TickerNumberKeysUpdated = TickerType(C.NUMBER_KEYS_UPDATED) // TickerBytesWritten is the number of uncompressed bytes issued by db.Put(), // db.Delete(), db.Merge(), and db.Write(). TickerBytesWritten = TickerType(C.BYTES_WRITTEN) // TickerBytesRead is the number of uncompressed bytes read from db.Get(). // It could be either from memtables, cache, or table files. // For the number of logical bytes read from db.MultiGet(), // please use NumberMultiGetBytesRead. TickerBytesRead = TickerType(C.BYTES_READ) // TickerStallMicros is the number of microseconds the writer has to wait for // compaction or flush to finish. TickerStallMicros = TickerType(C.STALL_MICROS) // TickerBlockCacheCompressedMiss is the number of misses in the compressed block cache. TickerBlockCacheCompressedMiss = TickerType(C.BLOCK_CACHE_COMPRESSED_MISS) // TickerBlockCacheCompressedHit is the number of hits in the compressed block cache. TickerBlockCacheCompressedHit = TickerType(C.BLOCK_CACHE_COMPRESSED_HIT) // TickerBlockCacheCompressedAdd is the number of blocks added to compressed block cache. TickerBlockCacheCompressedAdd = TickerType(C.BLOCK_CACHE_COMPRESSED_ADD) // TickerBlockCacheCompressedAddFailures is the number of failures when adding blocks to compressed block cache. TickerBlockCacheCompressedAddFailures = TickerType(C.BLOCK_CACHE_COMPRESSED_ADD_FAILURES) // TickerWALFileSynced is the number of times WAL sync is done. TickerWALFileSynced = TickerType(C.WAL_FILE_SYNCED) // TickerWALFileBytes is the number of bytes written to WAL. TickerWALFileBytes = TickerType(C.WAL_FILE_BYTES) // TickerCompactReadBytes is the number of bytes read during compaction. TickerCompactReadBytes = TickerType(C.COMPACT_READ_BYTES) // TickerCompactWriteBytes is the number of bytes written during compaction. TickerCompactWriteBytes = TickerType(C.COMPACT_WRITE_BYTES) // TickerFlushWriteBytes is the number of bytes written during flush. TickerFlushWriteBytes = TickerType(C.FLUSH_WRITE_BYTES) // TickerNumberBlockCompressed is the number of compressions executed. TickerNumberBlockCompressed = TickerType(C.NUMBER_BLOCK_COMPRESSED) // TickerNumberBlockDecompressed is the number of decompressions executed. TickerNumberBlockDecompressed = TickerType(C.NUMBER_BLOCK_DECOMPRESSED) // TickerNumberBlockNotCompressed is the number of blocks not compressed. TickerNumberBlockNotCompressed = TickerType(C.NUMBER_BLOCK_NOT_COMPRESSED) // TickerMergeOperationTotalTime is the number in # of all merge operations. TickerMergeOperationTotalTime = TickerType(C.MERGE_OPERATION_TOTAL_TIME) // TickerFilterOperationTotalTime is the number in # of all filter operations. TickerFilterOperationTotalTime = TickerType(C.FILTER_OPERATION_TOTAL_TIME) // TickerReadAmpEstimateUsefulBytes is the estimate of total bytes actually used. TickerReadAmpEstimateUsefulBytes = TickerType(C.READ_AMP_ESTIMATE_USEFUL_BYTES) // TickerReadAmpTotalReadBytes is the total size of loaded data blocks. TickerReadAmpTotalReadBytes = TickerType(C.READ_AMP_TOTAL_READ_BYTES) )
const ( // HistogramBytesPerRead is value size distribution in read operations. HistogramBytesPerRead = HistogramType(C.BYTES_PER_READ) )
Variables ¶
This section is empty.
Functions ¶
func ListColumnFamilies ¶
ListColumnFamilies lists the names of the column families in the DB.
func OpenDBColumnFamilies ¶
func OpenDBColumnFamilies( path string, opts *Options, cfNames []string, cfOpts []*Options, ) (*DB, ColumnFamilyHandles, error)
OpenDBColumnFamilies opens a database with the specified column families.
func OpenDBForReadOnlyColumnFamilies ¶
func OpenDBForReadOnlyColumnFamilies( path string, opts *Options, cfNames []string, cfOpts []*Options, errorIfLogFileExist bool, ) (*DB, ColumnFamilyHandles, error)
OpenDBForReadOnlyColumnFamilies opens a database with the specified column families in read-only mode.
Types ¶
type BackupEngine ¶
type BackupEngine struct {
// contains filtered or unexported fields
}
BackupEngine is a reusable handle to a RocksDB Backup, created by OpenBackupEngine.
func OpenBackupEngine ¶
func OpenBackupEngine(opts *Options, path string) (*BackupEngine, error)
OpenBackupEngine opens a backup engine with specified options.
func (*BackupEngine) Close ¶
func (b *BackupEngine) Close()
Close close the backup engine and cleans up state The backups already taken remain on storage.
func (*BackupEngine) CreateNewBackup ¶
func (b *BackupEngine) CreateNewBackup(db *DB) error
CreateNewBackup takes a new backup from db.
func (*BackupEngine) CreateNewBackupWithMetadata ¶
func (b *BackupEngine) CreateNewBackupWithMetadata(db *DB, metadata string) error
CreateNewBackupWithMetadata is same as CreateNewBackup, but stores extra application metadata. Flush will always trigger if 2PC is enabled. If write-ahead logs are disabled, set flush_before_backup=true to avoid losing unflushed key/value pairs from the memtable.
func (*BackupEngine) DeleteBackup ¶
func (b *BackupEngine) DeleteBackup(backupID uint32) error
DeleteBackup deletes a single backup from a backup engine.
func (*BackupEngine) GetInfo ¶
func (b *BackupEngine) GetInfo() *BackupEngineInfo
GetInfo gets an object that gives information about the backups that have already been taken
func (*BackupEngine) RestoreDBFromBackup ¶
func (b *BackupEngine) RestoreDBFromBackup(backupID uint32, dbDir, walDir string, ro *RestoreOptions) error
RestoreDBFromBackup restores a singular backup to dbDir. walDir is where the write ahead logs are restored to and usually the same as dbDir.
func (*BackupEngine) RestoreDBFromLatestBackup ¶
func (b *BackupEngine) RestoreDBFromLatestBackup(dbDir, walDir string, ro *RestoreOptions) error
RestoreDBFromLatestBackup restores the latest backup to dbDir. walDir is where the write ahead logs are restored to and usually the same as dbDir.
func (*BackupEngine) UnsafeGetBackupEngine ¶
func (b *BackupEngine) UnsafeGetBackupEngine() unsafe.Pointer
UnsafeGetBackupEngine returns the underlying c backup engine.
func (*BackupEngine) VerifyBackup ¶
func (b *BackupEngine) VerifyBackup(index uint32) error
VerifyBackup checks that each file exists and that the size of the file matches our expectations. It does not check file checksum. Returns Status::OK() if all checks are good
type BackupEngineInfo ¶
type BackupEngineInfo struct {
// contains filtered or unexported fields
}
BackupEngineInfo represents the information about the backups in a backup engine instance. Use this to get the state of the backup like number of backups and their ids and timestamps etc.
func (*BackupEngineInfo) Destroy ¶
func (b *BackupEngineInfo) Destroy()
Destroy destroys the backup engine info instance.
func (*BackupEngineInfo) GetAppMetadata ¶
func (b *BackupEngineInfo) GetAppMetadata(index int) string
GetAppMetadata gets the backup associated metadata.
func (*BackupEngineInfo) GetBackupID ¶
func (b *BackupEngineInfo) GetBackupID(index int) int64
GetBackupID gets an id that uniquely identifies a backup regardless of its position.
func (*BackupEngineInfo) GetCount ¶
func (b *BackupEngineInfo) GetCount() int
GetCount gets the number backsup available.
func (*BackupEngineInfo) GetNumFiles ¶
func (b *BackupEngineInfo) GetNumFiles(index int) int32
GetNumFiles gets the number of files in the backup index.
func (*BackupEngineInfo) GetSize ¶
func (b *BackupEngineInfo) GetSize(index int) int64
GetSize get the size of the backup in bytes.
func (*BackupEngineInfo) GetTimestamp ¶
func (b *BackupEngineInfo) GetTimestamp(index int) int64
GetTimestamp gets the timestamp at which the backup index was taken.
type BlockBasedTableOptions ¶
type BlockBasedTableOptions struct {
// contains filtered or unexported fields
}
BlockBasedTableOptions represents block-based table options.
func NewDefaultBlockBasedTableOptions ¶
func NewDefaultBlockBasedTableOptions() *BlockBasedTableOptions
NewDefaultBlockBasedTableOptions creates a default BlockBasedTableOptions object.
func (*BlockBasedTableOptions) Destroy ¶
func (o *BlockBasedTableOptions) Destroy()
Destroy deallocates the BlockBasedTableOptions object.
func (*BlockBasedTableOptions) SetBlockCache ¶
func (o *BlockBasedTableOptions) SetBlockCache(cache *Cache)
SetBlockCache sets the control over blocks (user data is stored in a set of blocks, and a block is the unit of reading from disk).
If set, use the specified cache for blocks. If nil, rocksdb will automatically create and use an 8MB internal cache. Default: nil
func (*BlockBasedTableOptions) SetBlockCacheCompressed ¶
func (o *BlockBasedTableOptions) SetBlockCacheCompressed(cache *Cache)
SetBlockCacheCompressed sets the cache for compressed blocks. If nil, rocksdb will not use a compressed block cache. Default: nil
func (*BlockBasedTableOptions) SetBlockSize ¶
func (o *BlockBasedTableOptions) SetBlockSize(blockSize int)
SetBlockSize sets the approximate size of user data packed per block. Note that the block size specified here corresponds to uncompressed data. The actual size of the unit read from disk may be smaller if compression is enabled. This parameter can be changed dynamically. Default: 4K
func (*BlockBasedTableOptions) SetBlockSizeDeviation ¶
func (o *BlockBasedTableOptions) SetBlockSizeDeviation(blockSizeDeviation int)
SetBlockSizeDeviation sets the block size deviation. This is used to close a block before it reaches the configured 'block_size'. If the percentage of free space in the current block is less than this specified number and adding a new record to the block will exceed the configured block size, then this block will be closed and the new record will be written to the next block. Default: 10
func (*BlockBasedTableOptions) SetCacheIndexAndFilterBlocks ¶
func (o *BlockBasedTableOptions) SetCacheIndexAndFilterBlocks(value bool)
SetCacheIndexAndFilterBlocks is indicating if we'd put index/filter blocks to the block cache. If not specified, each "table reader" object will pre-load index/filter block during table initialization. Default: false
func (*BlockBasedTableOptions) SetCacheIndexAndFilterBlocksWithHighPriority ¶
func (o *BlockBasedTableOptions) SetCacheIndexAndFilterBlocksWithHighPriority(value bool)
SetCacheIndexAndFilterBlocksWithHighPriority priority to high for index and filter blocks in block cache. It only affect LRUCache so far, and need to use together with high_pri_pool_ratio when calling NewLRUCache(). If the feature is enabled, LRU-list in LRU cache will be split into two parts, one for high-pri blocks and one for low-pri blocks. Data blocks will be inserted to the head of low-pri pool. Index and filter blocks will be inserted to the head of high-pri pool. If the total usage in the high-pri pool exceed capacity * high_pri_pool_ratio, the block at the tail of high-pri pool will overflow to the head of low-pri pool, after which it will compete against data blocks to stay in cache. Eviction will start from the tail of low-pri pool.
func (*BlockBasedTableOptions) SetFilterPolicy ¶
func (o *BlockBasedTableOptions) SetFilterPolicy(fp *FilterPolicy)
SetFilterPolicy sets the filter policy to reduce disk reads. Many applications will benefit from passing the result of NewBloomFilterPolicy() here. Default: nil
func (*BlockBasedTableOptions) SetHashIndexAllowCollision ¶
func (o *BlockBasedTableOptions) SetHashIndexAllowCollision(value bool)
SetHashIndexAllowCollision when enabled, prefix hash index for block-based table will not store prefix and allow hash collision, reducing memory consumption. Default false
func (*BlockBasedTableOptions) SetIndexType ¶
func (o *BlockBasedTableOptions) SetIndexType(value IndexType)
SetIndexType sets the index type used for this table. kBinarySearch: A space efficient index block that is optimized for binary-search-based index.
kHashSearch: The hash index, if enabled, will do the hash lookup when `Options.prefix_extractor` is provided.
kTwoLevelIndexSearch: A two-level index implementation. Both levels are binary search indexes. Default: kBinarySearch
func (*BlockBasedTableOptions) SetMetadataBlockSize ¶
func (o *BlockBasedTableOptions) SetMetadataBlockSize(blockSize uint64)
SetMetadataBlockSize sets the approximate size of the blocks for index partitions. Default: 4K
func (*BlockBasedTableOptions) SetNoBlockCache ¶
func (o *BlockBasedTableOptions) SetNoBlockCache(value bool)
SetNoBlockCache specify whether block cache should be used or not. Default: false
func (*BlockBasedTableOptions) SetPartitionFilters ¶
func (o *BlockBasedTableOptions) SetPartitionFilters(value bool)
SetPartitionFilters enables partition index filters. With partitioning, the index/filter of a SST file is partitioned into smaller blocks with an additional top-level index on them. When reading an index/filter, only top-level index is loaded into memory. The partitioned index/filter then uses the top-level index to load on demand into the block cache the partitions that are required to perform the index/filter query. The top-level index, which has much smaller memory footprint, can be stored in heap or block cache depending on the SetCacheIndexAndFilterBlocks setting. Default: false
func (*BlockBasedTableOptions) SetPinL0FilterAndIndexBlocksInCache ¶
func (o *BlockBasedTableOptions) SetPinL0FilterAndIndexBlocksInCache(value bool)
SetPinL0FilterAndIndexBlocksInCache sets cache_index_and_filter_blocks. If is true and the below is true (hash_index_allow_collision), then filter and index blocks are stored in the cache, but a reference is held in the "table reader" object so the blocks are pinned and only evicted from cache when the table reader is freed. Default: false
func (*BlockBasedTableOptions) SetPinTopLevelIndexAndFilterInCache ¶
func (o *BlockBasedTableOptions) SetPinTopLevelIndexAndFilterInCache(value bool)
SetPinTopLevelIndexAndFilterInCache pins top-level indexes. Default: false
func (*BlockBasedTableOptions) SetWholeKeyFiltering ¶
func (o *BlockBasedTableOptions) SetWholeKeyFiltering(value bool)
SetWholeKeyFiltering specify if whole keys in the filter (not just prefixes) should be placed. This must generally be true for gets opts be efficient. Default: true
type COWList ¶
type COWList struct {
// contains filtered or unexported fields
}
COWList implements a copy-on-write list. It is intended to be used by go callback registry for CGO, which is read-heavy with occasional writes. Reads do not block; Writes do not block reads (or vice versa), but only one write can occur at once;
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a cache used to store data read from data in memory.
func NewDefaultLRUCache ¶
NewDefaultLRUCache create a new LRU cache with a fixed size capacity. num_shard_bits = -1 means it is automatically determined: every shard will be at least 512KB and number of shard bits will not exceed 6. strict_capacity_limit = false high_pri_pool_ration = 0.0
func NewLRUCache ¶
NewLRUCache creates a new LRU cache with a fixed size capacity and high priority pool ration. The cache is sharded to 2^num_shard_bits shards, by hash of the key. The total capacity is divided and evenly assigned to each shard. If strict_capacity_limit is set, insert to the cache will fail when cache is full. User can also set percentage of the cache reserves for high priority entries via high_pri_pool_pct. num_shard_bits = -1 means it is automatically determined: every shard will be at least 512KB and number of shard bits will not exceed 6.
func (*Cache) GetPinnedUsage ¶
GetPinnedUsage returns the Cache pinned memory usage.
type Checkpoint ¶
type Checkpoint struct {
// contains filtered or unexported fields
}
Checkpoint provides Checkpoint functionality. A checkpoint is an openable snapshot of a database at a point in time.
func NewNativeCheckpoint ¶
func NewNativeCheckpoint(c *C.rocksdb_checkpoint_t) *Checkpoint
NewNativeCheckpoint creates a new checkpoint.
func (*Checkpoint) CreateCheckpoint ¶
func (cp *Checkpoint) CreateCheckpoint(checkpointDir string, logSizeForFlush uint64) error
CreateCheckpoint builds an openable snapshot of RocksDB on the same disk, which accepts an output directory on the same disk, and under the directory (1) hard-linked SST files pointing to existing live SST files SST files will be copied if output directory is on a different filesystem (2) a copied manifest files and other files The directory should not already exist and will be created by this API. The directory will be an absolute path logSizeForFlush: if the total log file size is equal or larger than this value, then a flush is triggered for all the column families. The default value is 0, which means flush is always triggered. If you move away from the default, the checkpoint may not contain up-to-date data if WAL writing is not always enabled. Flush will always trigger if it is 2PC.
func (*Checkpoint) Destroy ¶
func (cp *Checkpoint) Destroy()
Destroy deallocates the Checkpoint object.
type ColumnFamilyHandle ¶
type ColumnFamilyHandle struct {
// contains filtered or unexported fields
}
ColumnFamilyHandle represents a handle to a ColumnFamily.
func NewColumnFamilyHandle ¶
func NewColumnFamilyHandle(c *C.rocksdb_column_family_handle_t) *ColumnFamilyHandle
NewColumnFamilyHandle creates a ColumnFamilyHandle object.
func (*ColumnFamilyHandle) Destroy ¶
func (h *ColumnFamilyHandle) Destroy()
Destroy calls the destructor of the underlying column family handle.
func (*ColumnFamilyHandle) UnsafeGetCFHandler ¶
func (h *ColumnFamilyHandle) UnsafeGetCFHandler() unsafe.Pointer
UnsafeGetCFHandler returns the underlying c column family handle.
type ColumnFamilyHandles ¶
type ColumnFamilyHandles []*ColumnFamilyHandle
type CompressionType ¶
type CompressionType uint
CompressionType specifies the block compression. DB contents are stored in a set of blocks, each of which holds a sequence of key,value pairs. Each block may be compressed before being stored in a file. The following enum describes which compression method (if any) is used to compress a block.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a reusable handler to a RocksDB database on disk, created by OpenDB.
func OpenDBForReadOnly ¶
OpenDBForReadOnly opens a database with the specified options for read-only usage.
func (*DB) Delete ¶
func (db *DB) Delete(wo *WriteOptions, key []byte) error
Delete removes the data associated with the key from the database.
func (*DB) DeleteCF ¶
func (db *DB) DeleteCF(wo *WriteOptions, cf *ColumnFamilyHandle, key []byte) error
DeleteCF removes the data associated with the key from the database and column family.
func (*DB) Flush ¶
func (db *DB) Flush(fo *FlushOptions) error
Flush triggers a manual flush for the database.
func (*DB) Get ¶
func (db *DB) Get(ro *ReadOptions, key []byte) (*Slice, error)
Get returns the data associated with the key from the database.
func (*DB) GetBytes ¶
func (db *DB) GetBytes(ro *ReadOptions, key []byte) ([]byte, error)
GetBytes is like Get but returns a copy of the data instead of a Slice.
func (*DB) GetBytesCF ¶
func (db *DB) GetBytesCF(ro *ReadOptions, cf *ColumnFamilyHandle, key []byte) ([]byte, error)
GetBytesCF is like GetCF but returns a copy of the data instead of a Slice.
func (*DB) GetCF ¶
func (db *DB) GetCF(ro *ReadOptions, cf *ColumnFamilyHandle, key []byte) (*Slice, error)
GetCF returns the data associated with the key from the database and column family.
func (*DB) GetLatestSequenceNumber ¶
GetLatestSequenceNumber returns the sequence number of the most recent transaction.
func (*DB) GetProperty ¶
GetProperty returns the value of a database property.
func (*DB) GetPropertyCF ¶
func (db *DB) GetPropertyCF(propName string, cf *ColumnFamilyHandle) string
GetPropertyCF returns the value of a database property.
func (*DB) GetUint64Property ¶
GetUint64Property returns the value of a database property.
func (*DB) GetUint64PropertyCF ¶
func (db *DB) GetUint64PropertyCF(propName string, cf *ColumnFamilyHandle) uint64
GetUint64PropertyCF returns the value of a database property.
func (*DB) GetUpdatesSince ¶
func (db *DB) GetUpdatesSince(seqNum uint64) (*WALIterator, error)
GetUpdatesSince sets iter to an iterator that is positioned at a write-batch containing seq_number. If the sequence number is non existent, it returns an iterator at the first available seq_no after the requested seq_no. Returns an error if iterator is not valid. Must set WAL_ttl_seconds or WAL_size_limit_MB to large values to use this api, else the WAL files will get cleared aggressively and the iterator might keep getting invalid before an update is read.
func (*DB) NewCheckpoint ¶
func (db *DB) NewCheckpoint() (*Checkpoint, error)
NewCheckpoint creates a new Checkpoint for this db.
func (*DB) NewIterator ¶
func (db *DB) NewIterator(ro *ReadOptions) *Iterator
NewIterator returns an Iterator over the the database that uses the ReadOptions given.
func (*DB) NewIteratorCF ¶
func (db *DB) NewIteratorCF(ro *ReadOptions, cf *ColumnFamilyHandle) *Iterator
NewIteratorCF returns an Iterator over the the database and column family that uses the ReadOptions given.
func (*DB) Put ¶
func (db *DB) Put(wo *WriteOptions, key, value []byte) error
Put writes data associated with a key to the database.
func (*DB) PutCF ¶
func (db *DB) PutCF(wo *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) error
PutCF writes data associated with a key to the database and a column family.
func (*DB) Write ¶
func (db *DB) Write(wo *WriteOptions, batch *WriteBatch) error
Write writes a WriteBatch to the database
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is an environment used to route through all file operations and some system calls.
func (*Env) SetBackgroundThreads ¶
SetBackgroundThreads sets the number of background worker threads of a specific thread pool for this environment. 'LOW' is the default pool. Default: 1
func (*Env) SetHighPriorityBackgroundThreads ¶
SetHighPriorityBackgroundThreads sets the size of the high priority thread pool that can be used to prevent compactions from stalling memtable flushes.
type FilterPolicy ¶
type FilterPolicy struct {
// contains filtered or unexported fields
}
func NewBloomFilterPolicy ¶
func NewBloomFilterPolicy(bitsPerKey int) *FilterPolicy
NewBloomFilterPolicy returns a new filter policy that uses a block-based bloom filter with approximately the specified number of bits per key. A good value for bits_per_key is 10, which yields a filter with ~1% false positive rate.
Note: if you are using a custom comparator that ignores some parts of the keys being compared, you must not use NewBloomFilterPolicy() and must provide your own FilterPolicy that also ignores the corresponding parts of the keys. For example, if the comparator ignores trailing spaces, it would be incorrect to use a FilterPolicy (like NewBloomFilterPolicy) that does not ignore trailing spaces in keys.
func NewFullBloomFilterPolicy ¶
func NewFullBloomFilterPolicy(bitsPerKey int) *FilterPolicy
NewFullBloomFilterPolicy returns a new filter policy that uses a full bloom filter for the entire SST file, with approximately the specified number of bits per key. A good value for bits_per_key is 10, which yields a filter with ~1% false positive rate.
Note: if you are using a custom comparator that ignores some parts of the keys being compared, you must not use NewBloomFilterPolicy() and must provide your own FilterPolicy that also ignores the corresponding parts of the keys. For example, if the comparator ignores trailing spaces, it would be incorrect to use a FilterPolicy (like NewBloomFilterPolicy) that does not ignore trailing spaces in keys.
type FlushOptions ¶
type FlushOptions struct {
// contains filtered or unexported fields
}
FlushOptions represent all of the available options when manual flushing the database.
func NewDefaultFlushOptions ¶
func NewDefaultFlushOptions() *FlushOptions
NewDefaultFlushOptions creates a default FlushOptions object.
func (*FlushOptions) Destroy ¶
func (o *FlushOptions) Destroy()
Destroy deallocates the FlushOptions object.
func (*FlushOptions) SetWait ¶
func (o *FlushOptions) SetWait(value bool)
SetWait specify if the flush will wait until the flush is done. Default: true
type HistogramData ¶
type HistogramData struct {
// contains filtered or unexported fields
}
func NewHistogramData ¶
func NewHistogramData() *HistogramData
NewHistogramData constructs a HistogramData object.
func (*HistogramData) Destroy ¶
func (d *HistogramData) Destroy()
Destroy deallocates the HistogramData object.
func (*HistogramData) GetAverage ¶
func (d *HistogramData) GetAverage() float64
GetAverage returns the average value.
func (*HistogramData) GetCount ¶
func (d *HistogramData) GetCount() uint64
GetCount returns the total number of measure.
func (*HistogramData) GetMax ¶
func (d *HistogramData) GetMax() float64
GetMax returns the max value.
func (*HistogramData) GetMedian ¶
func (d *HistogramData) GetMedian() float64
GetMedian returns the median value.
func (*HistogramData) GetPercentile95 ¶
func (d *HistogramData) GetPercentile95() float64
GetPercentile95 returns the value of the percentile 95.
func (*HistogramData) GetPercentile99 ¶
func (d *HistogramData) GetPercentile99() float64
GetPercentile99 returns the value of the percentile 99.
func (*HistogramData) GetStandardDeviation ¶
func (d *HistogramData) GetStandardDeviation() float64
GetStandardDeviation returns the value of the standard deviation.
func (*HistogramData) GetSum ¶
func (d *HistogramData) GetSum() uint64
GetSum returns the sum of all measures.
type HistogramType ¶
type HistogramType uint32
HistogramType is the logical mapping of histograms defined in rocksdb:Histogram.
type IndexType ¶
type IndexType uint
IndexType specifies the index type that will be used for this table.
const ( // KBinarySearchIndexType is a space efficient index block that is optimized for // binary-search-based index. KBinarySearchIndexType IndexType = iota // KHashSearchIndexType is the hash index, if enabled, will do the hash lookup when // `Options.prefix_extractor` is provided. KHashSearchIndexType // KTwoLevelIndexSearchIndexType is a two-level index implementation. Both // levels are binary search indexes. KTwoLevelIndexSearchIndexType )
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator provides a way to seek to specific keys and iterate through the keyspace from that point, as well as access the values of those keys.
For example:
it := db.NewIterator(readOpts)
defer it.Close()
it.Seek([]byte("foo"))
for ; it.Valid(); it.Next() {
fmt.Printf("Key: %v Value: %v\n", it.Key().Data(), it.Value().Data())
}
if err := it.Err(); err != nil {
return err
}
func NewNativeIterator ¶
NewNativeIterator creates a Iterator object.
func (*Iterator) Err ¶
Err returns nil if no errors happened during iteration, or the actual error otherwise.
func (*Iterator) Key ¶
Key returns the key the iterator currently holds. The underlying storage for the returned slice is valid only until the next modification of the iterator. REQUIRES: Valid()
func (*Iterator) Next ¶
func (iter *Iterator) Next()
Next moves the iterator to the next sequential key in the database. After this call, Valid() is true if the iterator was not positioned at the last entry in the source. REQUIRES: Valid()
func (*Iterator) Prev ¶
func (iter *Iterator) Prev()
Prev moves the iterator to the previous sequential key in the database. After this call, Valid() is true if the iterator was not positioned at the first entry in source. REQUIRES: Valid()
func (*Iterator) Seek ¶
Seek moves the iterator to the position greater than or equal to the key. The iterator is Valid() after this call if the source contains an entry that comes at or past target. All Seek*() methods clear any error that the iterator had prior to the call; after the seek, Error() indicates only the error (if any) that happened during the seek, not any past errors.
func (*Iterator) SeekForPrev ¶
SeekForPrev moves the iterator to the last key that less than or equal to the target key, in contrast with Seek. The iterator is Valid() after this call if the source contains an entry that comes at or before target.
func (*Iterator) SeekToFirst ¶
func (iter *Iterator) SeekToFirst()
SeekToFirst moves the iterator to the first key in the database. The iterator is Valid() after this call if the source is not empty.
func (*Iterator) SeekToLast ¶
func (iter *Iterator) SeekToLast()
SeekToLast moves the iterator to the last key in the database. The iterator is Valid() after this call if the source is not empty.
func (*Iterator) Valid ¶
Valid returns false only when an Iterator has iterated past either the first or the last key in the database. An iterator is either positioned at a key/value pair, or not valid.
func (*Iterator) ValidForPrefix ¶
ValidForPrefix returns false only when an Iterator has iterated past the first or the last key in the database or the specified prefix.
type LogDataExtractor ¶
type LogDataExtractor struct {
Blob []byte
// contains filtered or unexported fields
}
LogDataExtractor extracts metadata from a WriteBatch.
func NewLogDataExtractor ¶
func NewLogDataExtractor(id string) *LogDataExtractor
NewLogDataExtractor creates a new LogDataExtractor.
func (*LogDataExtractor) Destroy ¶
func (e *LogDataExtractor) Destroy()
Destroy destroys de LogDataExtractor.
func (*LogDataExtractor) ID ¶
func (e *LogDataExtractor) ID() string
ID returns the unique identifier of this WriteBatchHandler.
func (*LogDataExtractor) LogData ¶
func (e *LogDataExtractor) LogData(blob []byte)
LogData is a callback for the LogData.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options represent all of the available options when opening a database with Open.
func NewDefaultOptions ¶
func NewDefaultOptions() *Options
NewDefaultOptions creates the default Options.
func (*Options) IncreaseParallelism ¶
IncreaseParallelism sets the level of parallelism.
By default, RocksDB uses only one background thread for flush and compaction. Calling this function will set it up such that total of `totalThreads` is used. Good value for `totalThreads` is the number of cores. You almost definitely want to call this function if your system is bottlenecked by RocksDB.
func (*Options) OptimizeForPointLookup ¶
OptimizeForPointLookup optimize the DB for point lookups.
Use this if you don't need to keep the data sorted, i.e. you'll never use an iterator, only Put() and Get() API calls
If you use this with rocksdb >= 5.0.2, you must call `SetAllowConcurrentMemtableWrites(false)` to avoid an assertion error immediately on opening the db.
func (*Options) SetAllowConcurrentMemtableWrites ¶
SetAllowConcurrentMemtableWrites sets whether to allow concurrent memtable writes. Conccurent writes are not supported by all memtable factories (currently only SkipList memtables). As of rocksdb 5.0.2 you must call `SetAllowConcurrentMemtableWrites(false)` if you use `OptimizeForPointLookup`.
func (*Options) SetAllowMmapReads ¶
SetAllowMmapReads enables/disables mmap reads for reading sst tables. Default: false
func (*Options) SetAllowMmapWrites ¶
SetAllowMmapWrites enables/disables mmap writes for writing sst tables. Default: false
func (*Options) SetAtomicFlush ¶
SetAtomicFlush enables/disables atomic flushes. If true, RocksDB supports flushing multiple column families and committing their results atomically to MANIFEST. Note that it is not necessary to set atomic_flush to true if WAL is always enabled since WAL allows the database to be restored to the last persistent state in WAL. This option is useful when there are column families with writes NOT protected by WAL. For manual flush, application has to specify which column families to flush atomically in db.Flush. For auto-triggered flush, RocksDB atomically flushes ALL column families.
Currently, any WAL-enabled writes after atomic flush may be replayed independently if the process crashes later and tries to recover.
func (*Options) SetBlockBasedTableFactory ¶
func (o *Options) SetBlockBasedTableFactory(value *BlockBasedTableOptions)
SetBlockBasedTableFactory sets the block based table factory.
This is the default table type that we inherited from LevelDB, which was designed for storing data in hard disk or flash device.
In block-based table, data is chucked into (almost) fix-sized blocks (default block size is 4k). Each block, in turn, keeps a bunch of entries.
When storing data, we can compress and/or encode data efficiently within a block, which often resulted in a much smaller data size compared with the raw data size.
As for the record retrieval, we'll first locate the block where target record may reside, then read the block to memory, and finally search that record within the block. Of course, to avoid frequent reads of the same block, we introduced the block cache to keep the loaded blocks in the memory.
func (*Options) SetCompression ¶
func (o *Options) SetCompression(value CompressionType)
SetCompression sets the compression algorithm. Default: SnappyCompression, which gives lightweight but fast compression.
func (*Options) SetCreateIfMissing ¶
SetCreateIfMissing specifies whether the database should be created if it is missing. Default: false
func (*Options) SetCreateIfMissingColumnFamilies ¶
SetCreateIfMissingColumnFamilies specifies whether the column families should be created if they are missing.
func (*Options) SetDBLogDir ¶
SetDBLogDir specifies the absolute info LOG dir.
If it is empty, the log files will be in the same dir as data. If it is non empty, the log files will be in the specified dir, and the db data dir's absolute path will be used as the log file name's prefix. Default: empty
func (*Options) SetDbWriteBufferSize ¶
SetDbWriteBufferSize sets the amount of data to build up in memtables across all column families before writing to disk.
This is distinct from write_buffer_size, which enforces a limit for a single memtable.
This feature is disabled by default. Specify a non-zero value to enable it.
Default: 0 (disabled)
func (*Options) SetEnablePipelinedWrite ¶
SetEnablePipelinedWrite improves concurrent write throughput in case WAL is enabled. By default, a single write thread queue is maintained for concurrent writers. The thread gets to the head of the queue becomes write batch group leader and responsible for writing to WAL and memtable for the batch group. One observation is that WAL writes and memtable writes are sequential and by making them run in parallel we can increase throughput. For one single writer WAL writes and memtable writes has to run sequentially. With concurrent writers, once the previous writer finish WAL write, the next writer waiting in the write queue can start to write WAL while the previous writer still have memtable write ongoing.
func (*Options) SetEnv ¶
SetEnv sets the specified object to interact with the environment, e.g. to read/write files, schedule background work, etc. Default: DefaultEnv
func (*Options) SetHashLinkListRep ¶
SetHashLinkListRep sets a hashed linked list as MemTableRep.
It contains a fixed array of buckets, each pointing to a sorted single linked list (null if the bucket is empty).
bucketCount: number of fixed array buckets
func (*Options) SetHashSkipListRep ¶
func (o *Options) SetHashSkipListRep(bucketCount int, skiplistHeight, skiplistBranchingFactor int32)
SetHashSkipListRep sets a hash skip list as MemTableRep.
It contains a fixed array of buckets, each pointing to a skiplist (null if the bucket is empty).
bucketCount: number of fixed array buckets skiplistHeight: the max height of the skiplist skiplistBranchingFactor: probabilistic size ratio between adjacent
link lists in the skiplist
func (*Options) SetKeepLogFileNum ¶
SetKeepLogFileNum sets the maximal info log files to be kept. Default: 1000
func (*Options) SetLevel0FileNumCompactionTrigger ¶
SetLevel0FileNumCompactionTrigger sets the number of files to trigger level-0 compaction.
A value <0 means that level-0 compaction will not be triggered by number of files at all. Default: 4
func (*Options) SetLevel0SlowdownWritesTrigger ¶
SetLevel0SlowdownWritesTrigger sets the soft limit on number of level-0 files.
We start slowing down writes at this point. A value <0 means that no writing slow down will be triggered by number of files in level-0. Default: 8
func (*Options) SetLevel0StopWritesTrigger ¶
SetLevel0StopWritesTrigger sets the maximum number of level-0 files. We stop writes at this point. Default: 12
func (*Options) SetLogFileTimeToRoll ¶
SetLogFileTimeToRoll sets the time for the info log file to roll (in seconds).
If specified with non-zero value, log file will be rolled if it has been active longer than `log_file_time_to_roll`. Default: 0 (disabled)
func (*Options) SetMaxBackgroundCompactions ¶
SetMaxBackgroundCompactions sets the maximum number of concurrent background jobs, submitted to the default LOW priority thread pool Default: 1
func (*Options) SetMaxBackgroundFlushes ¶
SetMaxBackgroundFlushes sets the maximum number of concurrent background memtable flush jobs, submitted to the HIGH priority thread pool.
By default, all background jobs (major compaction and memtable flush) go to the LOW priority pool. If this option is set to a positive number, memtable flush jobs will be submitted to the HIGH priority pool. It is important when the same Env is shared by multiple db instances. Without a separate pool, long running major compaction jobs could potentially block memtable flush jobs of other db instances, leading to unnecessary Put stalls. Default: 0
func (*Options) SetMaxBytesForLevelBase ¶
SetMaxBytesForLevelBase sets the maximum total data size for a level.
It is the max total for level-1. Maximum number of bytes for level L can be calculated as (max_bytes_for_level_base) * (max_bytes_for_level_multiplier ^ (L-1))
For example, if max_bytes_for_level_base is 20MB, and if max_bytes_for_level_multiplier is 10, total data size for level-1 will be 20MB, total file size for level-2 will be 200MB, and total file size for level-3 will be 2GB. Default: 10MB
func (*Options) SetMaxBytesForLevelMultiplier ¶
SetMaxBytesForLevelMultiplier sets the max Bytes for level multiplier. Default: 10
func (*Options) SetMaxFileOpeningThreads ¶
SetMaxFileOpeningThreads sets the maximum number of file opening threads. If max_open_files is -1, DB will open all files on db.Open(). You can use this option to increase the number of threads used to open the files. Default: 16
func (*Options) SetMaxLogFileSize ¶
SetMaxLogFileSize sets the maximal size of the info log file.
If the log file is larger than `max_log_file_size`, a new info log file will be created. If max_log_file_size == 0, all logs will be written to one log file. Default: 0
func (*Options) SetMaxOpenFiles ¶
SetMaxOpenFiles sets the number of open files that can be used by the DB.
You may need to increase this if your database has a large working set (budget one open file per 2MB of working set). Default: 1000
func (*Options) SetMaxSubCompactions ¶
SetMaxSubCompactions sets the maximum number of threads that will concurrently perform a compaction job by breaking it into multiple, smaller ones that are run simultaneously. Default: 1 (i.e. no subcompactions)
func (*Options) SetMaxTotalWalSize ¶
SetMaxTotalWalSize sets the maximum total wal size in bytes. Once write-ahead logs exceed this size, we will start forcing the flush of column families whose memtables are backed by the oldest live WAL file (i.e. the ones that are causing all the space amplification). If set to 0 (default), we will dynamically choose the WAL size limit to be [sum of all write_buffer_size * max_write_buffer_number] * 4 Default: 0
func (*Options) SetMaxWriteBufferNumber ¶
SetMaxWriteBufferNumber sets the maximum number of write buffers (memtables) that are built up in memory.
The default is 2, so that when 1 write buffer is being flushed to storage, new writes can continue to the other write buffer. Default: 2
func (*Options) SetMemtableVectorRep ¶
func (o *Options) SetMemtableVectorRep()
SetMemtableVectorRep sets a MemTableRep which is backed by a vector.
On iteration, the vector is sorted. This is useful for workloads where iteration is very rare and writes are generally not issued after reads begin.
func (*Options) SetMinWriteBufferNumberToMerge ¶
SetMinWriteBufferNumberToMerge sets the minimum number of write buffers that will be merged together before writing to storage.
If set to 1, then all write buffers are flushed to L0 as individual files and this increases read amplification because a get request has to check in all of these files. Also, an in-memory merge may result in writing lesser data to storage if there are duplicate records in each of these individual write buffers. Default: 1
func (*Options) SetNumLevels ¶
SetNumLevels sets the number of levels for this database. Default: 7
func (*Options) SetPlainTableFactory ¶
func (o *Options) SetPlainTableFactory(keyLen uint32, bloomBitsPerKey int, hashTableRatio float64, indexSparseness int)
SetPlainTableFactory sets a plain table factory with prefix-only seek.
Plain table stores data in a sequence of key/value pairs. Compared with block-based table, which employs mostly binary search for entry lookup, the well designed hash-based index in plain table enables us to locate data magnitudes faster. No memory copy is needed. Plain table bypasses the concept of "block" and therefore avoids the overhead inherent in block-based table, like extra block lookup, block cache, etc.
For this factory, you need to set prefix_extractor properly to make it work. Look-up will starts with prefix hash lookup for key prefix. Inside the hash bucket found, a binary search is executed for hash conflicts. Finally, a linear search is used.
Limitations:
- File size may not be greater than 2^31 - 1 (i.e., `2147483647`) bytes.
- Data compression/Delta encoding is not supported, which may resulted in bigger file size compared with block-based table.
- Backward (Iterator.Prev()) scan is not supported.
- Non-prefix-based Seek() is not supported.
- Table loading is slower since indexes are built on the fly by 2-pass table scanning.
- Only support mmap mode.
keyLen: plain table has optimization for fix-sized keys,
which can be specified via keyLen. Alternatively, you can pass 0 if your keys have variable lengths.
bloomBitsPerKey: the number of bits used for bloom filer per prefix. You
may disable it by passing a zero.
hashTableRatio: the desired utilization of the hash table used for prefix
hashing. hashTableRatio = number of prefixes / #buckets in the hash table
indexSparseness: inside each prefix, need to build one index record for how
many keys for binary search inside each hash bucket.
func (*Options) SetPrefixExtractor ¶
func (o *Options) SetPrefixExtractor(st SliceTransform)
SetPrefixExtractor sets the prefic extractor.
If set, use the specified function to determine the prefixes for keys. These prefixes will be placed in the filter. Depending on the workload, this can reduce the number of read-IOP cost for scans when a prefix is passed via ReadOptions to db.NewIterator(). Default: nil
func (*Options) SetStatistics ¶
func (o *Options) SetStatistics(s *Statistics)
SetStatistics sets a statistics object to pass to the DB.
func (*Options) SetTargetFileSizeBase ¶
SetTargetFileSizeBase sets the target file size for compaction.
Target file size is per-file size for level-1. Target file size for level L can be calculated by target_file_size_base * (target_file_size_multiplier ^ (L-1))
For example, if target_file_size_base is 2MB and target_file_size_multiplier is 10, then each file on level-1 will be 2MB, and each file on level 2 will be 20MB, and each file on level-3 will be 200MB. Default: 2MB
func (*Options) SetTargetFileSizeMultiplier ¶
SetTargetFileSizeMultiplier sets the target file size multiplier for compaction. Default: 1
func (*Options) SetUseDirectIOForFlushAndCompaction ¶
SetUseDirectIOForFlushAndCompaction enable/disable direct I/O mode (O_DIRECT) for both reads and writes in background flush and compactions. When true, new_table_reader_for_compaction_inputs is forced to true. Default: false
func (*Options) SetUseDirectReads ¶
SetUseDirectReads enable/disable direct I/O mode (O_DIRECT) for reads. Default: false
func (*Options) SetUseFsync ¶
SetUseFsync enable/disable fsync.
If true, then every store to stable storage will issue a fsync. If false, then every store to stable storage will issue a fdatasync. This parameter should be set to true while storing data to filesystem like ext3 that can lose files after a reboot. Default: false
func (*Options) SetWALTtlSeconds ¶
SetWALTtlSeconds sets the WAL ttl in seconds.
The following two options affect how archived logs will be deleted.
- If both set to 0, logs will be deleted asap and will not get into the archive.
- If wal_ttl_seconds is 0 and wal_size_limit_mb is not 0, WAL files will be checked every 10 min and if total size is greater then wal_size_limit_mb, they will be deleted starting with the earliest until size_limit is met. All empty files will be deleted.
- If wal_ttl_seconds is not 0 and wall_size_limit_mb is 0, then WAL files will be checked every wal_ttl_seconds / 2 and those that are older than wal_ttl_seconds will be deleted.
- If both are not 0, WAL files will be checked every 10 min and both checks will be performed with ttl being first.
Default: 0
func (*Options) SetWalDir ¶
SetWalDir specifies the absolute dir path for write-ahead logs (WAL).
If it is empty, the log files will be in the same dir as data. If it is non empty, the log files will be in the specified dir, When destroying the db, all log files and the dir are deleted. Default: empty
func (*Options) SetWalSizeLimitMb ¶
SetWalSizeLimitMb sets the WAL size limit in MB.
If total size of WAL files is greater then wal_size_limit_mb, they will be deleted starting with the earliest until size_limit is met Default: 0
func (*Options) SetWriteBufferSize ¶
SetWriteBufferSize sets the amount of data to build up in memory (backed by an unsorted log on disk) before converting to a sorted on-disk file.
Larger values increase performance, especially during bulk loads. Up to max_write_buffer_number write buffers may be held in memory at the same time, so you may wish to adjust this parameter to control memory usage. Also, a larger write buffer will result in a longer recovery time the next time the database is opened. Default: 4MB
type ReadOptions ¶
type ReadOptions struct {
// contains filtered or unexported fields
}
func NewDefaultReadOptions ¶
func NewDefaultReadOptions() *ReadOptions
NewDefaultReadOptions creates a default ReadOptions object.
func (*ReadOptions) Destroy ¶
func (o *ReadOptions) Destroy()
Destroy deallocates the ReadOptions object.
func (*ReadOptions) SetFillCache ¶
func (o *ReadOptions) SetFillCache(value bool)
SetFillCache specify whether the "data block"/"index block"/"filter block" read for this iteration should be cached in memory? Callers may wish to set this field to false for bulk scans. Default: true
func (*ReadOptions) SetIgnoreRangeDeletions ¶
func (o *ReadOptions) SetIgnoreRangeDeletions(value bool)
SetIgnoreRangeDeletions specify whether keys deleted using the DeleteRange() API will be visible to readers until they are naturally deleted during compaction. This improves read performance in DBs with many range deletions. Default: false
type RestoreOptions ¶
type RestoreOptions struct {
// contains filtered or unexported fields
}
RestoreOptions captures the options to be used during restoration of a backup.
func NewRestoreOptions ¶
func NewRestoreOptions() *RestoreOptions
NewRestoreOptions creates a RestoreOptions instance.
func (*RestoreOptions) Destroy ¶
func (ro *RestoreOptions) Destroy()
Destroy destroys this RestoreOptions instance.
func (*RestoreOptions) SetKeepLogFiles ¶
func (ro *RestoreOptions) SetKeepLogFiles(v int)
SetKeepLogFiles is used to set or unset the keep_log_files option If true, restore won't overwrite the existing log files in wal_dir. It will also move all log files from archive directory to wal_dir. By default, this is false.
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
Slice is a simple structure that contains a length and a pointer to an external byte array. It is used as a wrapper for non-copy values. Be careful when using Slices since it is up to the caller to ensure that the external byte array into which the Slice points remains live while the Slice is in use.
type SliceTransform ¶
type SliceTransform interface {
// Transform extracts a prefix from a specified key. This method is called
// when a key is inserted into the db, and the returned slice is used to
// create a bloom filter.
Transform(key []byte) []byte
// InDomain determines whether the specified key is compatible with the
// logic specified in the Transform method. This method is invoked for
// every key that is inserted into the db. If this method returns true,
// then Transform is called to translate the key to its prefix and
// that returned prefix is inserted into the bloom filter. If this
// method returns false, then the call to Transform is skipped and
// no prefix is inserted into the bloom filters.
//
// For example, if the Transform method operates on a fixed length
// prefix of size 4, then an invocation to InDomain("abc") returns
// false because the specified key length(3) is shorter than the
// prefix size of 4.
//
// Wiki documentation here:
// https://github.com/facebook/rocksdb/wiki/Prefix-Seek-API-Changes
//
InDomain(key []byte) bool
// InRange is currently not used and remains here for backward compatibility.
InRange(key []byte) bool
// Name returns the name of this transformation.
Name() string
}
A SliceTransform is a generic pluggable way of transforming one string to another. Its primary use-case is in configuring rocksdb
to store prefix blooms by setting prefix_extractor in ColumnFamilyOptions.
func NewFixedPrefixTransform ¶
func NewFixedPrefixTransform(prefixLen int) SliceTransform
NewFixedPrefixTransform creates a new fixed prefix transform.
func NewNativeSliceTransform ¶
func NewNativeSliceTransform(c *C.rocksdb_slicetransform_t) SliceTransform
NewNativeSliceTransform creates a SliceTransform object.
type Statistics ¶
type Statistics struct {
// contains filtered or unexported fields
}
Statistics is used to analyze the performance of a db. Pointer for statistics object is managed by Option class.
func NewStatistics ¶
func NewStatistics() *Statistics
NewStatistics is the constructor for a Statistics struct.
func (*Statistics) Destroy ¶
func (s *Statistics) Destroy()
Destroy deallocates the Statistics object.
func (*Statistics) GetAndResetTickerCount ¶
func (s *Statistics) GetAndResetTickerCount(tickerType TickerType) uint64
GetAndResetTickerCount get the count for a ticker and reset the tickers count.
func (*Statistics) GetHistogramData ¶
func (s *Statistics) GetHistogramData(histogramType HistogramType) *HistogramData
GetHistogramData gets the histogram data for a particular histogram.
func (*Statistics) GetTickerCount ¶
func (s *Statistics) GetTickerCount(tickerType TickerType) uint64
GetTickerCount gets the count for a ticker.
func (*Statistics) Reset ¶
func (s *Statistics) Reset()
Reset resets all ticker and histogram stats.
func (*Statistics) SetStatsLevel ¶
func (s *Statistics) SetStatsLevel(statsLevel StatsLevel)
SetStatsLevel sets the stats level.
func (*Statistics) StatsLevel ¶
func (s *Statistics) StatsLevel() StatsLevel
StatsLevel gets the current stats level.
type TickerType ¶
type TickerType uint32
TickerType is the logical mapping of tickers defined in rocksdb::Tickers.
type WALIterator ¶
type WALIterator struct {
// contains filtered or unexported fields
}
WALIterator is used to iterate over the transactions in a db. One run on the iterator is continuous, i.e. the iterator will stop at the beginning of any gap in sequences.
func NewNativeWALIterator ¶
func NewNativeWALIterator(c unsafe.Pointer) *WALIterator
NewNativeWALIterator creates a WALIterator object.
func (*WALIterator) GetBatch ¶
func (iter *WALIterator) GetBatch() (*WriteBatch, uint64)
GetBatch returns, if valid, the current write_batch and the sequence number of the earliest transaction contained in the batch. ONLY use if Valid() is true and status() is OK.
func (*WALIterator) Next ¶
func (iter *WALIterator) Next()
Next moves the iterator to the next sequential key in the database. After this call, Valid() is true if the iterator was not positioned at the last entry in the source. REQUIRES: Valid()
func (*WALIterator) Status ¶
func (iter *WALIterator) Status() error
Status returns an error if something has gone wrong or else it returns nil.
func (*WALIterator) Valid ¶
func (iter *WALIterator) Valid() bool
Valid returns false only when an Iterator has iterated past either the first or the last key in the database. An iterator is either positioned at a key/value pair, or not valid.
type WriteBatch ¶
type WriteBatch struct {
// contains filtered or unexported fields
}
WriteBatch holds a collection of updates to apply atomically to a DB.
The updates are applied in the order in which they are added to the WriteBatch. For example, the value of "key" will be "v3" after the following batch is written:
batch.Put("key", "v1");
batch.Delete("key");
batch.Put("key", "v2");
batch.Put("key", "v3");
func NewNativeWriteBatch ¶
func NewNativeWriteBatch(c *C.rocksdb_writebatch_t) *WriteBatch
NewNativeWriteBatch create a WriteBatch object.
func WriteBatchFrom ¶
func WriteBatchFrom(data []byte) *WriteBatch
WriteBatchFrom creates a write batch from a serialized WriteBatch.
func (*WriteBatch) Count ¶
func (wb *WriteBatch) Count() int
Count returns the number of updates in the batch.
func (*WriteBatch) Data ¶
func (wb *WriteBatch) Data() []byte
Data returns the serialized version of this batch.
func (*WriteBatch) Delete ¶
func (wb *WriteBatch) Delete(key []byte)
Delete erases the mapping for "key" if it exists. Else, do nothing.
func (*WriteBatch) DeleteCF ¶
func (wb *WriteBatch) DeleteCF(cf *ColumnFamilyHandle, key []byte)
DeleteCF erases the mapping for "key", in a column family, if it exists. Else, do nothing.
func (*WriteBatch) DeleteRange ¶
func (wb *WriteBatch) DeleteRange(beginKey, endKey []byte)
DeleteRange erases all mappings in the range ["beginKey", "endKey") if the database contains them. Else do nothing.
func (*WriteBatch) DeleteRangeCF ¶
func (wb *WriteBatch) DeleteRangeCF(cf *ColumnFamilyHandle, beginKey, endKey []byte)
DeleteRangeCF erases all mappings in the range ["beginKey", "endKey") on the given column family if the database contains them. Else do nothing.
func (*WriteBatch) Destroy ¶
func (wb *WriteBatch) Destroy()
Destroy deallocates the WriteBatch object.
func (*WriteBatch) GetLogData ¶
func (wb *WriteBatch) GetLogData(extractor *LogDataExtractor) []byte
GetLogData retrieves the blob appended to this batch.
func (*WriteBatch) Merge ¶
func (wb *WriteBatch) Merge(key, value []byte)
Merge "value" with the existing value of "key" in the database. "key->merge(existing, value)"
func (*WriteBatch) MergeCF ¶
func (wb *WriteBatch) MergeCF(cf *ColumnFamilyHandle, key, value []byte)
MergeCF "value" with the existing value of "key" in a column family. "key->merge(existing, value)"
func (*WriteBatch) Put ¶
func (wb *WriteBatch) Put(key, value []byte)
Put stores the mapping "key->value" in the database.
func (*WriteBatch) PutCF ¶
func (wb *WriteBatch) PutCF(cf *ColumnFamilyHandle, key, value []byte)
PutCF stores a mapping "key->value" in a column family.
func (*WriteBatch) PutLogData ¶
func (wb *WriteBatch) PutLogData(blob []byte, size int)
PutLogData appends a blob of arbitrary size to the records in this batch. The blob will be stored in the transaction log but not in any other files. In particular, it will not be persisted to the SST files. When iterating over this WriteBatch, WriteBatch::Handler::LogData will be called with the contents of the blob as it is encountered. Blobs, puts, deletes, and merges will be encountered in the same order in which they were inserted. The blob will NOT consume sequence number(s) and will NOT increase the count of the batch
Example application: add timestamps to the transaction log for use in replication.
type WriteBatchHandler ¶
WriteBatchHandler is used to iterate over the contents of a batch.
type WriteOptions ¶
type WriteOptions struct {
// contains filtered or unexported fields
}
WriteOptions represent all options available when writing to a database.
func NewDefaultWriteOptions ¶
func NewDefaultWriteOptions() *WriteOptions
NewDefaultWriteOptions creates a default WriteOptions object.
func (*WriteOptions) Destroy ¶
func (o *WriteOptions) Destroy()
Destroy deallocates the WriteOptions object.
func (*WriteOptions) SetDisableWAL ¶
func (o *WriteOptions) SetDisableWAL(value bool)
SetDisableWAL sets whether WAL should be active or not. If true, writes will not first go to the write ahead log, and the write may got lost after a crash. Default: false
func (*WriteOptions) SetSync ¶
func (o *WriteOptions) SetSync(value bool)
SetSync sets the sync mode. If true, the write will be flushed from the operating system buffer cache before the write is considered complete. If this flag is true, writes will be slower. Default: false
Source Files
¶
- backup.go
- cache.go
- cf_handle.go
- checkpoint.go
- cow.go
- db.go
- env.go
- filter_policy.go
- flags.go
- histogram.go
- histogram_type.go
- iterator.go
- options.go
- options_block_based_table.go
- options_flush.go
- options_read.go
- options_write.go
- slice.go
- slice_transform.go
- statistics.go
- test_util.go
- ticker_type.go
- util.go
- wal_iterator.go
- write_batch.go