Documentation ¶
Overview ¶
Package grocksdb provides the ability to create and access RocksDB databases.
grocksdb.OpenDb opens and creates databases.
bbto := grocksdb.NewDefaultBlockBasedTableOptions() bbto.SetBlockCache(grocksdb.NewLRUCache(3 << 30)) opts := grocksdb.NewDefaultOptions() opts.SetBlockBasedTableFactory(bbto) opts.SetCreateIfMissing(true) db, err := grocksdb.OpenDb(opts, "/path/to/db")
The DB struct returned by OpenDb provides DB.Get, DB.Put, DB.Merge and DB.Delete to modify and query the database.
ro := grocksdb.NewDefaultReadOptions() wo := grocksdb.NewDefaultWriteOptions() // if ro and wo are not used again, be sure to Close them. err = db.Put(wo, []byte("foo"), []byte("bar")) ... value, err := db.Get(ro, []byte("foo")) defer value.Free() ... err = db.Delete(wo, []byte("foo"))
For bulk reads, use an Iterator. If you want to avoid disturbing your live traffic while doing the bulk read, be sure to call SetFillCache(false) on the ReadOptions you use when creating the Iterator.
ro := grocksdb.NewDefaultReadOptions() ro.SetFillCache(false) it := db.NewIterator(ro) defer it.Close() it.Seek([]byte("foo")) for it = it; it.Valid(); it.Next() { key := it.Key() value := it.Value() fmt.Printf("Key: %v Value: %v\n", key.Data(), value.Data()) key.Free() value.Free() } if err := it.Err(); err != nil { ... }
Batched, atomic writes can be performed with a WriteBatch and DB.Write.
wb := grocksdb.NewWriteBatch() // defer wb.Close or use wb.Clear and reuse. wb.Delete([]byte("foo")) wb.Put([]byte("foo"), []byte("bar")) wb.Put([]byte("bar"), []byte("foo")) err := db.Write(wo, wb)
If your working dataset does not fit in memory, you'll want to add a bloom filter to your database. NewBloomFilter and BlockBasedTableOptions.SetFilterPolicy is what you want. NewBloomFilter is amount of bits in the filter to use per key in your database.
filter := grocksdb.NewBloomFilter(10) bbto := grocksdb.NewDefaultBlockBasedTableOptions() bbto.SetFilterPolicy(filter) opts.SetBlockBasedTableFactory(bbto) db, err := grocksdb.OpenDb(opts, "/path/to/db")
If you're using a custom comparator in your code, be aware you may have to make your own filter policy object.
This documentation is not a complete discussion of RocksDB. Please read the RocksDB documentation <http://rocksdb.org/> for information on its operation. You'll find lots of goodies there.
The default link options, to customize it, you can try build tag `grocksdb_clean_link` for a cleaner set of flags, or `grocksdb_no_link` where you have full control through `CGO_LDFLAGS` environment variable.
Index ¶
- Constants
- Variables
- func CloseBaseDBOfTransactionDB(db *DB)
- func DestroyDBPaths(dbpaths []*DBPath)
- func DestroyDb(name string, opts *Options) (err error)
- func ListColumnFamilies(opts *Options, name string) (names []string, err error)
- func OpenDbAndTrimHistory(opts *Options, name string, cfNames []string, cfOpts []*Options, ...) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
- func OpenDbAsSecondaryColumnFamilies(opts *Options, name string, secondaryPath string, cfNames []string, ...) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
- func OpenDbColumnFamilies(opts *Options, name string, cfNames []string, cfOpts []*Options) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
- func OpenDbColumnFamiliesWithTTL(opts *Options, name string, cfNames []string, cfOpts []*Options, ttls []C.int) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
- func OpenDbForReadOnlyColumnFamilies(opts *Options, name string, cfNames []string, cfOpts []*Options, ...) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
- func OpenOptimisticTransactionDbColumnFamilies(opts *Options, name string, cfNames []string, cfOpts []*Options) (db *OptimisticTransactionDB, cfHandles []*ColumnFamilyHandle, err error)
- func OpenTransactionDbColumnFamilies(opts *Options, transactionDBOpts *TransactionDBOptions, name string, ...) (db *TransactionDB, cfHandles []*ColumnFamilyHandle, err error)
- func RepairDb(name string, opts *Options) (err error)
- func SetPerfLevel(level PerfLevel)
- type BackupEngine
- func CreateBackupEngine(db *DB) (be *BackupEngine, err error)
- func CreateBackupEngineWithPath(db *DB, path string) (be *BackupEngine, err error)
- func OpenBackupEngine(opts *Options, path string) (be *BackupEngine, err error)
- func OpenBackupEngineWithOpt(opts *BackupEngineOptions, env *Env) (be *BackupEngine, err error)
- func (b *BackupEngine) Close()
- func (b *BackupEngine) CreateNewBackup() (err error)
- func (b *BackupEngine) CreateNewBackupFlush(flushBeforeBackup bool) (err error)
- func (b *BackupEngine) GetInfo() (infos []BackupInfo)
- func (b *BackupEngine) PurgeOldBackups(numBackupsToKeep uint32) (err error)
- func (b *BackupEngine) RestoreDBFromBackup(dbDir, walDir string, ro *RestoreOptions, backupID uint32) (err error)
- func (b *BackupEngine) RestoreDBFromLatestBackup(dbDir, walDir string, ro *RestoreOptions) (err error)
- func (b *BackupEngine) VerifyBackup(backupID uint32) (err error)
- type BackupEngineOptions
- func (b *BackupEngineOptions) BackupLogFiles(flag bool)
- func (b *BackupEngineOptions) Destroy()
- func (b *BackupEngineOptions) DestroyOldData(flag bool)
- func (b *BackupEngineOptions) GetBackupRateLimit() uint64
- func (b *BackupEngineOptions) GetCallbackTriggerIntervalSize() uint64
- func (b *BackupEngineOptions) GetMaxBackgroundOperations() int
- func (b *BackupEngineOptions) GetMaxValidBackupsToOpen() int
- func (b *BackupEngineOptions) GetRestoreRateLimit() uint64
- func (b *BackupEngineOptions) GetShareFilesWithChecksumNaming() ShareFilesNaming
- func (b *BackupEngineOptions) IsBackupLogFiles() bool
- func (b *BackupEngineOptions) IsDestroyOldData() bool
- func (b *BackupEngineOptions) IsShareTableFiles() bool
- func (b *BackupEngineOptions) IsSync() bool
- func (b *BackupEngineOptions) SetBackupDir(dir string)
- func (b *BackupEngineOptions) SetBackupRateLimit(limit uint64)
- func (b *BackupEngineOptions) SetCallbackTriggerIntervalSize(size uint64)
- func (b *BackupEngineOptions) SetEnv(env *Env)
- func (b *BackupEngineOptions) SetMaxBackgroundOperations(v int)
- func (b *BackupEngineOptions) SetMaxValidBackupsToOpen(val int)
- func (b *BackupEngineOptions) SetRestoreRateLimit(limit uint64)
- func (b *BackupEngineOptions) SetShareFilesWithChecksumNaming(val ShareFilesNaming)
- func (b *BackupEngineOptions) SetSync(flag bool)
- func (b *BackupEngineOptions) ShareTableFiles(flag bool)
- type BackupInfo
- type BlockBasedPinningTier
- type BlockBasedTableOptions
- func (opts *BlockBasedTableOptions) Destroy()
- func (opts *BlockBasedTableOptions) SetBlockCache(cache *Cache)
- func (opts *BlockBasedTableOptions) SetBlockRestartInterval(blockRestartInterval int)
- func (opts *BlockBasedTableOptions) SetBlockSize(blockSize int)
- func (opts *BlockBasedTableOptions) SetBlockSizeDeviation(blockSizeDeviation int)
- func (opts *BlockBasedTableOptions) SetCacheIndexAndFilterBlocks(value bool)
- func (opts *BlockBasedTableOptions) SetCacheIndexAndFilterBlocksWithHighPriority(value bool)
- func (opts *BlockBasedTableOptions) SetChecksum(csType int8)
- func (opts *BlockBasedTableOptions) SetDataBlockHashRatio(value float64)
- func (opts *BlockBasedTableOptions) SetDataBlockIndexType(value DataBlockIndexType)
- func (opts *BlockBasedTableOptions) SetFilterPolicy(fp *NativeFilterPolicy)
- func (opts *BlockBasedTableOptions) SetFormatVersion(value int)
- func (opts *BlockBasedTableOptions) SetIndexBlockRestartInterval(value int)
- func (opts *BlockBasedTableOptions) SetIndexType(value IndexType)
- func (opts *BlockBasedTableOptions) SetMetadataBlockSize(value uint64)
- func (opts *BlockBasedTableOptions) SetNoBlockCache(value bool)
- func (opts *BlockBasedTableOptions) SetOptimizeFiltersForMemory(value bool)
- func (opts *BlockBasedTableOptions) SetPartitionFilters(value bool)
- func (opts *BlockBasedTableOptions) SetPartitionPinningTier(tier BlockBasedPinningTier)
- func (opts *BlockBasedTableOptions) SetPinL0FilterAndIndexBlocksInCache(value bool)
- func (opts *BlockBasedTableOptions) SetPinTopLevelIndexAndFilter(value bool)
- func (opts *BlockBasedTableOptions) SetTopLevelIndexPinningTier(tier BlockBasedPinningTier)
- func (opts *BlockBasedTableOptions) SetUnpartitionedPinningTier(tier BlockBasedPinningTier)
- func (opts *BlockBasedTableOptions) SetUseDeltaEncoding(value bool)
- func (opts *BlockBasedTableOptions) SetWholeKeyFiltering(value bool)
- type BottommostLevelCompaction
- type COWList
- type Cache
- type Checkpoint
- type ColumnFamilyHandle
- type ColumnFamilyHandles
- type ColumnFamilyMetadata
- type CompactRangeOptions
- func (opts *CompactRangeOptions) BottommostLevelCompaction() BottommostLevelCompaction
- func (opts *CompactRangeOptions) ChangeLevel() bool
- func (opts *CompactRangeOptions) Destroy()
- func (opts *CompactRangeOptions) GetExclusiveManualCompaction() bool
- func (opts *CompactRangeOptions) SetBottommostLevelCompaction(value BottommostLevelCompaction)
- func (opts *CompactRangeOptions) SetChangeLevel(value bool)
- func (opts *CompactRangeOptions) SetExclusiveManualCompaction(value bool)
- func (opts *CompactRangeOptions) SetFullHistoryTsLow(ts []byte)
- func (opts *CompactRangeOptions) SetTargetLevel(value int32)
- func (opts *CompactRangeOptions) TargetLevel() int32
- type CompactionAccessPattern
- type CompactionFilter
- type CompactionPri
- type CompactionStyle
- type Comparator
- func (c *Comparator) Compare(a, b []byte) int
- func (c *Comparator) CompareTimestamp(a, b []byte) int
- func (c *Comparator) CompareWithoutTimestamp(a []byte, aHasTs bool, b []byte, bHasTs bool) int
- func (c *Comparator) Destroy()
- func (c *Comparator) Name() string
- func (c *Comparator) TimestampSize() uint64
- type Comparing
- type ComparingWithoutTimestamp
- type CompressionOptions
- type CompressionType
- type CuckooTableOptions
- func (opts *CuckooTableOptions) Destroy()
- func (opts *CuckooTableOptions) SetCuckooBlockSize(value uint32)
- func (opts *CuckooTableOptions) SetHashRatio(value float64)
- func (opts *CuckooTableOptions) SetIdentityAsFirstHash(value bool)
- func (opts *CuckooTableOptions) SetMaxSearchDepth(value uint32)
- func (opts *CuckooTableOptions) SetUseModuleHash(value bool)
- type DB
- func OpenDb(opts *Options, name string) (db *DB, err error)
- func OpenDbAsSecondary(opts *Options, name, secondaryPath string) (db *DB, err error)
- func OpenDbForReadOnly(opts *Options, name string, errorIfWalFileExists bool) (db *DB, err error)
- func OpenDbWithTTL(opts *Options, name string, ttl int) (db *DB, err error)
- func (db *DB) CancelAllBackgroundWork(wait bool)
- func (db *DB) Close()
- func (db *DB) CompactRange(r Range)
- func (db *DB) CompactRangeCF(cf *ColumnFamilyHandle, r Range)
- func (db *DB) CompactRangeCFOpt(cf *ColumnFamilyHandle, r Range, opt *CompactRangeOptions)
- func (db *DB) CompactRangeOpt(r Range, opt *CompactRangeOptions)
- func (db *DB) CreateColumnFamilies(opts *Options, names []string) (handles []*ColumnFamilyHandle, err error)
- func (db *DB) CreateColumnFamily(opts *Options, name string) (handle *ColumnFamilyHandle, err error)
- func (db *DB) CreateColumnFamilyWithTTL(opts *Options, name string, ttl int) (handle *ColumnFamilyHandle, err error)
- func (db *DB) Delete(opts *WriteOptions, key []byte) (err error)
- func (db *DB) DeleteCF(opts *WriteOptions, cf *ColumnFamilyHandle, key []byte) (err error)
- func (db *DB) DeleteCFWithTS(opts *WriteOptions, cf *ColumnFamilyHandle, key, ts []byte) (err error)
- func (db *DB) DeleteFile(name string)
- func (db *DB) DeleteFileInRange(r Range) (err error)
- func (db *DB) DeleteFileInRangeCF(cf *ColumnFamilyHandle, r Range) (err error)
- func (db *DB) DeleteRangeCF(opts *WriteOptions, cf *ColumnFamilyHandle, startKey, endKey []byte) (err error)
- func (db *DB) DeleteWithTS(opts *WriteOptions, key, ts []byte) (err error)
- func (db *DB) DisableFileDeletions() (err error)
- func (db *DB) DisableManualCompaction()
- func (db *DB) DropColumnFamily(c *ColumnFamilyHandle) (err error)
- func (db *DB) EnableFileDeletions() (err error)
- func (db *DB) EnableManualCompaction()
- func (db *DB) Flush(opts *FlushOptions) (err error)
- func (db *DB) FlushCF(cf *ColumnFamilyHandle, opts *FlushOptions) (err error)
- func (db *DB) FlushCFs(cfs []*ColumnFamilyHandle, opts *FlushOptions) (err error)
- func (db *DB) FlushWAL(sync bool) (err error)
- func (db *DB) Get(opts *ReadOptions, key []byte) (slice *Slice, err error)
- func (db *DB) GetApproximateSizes(ranges []Range) ([]uint64, error)
- func (db *DB) GetApproximateSizesCF(cf *ColumnFamilyHandle, ranges []Range) ([]uint64, error)
- func (db *DB) GetBytes(opts *ReadOptions, key []byte) (data []byte, err error)
- func (db *DB) GetBytesWithTS(opts *ReadOptions, key []byte) (data, timestamp []byte, err error)
- func (db *DB) GetCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
- func (db *DB) GetCFWithTS(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (value, timestamp *Slice, err error)
- func (db *DB) GetColumnFamilyMetadata() (m *ColumnFamilyMetadata)
- func (db *DB) GetColumnFamilyMetadataCF(cf *ColumnFamilyHandle) (m *ColumnFamilyMetadata)
- func (db *DB) GetDefaultColumnFamily() *ColumnFamilyHandle
- func (db *DB) GetFullHistoryTsLow(handle *ColumnFamilyHandle) (slice *Slice, err error)
- func (db *DB) GetIntProperty(propName string) (value uint64, success bool)
- func (db *DB) GetIntPropertyCF(propName string, cf *ColumnFamilyHandle) (value uint64, success bool)
- func (db *DB) GetLatestSequenceNumber() uint64
- func (db *DB) GetLiveFilesMetaData() []LiveFileMetadata
- func (db *DB) GetPinned(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
- func (db *DB) GetPinnedCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
- func (db *DB) GetProperty(propName string) (value string)
- func (db *DB) GetPropertyCF(propName string, cf *ColumnFamilyHandle) (value string)
- func (db *DB) GetUpdatesSince(seqNumber uint64) (iter *WalIterator, err error)
- func (db *DB) GetWithTS(opts *ReadOptions, key []byte) (value, timestamp *Slice, err error)
- func (db *DB) IncreaseFullHistoryTsLow(handle *ColumnFamilyHandle, ts []byte) (err error)
- func (db *DB) IngestExternalFile(filePaths []string, opts *IngestExternalFileOptions) (err error)
- func (db *DB) IngestExternalFileCF(handle *ColumnFamilyHandle, filePaths []string, ...) (err error)
- func (db *DB) KeyMayExists(opts *ReadOptions, key []byte, timestamp string) (slice *Slice)
- func (db *DB) KeyMayExistsCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte, timestamp string) (slice *Slice)
- func (db *DB) Merge(opts *WriteOptions, key, value []byte) (err error)
- func (db *DB) MergeCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
- func (db *DB) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error)
- func (db *DB) MultiGetCF(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, error)
- func (db *DB) MultiGetCFMultiCF(opts *ReadOptions, cfs ColumnFamilyHandles, keys [][]byte) (Slices, error)
- func (db *DB) MultiGetCFWithTS(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, Slices, error)
- func (db *DB) MultiGetMultiCFWithTS(opts *ReadOptions, cfs ColumnFamilyHandles, keys [][]byte) (Slices, Slices, error)
- func (db *DB) MultiGetWithTS(opts *ReadOptions, keys ...[]byte) (Slices, Slices, error)
- func (db *DB) Name() string
- func (db *DB) NewCheckpoint() (cp *Checkpoint, err error)
- func (db *DB) NewIterator(opts *ReadOptions) *Iterator
- func (db *DB) NewIteratorCF(opts *ReadOptions, cf *ColumnFamilyHandle) *Iterator
- func (db *DB) NewIterators(opts *ReadOptions, cfs []*ColumnFamilyHandle) (iters []*Iterator, err error)
- func (db *DB) NewSnapshot() *Snapshot
- func (db *DB) Put(opts *WriteOptions, key, value []byte) (err error)
- func (db *DB) PutCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
- func (db *DB) PutCFWithTS(opts *WriteOptions, cf *ColumnFamilyHandle, key, ts, value []byte) (err error)
- func (db *DB) PutWithTS(opts *WriteOptions, key, ts, value []byte) (err error)
- func (db *DB) ReleaseSnapshot(snapshot *Snapshot)
- func (db *DB) SetOptions(keys, values []string) (err error)
- func (db *DB) SetOptionsCF(cf *ColumnFamilyHandle, keys, values []string) (err error)
- func (db *DB) SingleDelete(opts *WriteOptions, key []byte) (err error)
- func (db *DB) SingleDeleteCF(opts *WriteOptions, cf *ColumnFamilyHandle, key []byte) (err error)
- func (db *DB) SingleDeleteCFWithTS(opts *WriteOptions, cf *ColumnFamilyHandle, key, ts []byte) (err error)
- func (db *DB) SingleDeleteWithTS(opts *WriteOptions, key, ts []byte) (err error)
- func (db *DB) SuggestCompactRange(r Range) (err error)
- func (db *DB) SuggestCompactRangeCF(cf *ColumnFamilyHandle, r Range) (err error)
- func (db *DB) TryCatchUpWithPrimary() (err error)
- func (db *DB) WaitForCompact(opts *WaitForCompactOptions) (err error)
- func (db *DB) Write(opts *WriteOptions, batch *WriteBatch) (err error)
- func (db *DB) WriteWI(opts *WriteOptions, batch *WriteBatchWI) (err error)
- type DBPath
- type DataBlockIndexType
- type EncodingType
- type Env
- func (env *Env) Destroy()
- func (env *Env) GetBackgroundThreads() int
- func (env *Env) GetBottomPriorityBackgroundThreads() int
- func (env *Env) GetHighPriorityBackgroundThreads() int
- func (env *Env) GetLowPriorityBackgroundThreads() int
- func (env *Env) JoinAllThreads()
- func (env *Env) LowerHighPriorityThreadPoolCPUPriority()
- func (env *Env) LowerHighPriorityThreadPoolIOPriority()
- func (env *Env) LowerThreadPoolCPUPriority()
- func (env *Env) LowerThreadPoolIOPriority()
- func (env *Env) SetBackgroundThreads(n int)
- func (env *Env) SetBottomPriorityBackgroundThreads(n int)
- func (env *Env) SetHighPriorityBackgroundThreads(n int)
- func (env *Env) SetLowPriorityBackgroundThreads(n int)
- type EnvOptions
- type FIFOCompactionOptions
- func (opts *FIFOCompactionOptions) AllowCompaction() bool
- func (opts *FIFOCompactionOptions) Destroy()
- func (opts *FIFOCompactionOptions) GetMaxTableFilesSize() uint64
- func (opts *FIFOCompactionOptions) SetAllowCompaction(allow bool)
- func (opts *FIFOCompactionOptions) SetMaxTableFilesSize(value uint64)
- type FlushOptions
- type HistogramData
- type HistogramType
- type HyperClockCacheOptions
- type IndexType
- type InfoLogLevel
- type IngestExternalFileOptions
- func (opts *IngestExternalFileOptions) Destroy()
- func (opts *IngestExternalFileOptions) SetAllowBlockingFlush(flag bool)
- func (opts *IngestExternalFileOptions) SetAllowGlobalSeqNo(flag bool)
- func (opts *IngestExternalFileOptions) SetFailIfNotBottommostLevel(flag bool)
- func (opts *IngestExternalFileOptions) SetIngestionBehind(flag bool)
- func (opts *IngestExternalFileOptions) SetMoveFiles(flag bool)
- func (opts *IngestExternalFileOptions) SetSnapshotConsistency(flag bool)
- type Iterator
- func (iter *Iterator) Close()
- func (iter *Iterator) Err() (err error)
- func (iter *Iterator) Key() *Slice
- func (iter *Iterator) Next()
- func (iter *Iterator) Prev()
- func (iter *Iterator) Refresh() (err error)
- func (iter *Iterator) Seek(key []byte)
- func (iter *Iterator) SeekForPrev(key []byte)
- func (iter *Iterator) SeekToFirst()
- func (iter *Iterator) SeekToLast()
- func (iter *Iterator) Timestamp() *Slice
- func (iter *Iterator) Valid() bool
- func (iter *Iterator) ValidForPrefix(prefix []byte) bool
- func (iter *Iterator) Value() *Slice
- type LRUCacheOptions
- type LatestOptions
- type LevelMetadata
- type LiveFileMetadata
- type Logger
- type MemoryAllocator
- type MemoryUsage
- type MergeOperator
- type MultiMerger
- type NativeFilterPolicy
- func NewBloomFilter(bitsPerKey float64) *NativeFilterPolicy
- func NewBloomFilterFull(bitsPerKey float64) *NativeFilterPolicy
- func NewRibbonFilterPolicy(bloomEquivalentBitsPerKey float64) *NativeFilterPolicy
- func NewRibbonHybridFilterPolicy(bloomEquivalentBitsPerKey float64, bloomBeforeLevel int) *NativeFilterPolicy
- type OptimisticTransactionDB
- func (db *OptimisticTransactionDB) Close()
- func (db *OptimisticTransactionDB) CloseBaseDB(base *DB)
- func (db *OptimisticTransactionDB) GetBaseDB() *DB
- func (db *OptimisticTransactionDB) NewCheckpoint() (cp *Checkpoint, err error)
- func (db *OptimisticTransactionDB) TransactionBegin(opts *WriteOptions, transactionOpts *OptimisticTransactionOptions, ...) *Transaction
- func (db *OptimisticTransactionDB) Write(opts *WriteOptions, batch *WriteBatch) (err error)
- type OptimisticTransactionOptions
- type Options
- func (opts *Options) AddCompactOnDeletionCollectorFactory(windowSize, numDelsTrigger uint)
- func (opts *Options) AddCompactOnDeletionCollectorFactoryWithRatio(windowSize, numDelsTrigger uint, deletionRatio float64)
- func (opts *Options) AdviseRandomOnOpen() bool
- func (opts *Options) AllowConcurrentMemtableWrites() bool
- func (opts *Options) AllowIngestBehind() bool
- func (opts *Options) AllowMmapReads() bool
- func (opts *Options) AllowMmapWrites() bool
- func (opts *Options) AvoidUnnecessaryBlockingIO(v bool)
- func (opts *Options) Clone() *Options
- func (opts *Options) CompactionReadaheadSize(value uint64)
- func (opts *Options) CreateIfMissing() bool
- func (opts *Options) CreateIfMissingColumnFamilies() bool
- func (opts *Options) Destroy()
- func (opts *Options) DisabledAutoCompactions() bool
- func (opts *Options) EnableBlobFiles(value bool)
- func (opts *Options) EnableBlobGC(value bool)
- func (opts *Options) EnableStatistics()
- func (opts *Options) EnabledPipelinedWrite() bool
- func (opts *Options) EnabledWriteThreadAdaptiveYield() bool
- func (opts *Options) ErrorIfExists() bool
- func (opts *Options) GetArenaBlockSize() uint64
- func (opts *Options) GetAvoidUnnecessaryBlockingIOFlag() bool
- func (opts *Options) GetBlobCompactionReadaheadSize() uint64
- func (opts *Options) GetBlobCompressionType() CompressionType
- func (opts *Options) GetBlobFileSize() uint64
- func (opts *Options) GetBlobFileStartingLevel() int
- func (opts *Options) GetBlobGCAgeCutoff() float64
- func (opts *Options) GetBlobGCForceThreshold() float64
- func (opts *Options) GetBloomLocality() uint32
- func (opts *Options) GetBottommostCompression() CompressionType
- func (opts *Options) GetBottommostCompressionOptionsZstdDictTrainer() bool
- func (opts *Options) GetBytesPerSync() uint64
- func (opts *Options) GetCompactionPri() CompactionPri
- func (opts *Options) GetCompactionReadaheadSize() uint64
- func (opts *Options) GetCompactionStyle() CompactionStyle
- func (opts *Options) GetCompression() CompressionType
- func (opts *Options) GetCompressionOptionsMaxDictBufferBytes() uint64
- func (opts *Options) GetCompressionOptionsParallelThreads() int
- func (opts *Options) GetCompressionOptionsZstdDictTrainer() bool
- func (opts *Options) GetCompressionOptionsZstdMaxTrainBytes() int
- func (opts *Options) GetDbWriteBufferSize() uint64
- func (opts *Options) GetDeleteObsoleteFilesPeriodMicros() uint64
- func (opts *Options) GetHardPendingCompactionBytesLimit() uint64
- func (opts *Options) GetHistogramData(histogramType HistogramType) (histogram HistogramData)
- func (opts *Options) GetInfoLog() *Logger
- func (opts *Options) GetInfoLogLevel() InfoLogLevel
- func (opts *Options) GetInplaceUpdateNumLocks() uint
- func (opts *Options) GetKeepLogFileNum() uint
- func (opts *Options) GetLevel0FileNumCompactionTrigger() int
- func (opts *Options) GetLevel0SlowdownWritesTrigger() int
- func (opts *Options) GetLevel0StopWritesTrigger() int
- func (opts *Options) GetLevelCompactionDynamicLevelBytes() bool
- func (opts *Options) GetLogFileTimeToRoll() uint64
- func (opts *Options) GetManifestPreallocationSize() uint64
- func (opts *Options) GetMaxBackgroundCompactions() int
- func (opts *Options) GetMaxBackgroundFlushes() int
- func (opts *Options) GetMaxBackgroundJobs() int
- func (opts *Options) GetMaxBytesForLevelBase() uint64
- func (opts *Options) GetMaxBytesForLevelMultiplier() float64
- func (opts *Options) GetMaxCompactionBytes() uint64
- func (opts *Options) GetMaxFileOpeningThreads() int
- func (opts *Options) GetMaxLogFileSize() uint64
- func (opts *Options) GetMaxManifestFileSize() uint64
- func (opts *Options) GetMaxOpenFiles() int
- func (opts *Options) GetMaxSequentialSkipInIterations() uint64
- func (opts *Options) GetMaxSubcompactions() uint32
- func (opts *Options) GetMaxSuccessiveMerges() uint
- func (opts *Options) GetMaxTotalWalSize() uint64
- func (opts *Options) GetMaxWriteBufferNumber() int
- func (opts *Options) GetMaxWriteBufferNumberToMaintain() intdeprecated
- func (opts *Options) GetMaxWriteBufferSizeToMaintain() int64
- func (opts *Options) GetMemTablePrefixBloomSizeRatio() float64
- func (opts *Options) GetMempurgeThreshold() float64
- func (opts *Options) GetMemtableHugePageSize() uint64
- func (opts *Options) GetMinBlobSize() uint64
- func (opts *Options) GetMinWriteBufferNumberToMerge() int
- func (opts *Options) GetNumLevels() int
- func (opts *Options) GetPeriodicCompactionSeconds() uint64
- func (opts *Options) GetPrepopulateBlobCache() PrepopulateBlob
- func (opts *Options) GetRecycleLogFileNum() uint
- func (opts *Options) GetSoftPendingCompactionBytesLimit() uint64
- func (opts *Options) GetStatisticsLevel() StatisticsLevel
- func (opts *Options) GetStatisticsString() (stats string)
- func (opts *Options) GetStatsDumpPeriodSec() uint
- func (opts *Options) GetStatsPersistPeriodSec() uint
- func (opts *Options) GetTTL() uint64
- func (opts *Options) GetTableCacheNumshardbits() int
- func (opts *Options) GetTargetFileSizeBase() uint64
- func (opts *Options) GetTargetFileSizeMultiplier() int
- func (opts *Options) GetTickerCount(tickerType TickerType) uint64
- func (opts *Options) GetWALBytesPerSync() uint64
- func (opts *Options) GetWALCompression() CompressionType
- func (opts *Options) GetWALRecoveryMode() WALRecoveryMode
- func (opts *Options) GetWALTtlSeconds() uint64
- func (opts *Options) GetWalSizeLimitMb() uint64
- func (opts *Options) GetWritableFileMaxBufferSize() uint64
- func (opts *Options) GetWriteBufferSize() uint64
- func (opts *Options) IncreaseParallelism(totalThreads int)
- func (opts *Options) InplaceUpdateSupport() bool
- func (opts *Options) IsAtomicFlush() bool
- func (opts *Options) IsBlobFilesEnabled() bool
- func (opts *Options) IsBlobGCEnabled() bool
- func (opts *Options) IsDBIDWrittenToManifest() bool
- func (opts *Options) IsFdCloseOnExec() bool
- func (opts *Options) IsIdentityFileWritten() bool
- func (opts *Options) IsManualWALFlush() bool
- func (opts *Options) OptimizeFiltersForHits() bool
- func (opts *Options) OptimizeForPointLookup(blockCacheSizeMB uint64)
- func (opts *Options) OptimizeLevelStyleCompaction(memtableMemoryBudget uint64)
- func (opts *Options) OptimizeUniversalStyleCompaction(memtableMemoryBudget uint64)
- func (opts *Options) ParanoidChecks() bool
- func (opts *Options) PrepareForBulkLoad()
- func (opts *Options) ReportBackgroundIOStats() bool
- func (opts *Options) SetAdviseRandomOnOpen(value bool)
- func (opts *Options) SetAllowConcurrentMemtableWrites(allow bool)
- func (opts *Options) SetAllowIngestBehind(value bool)
- func (opts *Options) SetAllowMmapReads(value bool)
- func (opts *Options) SetAllowMmapWrites(value bool)
- func (opts *Options) SetArenaBlockSize(value uint64)
- func (opts *Options) SetAtomicFlush(value bool)
- func (opts *Options) SetBlobCache(cache *Cache)
- func (opts *Options) SetBlobCompactionReadaheadSize(val uint64)
- func (opts *Options) SetBlobCompressionType(compressionType CompressionType)
- func (opts *Options) SetBlobFileSize(value uint64)
- func (opts *Options) SetBlobFileStartingLevel(level int)
- func (opts *Options) SetBlobGCAgeCutoff(value float64)
- func (opts *Options) SetBlobGCForceThreshold(val float64)
- func (opts *Options) SetBlockBasedTableFactory(value *BlockBasedTableOptions)
- func (opts *Options) SetBloomLocality(value uint32)
- func (opts *Options) SetBottommostCompression(value CompressionType)
- func (opts *Options) SetBottommostCompressionOptions(value CompressionOptions, enabled bool)
- func (opts *Options) SetBottommostCompressionOptionsMaxDictBufferBytes(value uint64, enabled bool)
- func (opts *Options) SetBottommostCompressionOptionsZstdDictTrainer(enabled bool)
- func (opts *Options) SetBottommostCompressionOptionsZstdMaxTrainBytes(value int, enabled bool)
- func (opts *Options) SetBytesPerSync(value uint64)
- func (opts *Options) SetCFPaths(dbpaths []*DBPath)
- func (opts *Options) SetCompactionFilter(value CompactionFilter)
- func (opts *Options) SetCompactionPri(pri CompactionPri)
- func (opts *Options) SetCompactionStyle(value CompactionStyle)
- func (opts *Options) SetComparator(cmp *Comparator)
- func (opts *Options) SetCompression(value CompressionType)
- func (opts *Options) SetCompressionOptions(value CompressionOptions)
- func (opts *Options) SetCompressionOptionsMaxDictBufferBytes(value uint64)
- func (opts *Options) SetCompressionOptionsParallelThreads(n int)
- func (opts *Options) SetCompressionOptionsZstdDictTrainer(enabled bool)
- func (opts *Options) SetCompressionOptionsZstdMaxTrainBytes(value int)
- func (opts *Options) SetCompressionPerLevel(value []CompressionType)
- func (opts *Options) SetCreateIfMissing(value bool)
- func (opts *Options) SetCreateIfMissingColumnFamilies(value bool)
- func (opts *Options) SetCuckooTableFactory(cuckooOpts *CuckooTableOptions)
- func (opts *Options) SetDBPaths(dbpaths []*DBPath)
- func (opts *Options) SetDbLogDir(value string)
- func (opts *Options) SetDbWriteBufferSize(value uint64)
- func (opts *Options) SetDeleteObsoleteFilesPeriodMicros(value uint64)
- func (opts *Options) SetDisableAutoCompactions(value bool)
- func (opts *Options) SetDumpMallocStats(value bool)
- func (opts *Options) SetEnablePipelinedWrite(value bool)
- func (opts *Options) SetEnableWriteThreadAdaptiveYield(value bool)
- func (opts *Options) SetEnv(env *Env)
- func (opts *Options) SetErrorIfExists(value bool)
- func (opts *Options) SetFIFOCompactionOptions(value *FIFOCompactionOptions)
- func (opts *Options) SetHardPendingCompactionBytesLimit(value uint64)
- func (opts *Options) SetHashLinkListRep(bucketCount uint)
- func (opts *Options) SetHashSkipListRep(bucketCount uint, skiplistHeight, skiplistBranchingFactor int32)
- func (opts *Options) SetInfoLog(logger *Logger)
- func (opts *Options) SetInfoLogLevel(value InfoLogLevel)
- func (opts *Options) SetInplaceUpdateNumLocks(value uint)
- func (opts *Options) SetInplaceUpdateSupport(value bool)
- func (opts *Options) SetIsFdCloseOnExec(value bool)
- func (opts *Options) SetKeepLogFileNum(value uint)
- func (opts *Options) SetLevel0FileNumCompactionTrigger(value int)
- func (opts *Options) SetLevel0SlowdownWritesTrigger(value int)
- func (opts *Options) SetLevel0StopWritesTrigger(value int)
- func (opts *Options) SetLevelCompactionDynamicLevelBytes(value bool)
- func (opts *Options) SetLogFileTimeToRoll(value uint64)
- func (opts *Options) SetManifestPreallocationSize(value uint64)
- func (opts *Options) SetManualWALFlush(v bool)
- func (opts *Options) SetMaxBackgroundCompactions(value int)deprecated
- func (opts *Options) SetMaxBackgroundFlushes(value int)deprecated
- func (opts *Options) SetMaxBackgroundJobs(value int)
- func (opts *Options) SetMaxBytesForLevelBase(value uint64)
- func (opts *Options) SetMaxBytesForLevelMultiplier(value float64)
- func (opts *Options) SetMaxBytesForLevelMultiplierAdditional(value []int)
- func (opts *Options) SetMaxCompactionBytes(value uint64)
- func (opts *Options) SetMaxFileOpeningThreads(value int)
- func (opts *Options) SetMaxLogFileSize(value uint64)
- func (opts *Options) SetMaxManifestFileSize(value uint64)
- func (opts *Options) SetMaxOpenFiles(value int)
- func (opts *Options) SetMaxSequentialSkipInIterations(value uint64)
- func (opts *Options) SetMaxSubcompactions(value uint32)
- func (opts *Options) SetMaxSuccessiveMerges(value uint)
- func (opts *Options) SetMaxTotalWalSize(value uint64)
- func (opts *Options) SetMaxWriteBufferNumber(value int)
- func (opts *Options) SetMaxWriteBufferNumberToMaintain(value int)deprecated
- func (opts *Options) SetMaxWriteBufferSizeToMaintain(value int64)
- func (opts *Options) SetMemTablePrefixBloomSizeRatio(value float64)
- func (opts *Options) SetMempurgeThreshold(threshold float64)
- func (opts *Options) SetMemtableHugePageSize(value uint64)
- func (opts *Options) SetMemtableVectorRep()
- func (opts *Options) SetMemtableWholeKeyFiltering(value bool)
- func (opts *Options) SetMergeOperator(value MergeOperator)
- func (opts *Options) SetMinBlobSize(value uint64)
- func (opts *Options) SetMinLevelToCompress(value int)
- func (opts *Options) SetMinWriteBufferNumberToMerge(value int)
- func (opts *Options) SetNativeComparator(cmp unsafe.Pointer)
- func (opts *Options) SetNumLevels(value int)
- func (opts *Options) SetOptimizeFiltersForHits(value bool)
- func (opts *Options) SetParanoidChecks(value bool)
- func (opts *Options) SetPeriodicCompactionSeconds(v uint64)
- func (opts *Options) SetPlainTableFactory(keyLen uint32, bloomBitsPerKey int, hashTableRatio float64, ...)
- func (opts *Options) SetPrefixExtractor(value SliceTransform)
- func (opts *Options) SetPrepopulateBlobCache(strategy PrepopulateBlob)
- func (opts *Options) SetRateLimiter(rateLimiter *RateLimiter)
- func (opts *Options) SetRecycleLogFileNum(value uint)
- func (opts *Options) SetReportBackgroundIOStats(value bool)
- func (opts *Options) SetRowCache(cache *Cache)
- func (opts *Options) SetSkipCheckingSSTFileSizesOnDBOpen(value bool)
- func (opts *Options) SetSkipStatsUpdateOnDBOpen(value bool)
- func (opts *Options) SetSoftPendingCompactionBytesLimit(value uint64)
- func (opts *Options) SetStatisticsLevel(level StatisticsLevel)
- func (opts *Options) SetStatsDumpPeriodSec(value uint)
- func (opts *Options) SetStatsPersistPeriodSec(value uint)
- func (opts *Options) SetTTL(seconds uint64)
- func (opts *Options) SetTableCacheNumshardbits(value int)
- func (opts *Options) SetTargetFileSizeBase(value uint64)
- func (opts *Options) SetTargetFileSizeMultiplier(value int)
- func (opts *Options) SetUint64AddMergeOperator()
- func (opts *Options) SetUniversalCompactionOptions(value *UniversalCompactionOptions)
- func (opts *Options) SetUnorderedWrite(value bool)
- func (opts *Options) SetUseAdaptiveMutex(value bool)
- func (opts *Options) SetUseDirectIOForFlushAndCompaction(value bool)
- func (opts *Options) SetUseDirectReads(value bool)
- func (opts *Options) SetUseFsync(value bool)
- func (opts *Options) SetWALBytesPerSync(value uint64)
- func (opts *Options) SetWALCompression(cType CompressionType)
- func (opts *Options) SetWALRecoveryMode(mode WALRecoveryMode)
- func (opts *Options) SetWALTtlSeconds(value uint64)
- func (opts *Options) SetWalDir(value string)
- func (opts *Options) SetWalSizeLimitMb(value uint64)
- func (opts *Options) SetWritableFileMaxBufferSize(value uint64)
- func (opts *Options) SetWriteBufferManager(wbm *WriteBufferManager)
- func (opts *Options) SetWriteBufferSize(value uint64)
- func (opts *Options) SkipCheckingSSTFileSizesOnDBOpen() bool
- func (opts *Options) SkipStatsUpdateOnDBOpen() bool
- func (opts *Options) ToggleTrackAndVerifyWALsInManifestFlag(v bool)
- func (opts *Options) TrackAndVerifyWALsInManifestFlag() bool
- func (opts *Options) UnorderedWrite() bool
- func (opts *Options) UseAdaptiveMutex() bool
- func (opts *Options) UseDirectIOForFlushAndCompaction() bool
- func (opts *Options) UseDirectReads() bool
- func (opts *Options) UseFsync() bool
- func (opts *Options) WriteDBIDToManifest(v bool)
- func (opts *Options) WriteIdentityFile(v bool)
- type PartialMerger
- type PerfContext
- type PerfLevel
- type PinnableSliceHandle
- type PrepopulateBlob
- type Range
- type RateLimiter
- type RateLimiterMode
- type ReadOptions
- func (opts *ReadOptions) Destroy()
- func (opts *ReadOptions) FillCache() bool
- func (opts *ReadOptions) GetBackgroundPurgeOnIteratorCleanup() bool
- func (opts *ReadOptions) GetDeadline() uint64
- func (opts *ReadOptions) GetIOTimeout() uint64
- func (opts *ReadOptions) GetMaxSkippableInternalKeys() uint64
- func (opts *ReadOptions) GetReadTier() ReadTier
- func (opts *ReadOptions) GetReadaheadSize() uint64
- func (opts *ReadOptions) GetTotalOrderSeek() bool
- func (opts *ReadOptions) IgnoreRangeDeletions() bool
- func (opts *ReadOptions) IsAsyncIO() bool
- func (opts *ReadOptions) PinData() bool
- func (opts *ReadOptions) PrefixSameAsStart() bool
- func (opts *ReadOptions) SetAsyncIO(value bool)
- func (opts *ReadOptions) SetAutoReadaheadSize(enable bool)
- func (opts *ReadOptions) SetBackgroundPurgeOnIteratorCleanup(value bool)
- func (opts *ReadOptions) SetDeadline(microseconds uint64)
- func (opts *ReadOptions) SetFillCache(value bool)
- func (opts *ReadOptions) SetIOTimeout(microseconds uint64)
- func (opts *ReadOptions) SetIgnoreRangeDeletions(value bool)
- func (opts *ReadOptions) SetIterStartTimestamp(ts []byte)
- func (opts *ReadOptions) SetIterateLowerBound(key []byte)
- func (opts *ReadOptions) SetIterateUpperBound(key []byte)
- func (opts *ReadOptions) SetMaxSkippableInternalKeys(value uint64)
- func (opts *ReadOptions) SetPinData(value bool)
- func (opts *ReadOptions) SetPrefixSameAsStart(value bool)
- func (opts *ReadOptions) SetReadTier(value ReadTier)
- func (opts *ReadOptions) SetReadaheadSize(value uint64)
- func (opts *ReadOptions) SetSnapshot(snap *Snapshot)
- func (opts *ReadOptions) SetTailing(value bool)
- func (opts *ReadOptions) SetTimestamp(ts []byte)
- func (opts *ReadOptions) SetTotalOrderSeek(value bool)
- func (opts *ReadOptions) SetVerifyChecksums(value bool)
- func (opts *ReadOptions) Tailing() bool
- func (opts *ReadOptions) VerifyChecksums() bool
- type ReadTier
- type RestoreOptions
- type SSTFileWriter
- func (w *SSTFileWriter) Add(key, value []byte) (err error)
- func (w *SSTFileWriter) Delete(key []byte) (err error)
- func (w *SSTFileWriter) DeleteRange(startKey, endKey []byte) (err error)
- func (w *SSTFileWriter) DeleteWithTS(key, ts []byte) (err error)
- func (w *SSTFileWriter) Destroy()
- func (w *SSTFileWriter) FileSize() (size uint64)
- func (w *SSTFileWriter) Finish() (err error)
- func (w *SSTFileWriter) Merge(key, value []byte) (err error)
- func (w *SSTFileWriter) Open(path string) (err error)
- func (w *SSTFileWriter) Put(key, value []byte) (err error)
- func (w *SSTFileWriter) PutWithTS(key, ts, value []byte) (err error)
- type ShareFilesNaming
- type Slice
- type SliceTransform
- type Slices
- type Snapshot
- type SstMetadata
- type StatisticsLevel
- type TickerType
- type Transaction
- func (transaction *Transaction) Commit() (err error)
- func (transaction *Transaction) Delete(key []byte) (err error)
- func (transaction *Transaction) DeleteCF(cf *ColumnFamilyHandle, key []byte) (err error)
- func (transaction *Transaction) Destroy()
- func (transaction *Transaction) Get(opts *ReadOptions, key []byte) (slice *Slice, err error)
- func (transaction *Transaction) GetForUpdate(opts *ReadOptions, key []byte) (slice *Slice, err error)
- func (transaction *Transaction) GetForUpdateWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
- func (transaction *Transaction) GetName() string
- func (transaction *Transaction) GetPinned(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
- func (transaction *Transaction) GetPinnedForUpdate(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
- func (transaction *Transaction) GetPinnedForUpdateWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
- func (transaction *Transaction) GetPinnedWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
- func (transaction *Transaction) GetSnapshot() *Snapshot
- func (transaction *Transaction) GetWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
- func (transaction *Transaction) GetWriteBatchWI() *WriteBatchWI
- func (transaction *Transaction) Merge(key, value []byte) (err error)
- func (transaction *Transaction) MergeCF(cf *ColumnFamilyHandle, key, value []byte) (err error)
- func (transaction *Transaction) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error)
- func (transaction *Transaction) MultiGetWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, error)
- func (transaction *Transaction) NewIterator(opts *ReadOptions) *Iterator
- func (transaction *Transaction) NewIteratorCF(opts *ReadOptions, cf *ColumnFamilyHandle) *Iterator
- func (transaction *Transaction) Prepare() (err error)
- func (transaction *Transaction) Put(key, value []byte) (err error)
- func (transaction *Transaction) PutCF(cf *ColumnFamilyHandle, key, value []byte) (err error)
- func (transaction *Transaction) RebuildFromWriteBatch(wb *WriteBatch) (err error)
- func (transaction *Transaction) RebuildFromWriteBatchWI(wb *WriteBatchWI) (err error)
- func (transaction *Transaction) Rollback() (err error)
- func (transaction *Transaction) RollbackToSavePoint() (err error)
- func (transaction *Transaction) SetCommitTimestamp(ts uint64)
- func (transaction *Transaction) SetName(name string) (err error)
- func (transaction *Transaction) SetReadTimestampForValidation(ts uint64)
- func (transaction *Transaction) SetSavePoint()
- type TransactionDB
- func (db *TransactionDB) Close()
- func (db *TransactionDB) CreateColumnFamily(opts *Options, name string) (handle *ColumnFamilyHandle, err error)
- func (db *TransactionDB) Delete(opts *WriteOptions, key []byte) (err error)
- func (db *TransactionDB) DeleteCF(opts *WriteOptions, cf *ColumnFamilyHandle, key []byte) (err error)
- func (db *TransactionDB) Flush(opts *FlushOptions) (err error)
- func (db *TransactionDB) FlushCF(cf *ColumnFamilyHandle, opts *FlushOptions) (err error)
- func (db *TransactionDB) FlushCFs(cfs []*ColumnFamilyHandle, opts *FlushOptions) (err error)
- func (db *TransactionDB) FlushWAL(sync bool) (err error)
- func (db *TransactionDB) Get(opts *ReadOptions, key []byte) (slice *Slice, err error)
- func (db *TransactionDB) GetBaseDB() *DB
- func (db *TransactionDB) GetCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
- func (db *TransactionDB) GetIntProperty(propName string) (value uint64, success bool)
- func (db *TransactionDB) GetPinned(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
- func (db *TransactionDB) GetPinnedWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
- func (db *TransactionDB) GetProperty(propName string) (value string)
- func (db *TransactionDB) Merge(opts *WriteOptions, key, value []byte) (err error)
- func (db *TransactionDB) MergeCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
- func (db *TransactionDB) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error)
- func (db *TransactionDB) MultiGetWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, error)
- func (db *TransactionDB) NewCheckpoint() (cp *Checkpoint, err error)
- func (db *TransactionDB) NewIterator(opts *ReadOptions) *Iterator
- func (db *TransactionDB) NewIteratorCF(opts *ReadOptions, cf *ColumnFamilyHandle) *Iterator
- func (db *TransactionDB) NewSnapshot() *Snapshot
- func (db *TransactionDB) Put(opts *WriteOptions, key, value []byte) (err error)
- func (db *TransactionDB) PutCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
- func (db *TransactionDB) ReleaseSnapshot(snapshot *Snapshot)
- func (db *TransactionDB) TransactionBegin(opts *WriteOptions, transactionOpts *TransactionOptions, ...) *Transaction
- func (db *TransactionDB) Write(opts *WriteOptions, batch *WriteBatch) (err error)
- type TransactionDBOptions
- func (opts *TransactionDBOptions) Destroy()
- func (opts *TransactionDBOptions) SetDefaultLockTimeout(defaultLockTimeout int64)
- func (opts *TransactionDBOptions) SetMaxNumLocks(maxNumLocks int64)
- func (opts *TransactionDBOptions) SetNumStripes(numStripes uint64)
- func (opts *TransactionDBOptions) SetTransactionLockTimeout(txnLockTimeout int64)
- type TransactionOptions
- func (opts *TransactionOptions) Destroy()
- func (opts *TransactionOptions) SetDeadlockDetect(value bool)
- func (opts *TransactionOptions) SetDeadlockDetectDepth(depth int64)
- func (opts *TransactionOptions) SetExpiration(expiration int64)
- func (opts *TransactionOptions) SetLockTimeout(lockTimeout int64)
- func (opts *TransactionOptions) SetMaxWriteBatchSize(size uint64)
- func (opts *TransactionOptions) SetSetSnapshot(value bool)
- func (opts *TransactionOptions) SetSkipPrepare(skip bool)
- type UniversalCompactionOptions
- func (opts *UniversalCompactionOptions) Destroy()
- func (opts *UniversalCompactionOptions) GetCompressionSizePercent() int
- func (opts *UniversalCompactionOptions) GetMaxMergeWidth() int
- func (opts *UniversalCompactionOptions) GetMaxSizeAmplificationPercent() int
- func (opts *UniversalCompactionOptions) GetMinMergeWidth() int
- func (opts *UniversalCompactionOptions) GetSizeRatio() int
- func (opts *UniversalCompactionOptions) GetStopStyle() UniversalCompactionStopStyle
- func (opts *UniversalCompactionOptions) SetCompressionSizePercent(value int)
- func (opts *UniversalCompactionOptions) SetMaxMergeWidth(value uint)
- func (opts *UniversalCompactionOptions) SetMaxSizeAmplificationPercent(value int)
- func (opts *UniversalCompactionOptions) SetMinMergeWidth(value int)
- func (opts *UniversalCompactionOptions) SetSizeRatio(value int)
- func (opts *UniversalCompactionOptions) SetStopStyle(value UniversalCompactionStopStyle)
- type UniversalCompactionStopStyle
- type WALRecoveryMode
- type WaitForCompactOptions
- func (w *WaitForCompactOptions) AbortOnPause() bool
- func (w *WaitForCompactOptions) CloseDB() bool
- func (w *WaitForCompactOptions) Destroy()
- func (w *WaitForCompactOptions) Flush() bool
- func (w *WaitForCompactOptions) GetTimeout() uint64
- func (w *WaitForCompactOptions) SetAbortOnPause(v bool)
- func (w *WaitForCompactOptions) SetCloseDB(v bool)
- func (w *WaitForCompactOptions) SetFlush(v bool)
- func (w *WaitForCompactOptions) SetTimeout(microseconds uint64)
- 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) DeleteCFWithTS(cf *ColumnFamilyHandle, key, ts []byte)
- func (wb *WriteBatch) DeleteRange(startKey, endKey []byte)
- func (wb *WriteBatch) DeleteRangeCF(cf *ColumnFamilyHandle, startKey, endKey []byte)
- func (wb *WriteBatch) Destroy()
- func (wb *WriteBatch) Merge(key, value []byte)
- func (wb *WriteBatch) MergeCF(cf *ColumnFamilyHandle, key, value []byte)
- func (wb *WriteBatch) NewIterator() *WriteBatchIterator
- func (wb *WriteBatch) PopSavePoint() (err error)
- func (wb *WriteBatch) Put(key, value []byte)
- func (wb *WriteBatch) PutCF(cf *ColumnFamilyHandle, key, value []byte)
- func (wb *WriteBatch) PutCFWithTS(cf *ColumnFamilyHandle, key, ts, value []byte)
- func (wb *WriteBatch) PutLogData(blob []byte)
- func (wb *WriteBatch) RollbackToSavePoint() (err error)
- func (wb *WriteBatch) SetSavePoint()
- func (wb *WriteBatch) SingleDelete(key []byte)
- func (wb *WriteBatch) SingleDeleteCF(cf *ColumnFamilyHandle, key []byte)
- func (wb *WriteBatch) SingleDeleteCFWithTS(cf *ColumnFamilyHandle, key, ts []byte)
- type WriteBatchIterator
- type WriteBatchRecord
- type WriteBatchRecordType
- type WriteBatchWI
- func (wb *WriteBatchWI) Clear()
- func (wb *WriteBatchWI) Count() int
- func (wb *WriteBatchWI) Data() []byte
- func (wb *WriteBatchWI) Delete(key []byte)
- func (wb *WriteBatchWI) DeleteCF(cf *ColumnFamilyHandle, key []byte)
- func (wb *WriteBatchWI) DeleteRange(startKey, endKey []byte)
- func (wb *WriteBatchWI) DeleteRangeCF(cf *ColumnFamilyHandle, startKey, endKey []byte)
- func (wb *WriteBatchWI) Destroy()
- func (wb *WriteBatchWI) Get(opts *Options, key []byte) (slice *Slice, err error)
- func (wb *WriteBatchWI) GetFromDB(db *DB, opts *ReadOptions, key []byte) (slice *Slice, err error)
- func (wb *WriteBatchWI) GetFromDBWithCF(db *DB, opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
- func (wb *WriteBatchWI) GetWithCF(opts *Options, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
- func (wb *WriteBatchWI) Merge(key, value []byte)
- func (wb *WriteBatchWI) MergeCF(cf *ColumnFamilyHandle, key, value []byte)
- func (wb *WriteBatchWI) NewIterator() *WriteBatchIterator
- func (wb *WriteBatchWI) NewIteratorWithBase(db *DB, baseIter *Iterator) *Iterator
- func (wb *WriteBatchWI) NewIteratorWithBaseCF(db *DB, baseIter *Iterator, cf *ColumnFamilyHandle) *Iterator
- func (wb *WriteBatchWI) Put(key, value []byte)
- func (wb *WriteBatchWI) PutCF(cf *ColumnFamilyHandle, key, value []byte)
- func (wb *WriteBatchWI) PutLogData(blob []byte)
- func (wb *WriteBatchWI) RollbackToSavePoint() (err error)
- func (wb *WriteBatchWI) SetSavePoint()
- func (wb *WriteBatchWI) SingleDelete(key []byte)
- func (wb *WriteBatchWI) SingleDeleteCF(cf *ColumnFamilyHandle, key []byte)
- type WriteBufferManager
- func (w *WriteBufferManager) BufferSize() int
- func (w *WriteBufferManager) CostToCache() bool
- func (w *WriteBufferManager) Destroy()
- func (w *WriteBufferManager) DummyEntriesInCacheUsage() int
- func (w *WriteBufferManager) Enabled() bool
- func (w *WriteBufferManager) MemoryUsage() int
- func (w *WriteBufferManager) MemtableMemoryUsage() int
- func (w *WriteBufferManager) SetBufferSize(size int)
- func (w *WriteBufferManager) ToggleAllowStall(v bool)
- type WriteOptions
- func (opts *WriteOptions) Destroy()
- func (opts *WriteOptions) DisableWAL(value bool)
- func (opts *WriteOptions) IgnoreMissingColumnFamilies() bool
- func (opts *WriteOptions) IsDisableWAL() bool
- func (opts *WriteOptions) IsLowPri() bool
- func (opts *WriteOptions) IsNoSlowdown() bool
- func (opts *WriteOptions) IsSync() bool
- func (opts *WriteOptions) MemtableInsertHintPerBatch() bool
- func (opts *WriteOptions) SetIgnoreMissingColumnFamilies(value bool)
- func (opts *WriteOptions) SetLowPri(value bool)
- func (opts *WriteOptions) SetMemtableInsertHintPerBatch(value bool)
- func (opts *WriteOptions) SetNoSlowdown(value bool)
- func (opts *WriteOptions) SetSync(value bool)
Constants ¶
const ( NoCompression = CompressionType(C.rocksdb_no_compression) SnappyCompression = CompressionType(C.rocksdb_snappy_compression) ZLibCompression = CompressionType(C.rocksdb_zlib_compression) Bz2Compression = CompressionType(C.rocksdb_bz2_compression) LZ4Compression = CompressionType(C.rocksdb_lz4_compression) LZ4HCCompression = CompressionType(C.rocksdb_lz4hc_compression) XpressCompression = CompressionType(C.rocksdb_xpress_compression) ZSTDCompression = CompressionType(C.rocksdb_zstd_compression) )
Compression types.
const ( LevelCompactionStyle = CompactionStyle(C.rocksdb_level_compaction) UniversalCompactionStyle = CompactionStyle(C.rocksdb_universal_compaction) FIFOCompactionStyle = CompactionStyle(C.rocksdb_fifo_compaction) )
Compaction styles.
const ( NoneCompactionAccessPattern = CompactionAccessPattern(0) NormalCompactionAccessPattern = CompactionAccessPattern(1) SequentialCompactionAccessPattern = CompactionAccessPattern(2) WillneedCompactionAccessPattern = CompactionAccessPattern(3) )
Access patterns for compaction.
const ( DebugInfoLogLevel = InfoLogLevel(0) InfoInfoLogLevel = InfoLogLevel(1) WarnInfoLogLevel = InfoLogLevel(2) ErrorInfoLogLevel = InfoLogLevel(3) FatalInfoLogLevel = InfoLogLevel(4) )
Log leves.
const ( // TolerateCorruptedTailRecordsRecovery is original levelDB recovery // We tolerate incomplete record in trailing data on all logs // Use case : This is legacy behavior TolerateCorruptedTailRecordsRecovery = WALRecoveryMode(0) // AbsoluteConsistencyRecovery recover from clean shutdown // We don't expect to find any corruption in the WAL // Use case : This is ideal for unit tests and rare applications that // can require high consistency guarantee AbsoluteConsistencyRecovery = WALRecoveryMode(1) // PointInTimeRecovery recover to point-in-time consistency (default) // We stop the WAL playback on discovering WAL inconsistency // Use case : Ideal for systems that have disk controller cache like // hard disk, SSD without super capacitor that store related data PointInTimeRecovery = WALRecoveryMode(2) // SkipAnyCorruptedRecordsRecovery recovery after a disaster // We ignore any corruption in the WAL and try to salvage as much data as // possible // Use case : Ideal for last ditch effort to recover data or systems that // operate with low grade unrelated data SkipAnyCorruptedRecordsRecovery = WALRecoveryMode(3) )
const ( // PrepopulateBlobDisable disables prepopulate blob cache. PrepopulateBlobDisable = PrepopulateBlob(0) // PrepopulateBlobFlushOnly prepopulates blobs during flush only. PrepopulateBlobFlushOnly = PrepopulateBlob(1) )
const ( KByCompensatedSizeCompactionPri CompactionPri = 0 KOldestLargestSeqFirstCompactionPri = 1 KOldestSmallestSeqFirstCompactionPri = 2 KMinOverlappingRatioCompactionPri = 3 KRoundRobinCompactionPri = 4 )
const ( // For compatibility, this value specifies to fallback to the behavior // indicated by the deprecated options, // `pin_l0_filter_and_index_blocks_in_cache` and // `pin_top_level_index_and_filter`. KFallbackPinningTier BlockBasedPinningTier = 0 // This tier contains no block-based tables. KNonePinningTier = 1 // This tier contains block-based tables that may have originated from a // memtable flush. In particular, it includes tables from L0 that are smaller // than 1.5 times the current `write_buffer_size`. Note these criteria imply // it can include intra-L0 compaction outputs and ingested files, as long as // they are not abnormally large compared to flushed files in L0. KFlushAndSimilarPinningTier = 2 // This tier contains all block-based tables. KAllPinningTier = 3 )
const ( CompactionStopStyleSimilarSize = UniversalCompactionStopStyle(C.rocksdb_similar_size_compaction_stop_style) CompactionStopStyleTotalSize = UniversalCompactionStopStyle(C.rocksdb_total_size_compaction_stop_style) )
Compaction stop style types.
const ( // ReadAllTier reads data in memtable, block cache, OS cache or storage. ReadAllTier = ReadTier(0) // BlockCacheTier reads data in memtable or block cache. BlockCacheTier = ReadTier(1) // PersistedTier reads data in memtable or block cache persisted data. // When WAL is disabled, this option will skip data in memtable. // Note that this ReadTier currently only supports Get and MultiGet and does not support iterators. PersistedTier = ReadTier(2) // MemtableTier reads data in memtable. Used for memtable-only iterators. MemtableTier = ReadTier(3) )
const ( // StatisticsLevelExceptTickers disable tickers. StatisticsLevelExceptTickers = StatisticsLevelDisableAll )
Variables ¶
var ErrColumnFamilyMustMatch = fmt.Errorf("must provide the same number of column family names and options")
ErrColumnFamilyMustMatch indicates number of column family names and options must match.
Functions ¶
func CloseBaseDBOfTransactionDB ¶ added in v1.8.4
func CloseBaseDBOfTransactionDB(db *DB)
CloseBaseDBOfTransactionDB closes base db of TransactionDB.
func DestroyDBPaths ¶
func DestroyDBPaths(dbpaths []*DBPath)
DestroyDBPaths deallocates all DBPath objects in dbpaths.
func ListColumnFamilies ¶
ListColumnFamilies lists the names of the column families in the DB.
func OpenDbAndTrimHistory ¶ added in v1.7.5
func OpenDbAndTrimHistory(opts *Options, name string, cfNames []string, cfOpts []*Options, trimTimestamp []byte, ) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
OpenDbAndTrimHistory opens DB and trim data newer than specified timestamp. The trim_ts specified the user-defined timestamp trim bound. This API should only be used at timestamp enabled column families recovery. If some input column families do not support timestamp, nothing will be happened to them. The data with timestamp > trim_ts will be removed after this API returns successfully.
func OpenDbAsSecondaryColumnFamilies ¶
func OpenDbAsSecondaryColumnFamilies( opts *Options, name string, secondaryPath string, cfNames []string, cfOpts []*Options, ) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
OpenDbAsSecondaryColumnFamilies opens database as secondary instance with column families. You can open a subset of column families in secondary mode. The `opts` specify the database specific options. The `name` argument specifies the name of the primary db that you have used to open the primary instance. The `secondaryPath` argument points to a directory where the secondary instance stores its info log. The `column_families` arguments specifieds a list of column families to open. If any of the column families does not exist, the function returns non-OK status.
func OpenDbColumnFamilies ¶
func OpenDbColumnFamilies( opts *Options, name string, cfNames []string, cfOpts []*Options, ) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
OpenDbColumnFamilies opens a database with the specified column families.
func OpenDbColumnFamiliesWithTTL ¶ added in v1.6.21
func OpenDbColumnFamiliesWithTTL( opts *Options, name string, cfNames []string, cfOpts []*Options, ttls []C.int, ) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
OpenDbColumnFamiliesWithTTL opens a database with the specified column families along with their ttls.
BEHAVIOUR: TTL is accepted in seconds (int32_t)Timestamp(creation) is suffixed to values in Put internally Expired TTL values deleted in compaction only:(Timestamp+ttl<time_now) Get/Iterator may return expired entries(compaction not run on them yet) Different TTL may be used during different Opens Example: Open1 at t=0 with ttl=4 and insert k1,k2, close at t=2 Open2 at t=3 with ttl=5. Now k1,k2 should be deleted at t>=5 read_only=true opens in the usual read-only mode. Compactions will not be triggered(neither manual nor automatic), so no expired entries removed
CONSTRAINTS: Not specifying/passing or non-positive TTL behaves like TTL = infinity
func OpenDbForReadOnlyColumnFamilies ¶
func OpenDbForReadOnlyColumnFamilies( opts *Options, name string, cfNames []string, cfOpts []*Options, errorIfWalFileExists bool, ) (db *DB, cfHandles []*ColumnFamilyHandle, err error)
OpenDbForReadOnlyColumnFamilies opens a database with the specified column families in read only mode.
func OpenOptimisticTransactionDbColumnFamilies ¶
func OpenOptimisticTransactionDbColumnFamilies( opts *Options, name string, cfNames []string, cfOpts []*Options, ) (db *OptimisticTransactionDB, cfHandles []*ColumnFamilyHandle, err error)
OpenOptimisticTransactionDbColumnFamilies opens a database with the specified column families.
func OpenTransactionDbColumnFamilies ¶
func OpenTransactionDbColumnFamilies( opts *Options, transactionDBOpts *TransactionDBOptions, name string, cfNames []string, cfOpts []*Options, ) (db *TransactionDB, cfHandles []*ColumnFamilyHandle, err error)
OpenTransactionDbColumnFamilies opens a database with the specified column families.
func SetPerfLevel ¶
func SetPerfLevel(level PerfLevel)
SetPerfLevel sets the perf stats level for current thread.
Types ¶
type BackupEngine ¶
type BackupEngine struct {
// contains filtered or unexported fields
}
BackupEngine is a reusable handle to a RocksDB Backup, created by OpenBackupEngine.
func CreateBackupEngine ¶ added in v1.6.22
func CreateBackupEngine(db *DB) (be *BackupEngine, err error)
CreateBackupEngine opens a backup engine from DB.
func CreateBackupEngineWithPath ¶ added in v1.7.8
func CreateBackupEngineWithPath(db *DB, path string) (be *BackupEngine, err error)
CreateBackupEngineWithPath opens a backup engine from DB and path
func OpenBackupEngine ¶
func OpenBackupEngine(opts *Options, path string) (be *BackupEngine, err error)
OpenBackupEngine opens a backup engine with specified options.
func OpenBackupEngineWithOpt ¶ added in v1.6.28
func OpenBackupEngineWithOpt(opts *BackupEngineOptions, env *Env) (be *BackupEngine, err error)
OpenBackupEngineWithOpt 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() (err error)
CreateNewBackup takes a new backup from db.
func (*BackupEngine) CreateNewBackupFlush ¶
func (b *BackupEngine) CreateNewBackupFlush(flushBeforeBackup bool) (err error)
CreateNewBackupFlush takes a new backup from db. Backup would be created after flushing.
func (*BackupEngine) GetInfo ¶
func (b *BackupEngine) GetInfo() (infos []BackupInfo)
GetInfo gets an object that gives information about the backups that have already been taken
func (*BackupEngine) PurgeOldBackups ¶
func (b *BackupEngine) PurgeOldBackups(numBackupsToKeep uint32) (err error)
PurgeOldBackups deletes old backups, where `numBackupsToKeep` is how many backups you’d like to keep.
func (*BackupEngine) RestoreDBFromBackup ¶ added in v1.6.21
func (b *BackupEngine) RestoreDBFromBackup(dbDir, walDir string, ro *RestoreOptions, backupID uint32) (err error)
RestoreDBFromBackup restores the backup (identified by its id) 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) (err 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) VerifyBackup ¶
func (b *BackupEngine) VerifyBackup(backupID uint32) (err error)
VerifyBackup verifies a backup by its id.
type BackupEngineOptions ¶ added in v1.7.0
type BackupEngineOptions struct {
// contains filtered or unexported fields
}
BackupEngineOptions represents options for backup engine.
func NewBackupableDBOptions ¶ added in v1.6.28
func NewBackupableDBOptions(backupDir string) *BackupEngineOptions
NewBackupableDBOptions
func (*BackupEngineOptions) BackupLogFiles ¶ added in v1.7.0
func (b *BackupEngineOptions) BackupLogFiles(flag bool)
BackupLogFiles if false, we won't backup log files. This option can be useful for backing up in-memory databases where log file are persisted, but table files are in memory.
Default: true
func (*BackupEngineOptions) Destroy ¶ added in v1.7.0
func (b *BackupEngineOptions) Destroy()
Destroy releases these options.
func (*BackupEngineOptions) DestroyOldData ¶ added in v1.7.0
func (b *BackupEngineOptions) DestroyOldData(flag bool)
DestroyOldData if true, it will delete whatever backups there are already
Default: false
func (*BackupEngineOptions) GetBackupRateLimit ¶ added in v1.7.0
func (b *BackupEngineOptions) GetBackupRateLimit() uint64
GetBackupRateLimit gets max bytes that can be transferred in a second during backup. If 0, go as fast as you can.
func (*BackupEngineOptions) GetCallbackTriggerIntervalSize ¶ added in v1.7.0
func (b *BackupEngineOptions) GetCallbackTriggerIntervalSize() uint64
GetCallbackTriggerIntervalSize gets size (N) during backup user can get callback every time next N bytes being copied.
func (*BackupEngineOptions) GetMaxBackgroundOperations ¶ added in v1.7.0
func (b *BackupEngineOptions) GetMaxBackgroundOperations() int
GetMaxBackgroundOperations gets max number of background threads will copy files for CreateNewBackup() and RestoreDBFromBackup()
func (*BackupEngineOptions) GetMaxValidBackupsToOpen ¶ added in v1.7.0
func (b *BackupEngineOptions) GetMaxValidBackupsToOpen() int
GetMaxValidBackupsToOpen gets max number of valid backup to open.
For BackupEngineReadOnly, Open() will open at most this many of the latest non-corrupted backups.
Note: this setting is ignored (behaves like INT_MAX) for any kind of writable BackupEngine because it would inhibit accounting for shared files for proper backup deletion, including purging any incompletely created backups on creation of a new backup.
func (*BackupEngineOptions) GetRestoreRateLimit ¶ added in v1.7.0
func (b *BackupEngineOptions) GetRestoreRateLimit() uint64
GetRestoreRateLimit gets max bytes that can be transferred in a second during restore. If 0, go as fast as you can
func (*BackupEngineOptions) GetShareFilesWithChecksumNaming ¶ added in v1.7.0
func (b *BackupEngineOptions) GetShareFilesWithChecksumNaming() ShareFilesNaming
GetShareFilesWithChecksumNaming gets naming option for share_files_with_checksum table files. See ShareFilesNaming for details.
func (*BackupEngineOptions) IsBackupLogFiles ¶ added in v1.7.0
func (b *BackupEngineOptions) IsBackupLogFiles() bool
IsBackupLogFiles if false, we won't backup log files. This option can be useful for backing up in-memory databases where log file are persisted, but table files are in memory.
func (*BackupEngineOptions) IsDestroyOldData ¶ added in v1.7.0
func (b *BackupEngineOptions) IsDestroyOldData() bool
IsDestroyOldData indicates if we should delete whatever backups there are already.
func (*BackupEngineOptions) IsShareTableFiles ¶ added in v1.7.0
func (b *BackupEngineOptions) IsShareTableFiles() bool
IsShareTableFiles returns if backup will assume that table files with same name have the same contents. This enables incremental backups and avoids unnecessary data copies.
If false, each backup will be on its own and will not share any data with other backups.
func (*BackupEngineOptions) IsSync ¶ added in v1.7.0
func (b *BackupEngineOptions) IsSync() bool
IsSync if true, we can guarantee you'll get consistent backup even on a machine crash/reboot. Backup process is slower with sync enabled.
If false, we don't guarantee anything on machine reboot. However, chances are some of the backups are consistent.
func (*BackupEngineOptions) SetBackupDir ¶ added in v1.7.0
func (b *BackupEngineOptions) SetBackupDir(dir string)
SetBackupDir sets where to keep the backup files. Has to be different than dbname_ Best to set this to dbname_ + "/backups".
func (*BackupEngineOptions) SetBackupRateLimit ¶ added in v1.7.0
func (b *BackupEngineOptions) SetBackupRateLimit(limit uint64)
SetBackupRateLimit sets max bytes that can be transferred in a second during backup. If 0, go as fast as you can.
Default: 0
func (*BackupEngineOptions) SetCallbackTriggerIntervalSize ¶ added in v1.7.0
func (b *BackupEngineOptions) SetCallbackTriggerIntervalSize(size uint64)
SetCallbackTriggerIntervalSize sets size (N) during backup user can get callback every time next N bytes being copied.
Default: N=4194304
func (*BackupEngineOptions) SetEnv ¶ added in v1.7.0
func (b *BackupEngineOptions) SetEnv(env *Env)
SetEnv to be used for backup file I/O. If it's nullptr, backups will be written out using DBs Env. If it's non-nullptr, backup's I/O will be performed using this object. If you want to have backups on HDFS, use HDFS Env here!
func (*BackupEngineOptions) SetMaxBackgroundOperations ¶ added in v1.7.0
func (b *BackupEngineOptions) SetMaxBackgroundOperations(v int)
SetMaxBackgroundOperations sets max number of background threads will copy files for CreateNewBackup() and RestoreDBFromBackup()
Default: 1
func (*BackupEngineOptions) SetMaxValidBackupsToOpen ¶ added in v1.7.0
func (b *BackupEngineOptions) SetMaxValidBackupsToOpen(val int)
SetMaxValidBackupsToOpen sets max number of valid backup to open.
For BackupEngineReadOnly, Open() will open at most this many of the latest non-corrupted backups.
Note: this setting is ignored (behaves like INT_MAX) for any kind of writable BackupEngine because it would inhibit accounting for shared files for proper backup deletion, including purging any incompletely created backups on creation of a new backup.
Default: INT_MAX
func (*BackupEngineOptions) SetRestoreRateLimit ¶ added in v1.7.0
func (b *BackupEngineOptions) SetRestoreRateLimit(limit uint64)
SetRestoreRateLimit sets max bytes that can be transferred in a second during restore. If 0, go as fast as you can
Default: 0
func (*BackupEngineOptions) SetShareFilesWithChecksumNaming ¶ added in v1.7.0
func (b *BackupEngineOptions) SetShareFilesWithChecksumNaming(val ShareFilesNaming)
SetShareFilesWithChecksumNaming sets naming option for share_files_with_checksum table files. See ShareFilesNaming for details.
Modifying this option cannot introduce a downgrade compatibility issue because RocksDB can read, restore, and delete backups using different file names, and it's OK for a backup directory to use a mixture of table file naming schemes.
However, modifying this option and saving more backups to the same directory can lead to the same file getting saved again to that directory, under the new shared name in addition to the old shared name.
Default: UseDBSessionID | FlagIncludeFileSize | FlagMatchInterimNaming
func (*BackupEngineOptions) SetSync ¶ added in v1.7.0
func (b *BackupEngineOptions) SetSync(flag bool)
SetSync if true, we can guarantee you'll get consistent backup even on a machine crash/reboot. Backup process is slower with sync enabled.
If false, we don't guarantee anything on machine reboot. However, chances are some of the backups are consistent.
Default: true
func (*BackupEngineOptions) ShareTableFiles ¶ added in v1.7.0
func (b *BackupEngineOptions) ShareTableFiles(flag bool)
ShareTableFiles if set to true, backup will assume that table files with same name have the same contents. This enables incremental backups and avoids unnecessary data copies.
If false, each backup will be on its own and will not share any data with other backups.
Default: true
type BackupInfo ¶ added in v1.6.22
BackupInfo represents the information about a backup.
type BlockBasedPinningTier ¶ added in v1.9.3
type BlockBasedPinningTier int
BlockBasedPinningTier is used to specify which tier of block-based tables should be affected by a block cache pinning setting.
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 (opts *BlockBasedTableOptions) Destroy()
Destroy deallocates the BlockBasedTableOptions object.
func (*BlockBasedTableOptions) SetBlockCache ¶
func (opts *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 auoptsmatically create and use an 8MB internal cache. Default: nil
func (*BlockBasedTableOptions) SetBlockRestartInterval ¶
func (opts *BlockBasedTableOptions) SetBlockRestartInterval(blockRestartInterval int)
SetBlockRestartInterval sets the number of keys between restart points for delta encoding of keys. This parameter can be changed dynamically. Most clients should leave this parameter alone. Default: 16
func (*BlockBasedTableOptions) SetBlockSize ¶
func (opts *BlockBasedTableOptions) SetBlockSize(blockSize int)
SetBlockSize sets the approximate size of user data packed per block. Note that the block size specified here corresponds opts 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 (opts *BlockBasedTableOptions) SetBlockSizeDeviation(blockSizeDeviation int)
SetBlockSizeDeviation sets the block size deviation. This is used opts 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 opts the block will exceed the configured block size, then this block will be closed and the new record will be written opts the next block. Default: 10
func (*BlockBasedTableOptions) SetCacheIndexAndFilterBlocks ¶
func (opts *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 (opts *BlockBasedTableOptions) SetCacheIndexAndFilterBlocksWithHighPriority(value bool)
SetCacheIndexAndFilterBlocksWithHighPriority if cache_index_and_filter_blocks is enabled, cache index and filter blocks with high priority. If set to true, depending on implementation of block cache, index and filter blocks may be less likely to be evicted than data blocks.
Default: true.
func (*BlockBasedTableOptions) SetChecksum ¶ added in v1.7.11
func (opts *BlockBasedTableOptions) SetChecksum(csType int8)
SetChecksum sets checksum types.
enum ChecksumType : char { kNoChecksum = 0x0, kCRC32c = 0x1, kxxHash = 0x2, kxxHash64 = 0x3, kXXH3 = 0x4, // Supported since RocksDB 6.27 };
func (*BlockBasedTableOptions) SetDataBlockHashRatio ¶ added in v1.6.17
func (opts *BlockBasedTableOptions) SetDataBlockHashRatio(value float64)
SetDataBlockHashRatio is valid only when data_block_hash_index_type is KDataBlockIndexTypeBinarySearchAndHash.
Default value: 0.75
func (*BlockBasedTableOptions) SetDataBlockIndexType ¶ added in v1.6.17
func (opts *BlockBasedTableOptions) SetDataBlockIndexType(value DataBlockIndexType)
SetDataBlockIndexType sets data block index type
func (*BlockBasedTableOptions) SetFilterPolicy ¶
func (opts *BlockBasedTableOptions) SetFilterPolicy(fp *NativeFilterPolicy)
SetFilterPolicy sets the filter policy opts reduce disk reads. Many applications will benefit from passing the result of NewBloomFilterPolicy() here.
Note: this op is `move`, fp is no longer usable.
Default: nil
func (*BlockBasedTableOptions) SetFormatVersion ¶
func (opts *BlockBasedTableOptions) SetFormatVersion(value int)
SetFormatVersion set format version. We currently have five options: 0 -- This version is currently written out by all RocksDB's versions by default. Can be read by really old RocksDB's. Doesn't support changing checksum (default is CRC32). 1 -- Can be read by RocksDB's versions since 3.0. Supports non-default checksum, like xxHash. It is written by RocksDB when BlockBasedTableOptions::checksum is something other than kCRC32c. (version 0 is silently upconverted) 2 -- Can be read by RocksDB's versions since 3.10. Changes the way we encode compressed blocks with LZ4, BZip2 and Zlib compression. If you don't plan to run RocksDB before version 3.10, you should probably use this. 3 -- Can be read by RocksDB's versions since 5.15. Changes the way we encode the keys in index blocks. If you don't plan to run RocksDB before version 5.15, you should probably use this. This option only affects newly written tables. When reading existing tables, the information about version is read from the footer. 4 -- Can be read by RocksDB's versions since 5.16. Changes the way we encode the values in index blocks. If you don't plan to run RocksDB before version 5.16 and you are using index_block_restart_interval > 1, you should probably use this as it would reduce the index size. This option only affects newly written tables. When reading existing tables, the information about version is read from the footer.
func (*BlockBasedTableOptions) SetIndexBlockRestartInterval ¶
func (opts *BlockBasedTableOptions) SetIndexBlockRestartInterval(value int)
SetIndexBlockRestartInterval same as block_restart_interval but used for the index block.
func (*BlockBasedTableOptions) SetIndexType ¶
func (opts *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 (opts *BlockBasedTableOptions) SetMetadataBlockSize(value uint64)
SetMetadataBlockSize sets block size for partitioned metadata. Currently applied to indexes when kTwoLevelIndexSearch is used and to filters when partition_filters is used. Note: Since in the current implementation the filters and index partitions are aligned, an index/filter block is created when either index or filter block size reaches the specified limit. Note: this limit is currently applied to only index blocks; a filter partition is cut right after an index block is cut.
func (*BlockBasedTableOptions) SetNoBlockCache ¶
func (opts *BlockBasedTableOptions) SetNoBlockCache(value bool)
SetNoBlockCache specify whether block cache should be used or not. Default: false
func (*BlockBasedTableOptions) SetOptimizeFiltersForMemory ¶ added in v1.7.16
func (opts *BlockBasedTableOptions) SetOptimizeFiltersForMemory(value bool)
SetOptimizeFiltersForMemory to generate Bloom/Ribbon filters that minimize memory internal fragmentation.
When false, malloc_usable_size is not available, or format_version < 5, filters are generated without regard to internal fragmentation when loaded into memory (historical behavior). When true (and malloc_usable_size is available and format_version >= 5), then filters are generated to "round up" and "round down" their sizes to minimize internal fragmentation when loaded into memory, assuming the reading DB has the same memory allocation characteristics as the generating DB. This option does not break forward or backward compatibility.
While individual filters will vary in bits/key and false positive rate when setting is true, the implementation attempts to maintain a weighted average FP rate for filters consistent with this option set to false.
With Jemalloc for example, this setting is expected to save about 10% of the memory footprint and block cache charge of filters, while increasing disk usage of filters by about 1-2% due to encoding efficiency losses with variance in bits/key.
NOTE: Because some memory counted by block cache might be unmapped pages within internal fragmentation, this option can increase observed RSS memory usage. With cache_index_and_filter_blocks=true, this option makes the block cache better at using space it is allowed. (These issues should not arise with partitioned filters.)
NOTE: Do not set to true if you do not trust malloc_usable_size. With this option, RocksDB might access an allocated memory object beyond its original size if malloc_usable_size says it is safe to do so. While this can be considered bad practice, it should not produce undefined behavior unless malloc_usable_size is buggy or broken.
Default: false
func (*BlockBasedTableOptions) SetPartitionFilters ¶
func (opts *BlockBasedTableOptions) SetPartitionFilters(value bool)
SetPartitionFilters use partitioned full filters for each SST file. This option is incompatible with block-based filters.
Note: currently this option requires kTwoLevelIndexSearch to be set as well.
func (*BlockBasedTableOptions) SetPartitionPinningTier ¶ added in v1.9.3
func (opts *BlockBasedTableOptions) SetPartitionPinningTier(tier BlockBasedPinningTier)
SetPartitionPinningTier sets the tier of block-based tables whose metadata partitions will be pinned. Currently indexes and filters may be partitioned.
func (*BlockBasedTableOptions) SetPinL0FilterAndIndexBlocksInCache ¶
func (opts *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.
func (*BlockBasedTableOptions) SetPinTopLevelIndexAndFilter ¶
func (opts *BlockBasedTableOptions) SetPinTopLevelIndexAndFilter(value bool)
SetPinTopLevelIndexAndFilter if cache_index_and_filter_blocks is true and the below is true, then the top-level index of partitioned 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. This is not limited to l0 in LSM tree.
Default: true.
func (*BlockBasedTableOptions) SetTopLevelIndexPinningTier ¶ added in v1.9.3
func (opts *BlockBasedTableOptions) SetTopLevelIndexPinningTier(tier BlockBasedPinningTier)
SetTopLevelIndexPinningTier sets the tier of block-based tables whose top-level index into metadata partitions will be pinned. Currently indexes and filters may be partitioned.
Note `cache_index_and_filter_blocks` must be true for this option to have any effect. Otherwise any top-level index into metadata partitions would be held in table reader memory, outside the block cache.
func (*BlockBasedTableOptions) SetUnpartitionedPinningTier ¶ added in v1.9.3
func (opts *BlockBasedTableOptions) SetUnpartitionedPinningTier(tier BlockBasedPinningTier)
SetUnpartitionedPinningTier sets the tier of block-based tables whose unpartitioned metadata blocks will be pinned.
Note `cache_index_and_filter_blocks` must be true for this option to have any effect. Otherwise the unpartitioned meta-blocks would be held in table reader memory, outside the block cache.
func (*BlockBasedTableOptions) SetUseDeltaEncoding ¶
func (opts *BlockBasedTableOptions) SetUseDeltaEncoding(value bool)
SetUseDeltaEncoding uses delta encoding to compress keys in blocks. ReadOptions::pin_data requires this option to be disabled.
Default: true
func (*BlockBasedTableOptions) SetWholeKeyFiltering ¶
func (opts *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 BottommostLevelCompaction ¶
type BottommostLevelCompaction byte
BottommostLevelCompaction for level based compaction, we can configure if we want to skip/force bottommost level compaction.
const ( // KSkip skip bottommost level compaction KSkip BottommostLevelCompaction = 0 // KIfHaveCompactionFilter only compact bottommost level if there is a compaction filter // This is the default option KIfHaveCompactionFilter BottommostLevelCompaction = 1 // KForce always compact bottommost level KForce BottommostLevelCompaction = 2 // KForceOptimized always compact bottommost level but in bottommost level avoid // double-compacting files created in the same compaction KForceOptimized BottommostLevelCompaction = 3 )
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 NewHyperClockCache ¶ added in v1.8.0
NewHyperClockCache creates a new hyper clock cache.
func NewHyperClockCacheWithOpts ¶ added in v1.8.0
func NewHyperClockCacheWithOpts(opt *HyperClockCacheOptions) *Cache
NewHyperClockCacheWithOpts creates a hyper clock cache with predefined options.
func NewLRUCache ¶
NewLRUCache creates a new LRU Cache object with the capacity given.
func NewLRUCacheWithOptions ¶ added in v1.6.37
func NewLRUCacheWithOptions(opt *LRUCacheOptions) *Cache
NewLRUCacheWithOptions creates a new LRU Cache from options.
func (*Cache) DisownData ¶ added in v1.6.36
func (c *Cache) DisownData()
Disowndata call this on shutdown if you want to speed it up. Cache will disown any underlying data and will not free it on delete. This call will leak memory - call this only if you're shutting down the process. Any attempts of using cache after this call will fail terribly. Always delete the DB object before calling this method!
func (*Cache) GetCapacity ¶ added in v1.6.21
GetCapacity returns capacity of the cache.
func (*Cache) GetPinnedUsage ¶
GetPinnedUsage returns the Cache pinned memory usage.
func (*Cache) SetCapacity ¶
SetCapacity sets capacity of the cache.
type Checkpoint ¶
type Checkpoint struct {
// contains filtered or unexported fields
}
Checkpoint provides persistent snapshots of RocksDB databases.
func (*Checkpoint) CreateCheckpoint ¶
func (checkpoint *Checkpoint) CreateCheckpoint(checkpointDir string, logSizeForFlush uint64) (err 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 log_size_for_flush: 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 (checkpoint *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 (*ColumnFamilyHandle) Destroy ¶
func (h *ColumnFamilyHandle) Destroy()
Destroy calls the destructor of the underlying column family handle.
func (*ColumnFamilyHandle) ID ¶ added in v1.7.11
func (h *ColumnFamilyHandle) ID() uint32
ID returned id of Column family.
func (*ColumnFamilyHandle) Name ¶ added in v1.7.11
func (h *ColumnFamilyHandle) Name() string
Name returned name of Column family.
type ColumnFamilyHandles ¶
type ColumnFamilyHandles []*ColumnFamilyHandle
ColumnFamilyHandles represents collection of multiple column family handle.
type ColumnFamilyMetadata ¶ added in v1.7.6
type ColumnFamilyMetadata struct {
// contains filtered or unexported fields
}
ColumnFamilyMetadata contains metadata info of column family.
func (*ColumnFamilyMetadata) FileCount ¶ added in v1.7.6
func (cm *ColumnFamilyMetadata) FileCount() int
FileCount returns number of files in this column family.
func (*ColumnFamilyMetadata) LevelMetas ¶ added in v1.7.6
func (cm *ColumnFamilyMetadata) LevelMetas() []LevelMetadata
LevelMetas returns metadata(s) of each level.
func (*ColumnFamilyMetadata) Name ¶ added in v1.7.6
func (cm *ColumnFamilyMetadata) Name() string
Name returns name of this column family.
func (*ColumnFamilyMetadata) Size ¶ added in v1.7.6
func (cm *ColumnFamilyMetadata) Size() uint64
GetSize returns size of this column family in bytes, which is equal to the sum of the file size of its "levels".
type CompactRangeOptions ¶
type CompactRangeOptions struct {
// contains filtered or unexported fields
}
CompactRangeOptions represent all of the available options for compact range.
func NewCompactRangeOptions ¶
func NewCompactRangeOptions() *CompactRangeOptions
NewCompactRangeOptions creates new compact range options.
func (*CompactRangeOptions) BottommostLevelCompaction ¶ added in v1.6.21
func (opts *CompactRangeOptions) BottommostLevelCompaction() BottommostLevelCompaction
BottommostLevelCompaction returns if bottommost level compaction feature is turned on.
func (*CompactRangeOptions) ChangeLevel ¶ added in v1.6.21
func (opts *CompactRangeOptions) ChangeLevel() bool
ChangeLevel if true, compacted files will be moved to the minimum level capable of holding the data or given level (specified non-negative target_level).
func (*CompactRangeOptions) Destroy ¶
func (opts *CompactRangeOptions) Destroy()
Destroy deallocates the CompactionOptions object.
func (*CompactRangeOptions) GetExclusiveManualCompaction ¶ added in v1.6.21
func (opts *CompactRangeOptions) GetExclusiveManualCompaction() bool
GetExclusiveManualCompaction returns if exclusive manual compaction is turned on.
func (*CompactRangeOptions) SetBottommostLevelCompaction ¶
func (opts *CompactRangeOptions) SetBottommostLevelCompaction(value BottommostLevelCompaction)
SetBottommostLevelCompaction sets bottommost level compaction.
Default: KIfHaveCompactionFilter
func (*CompactRangeOptions) SetChangeLevel ¶
func (opts *CompactRangeOptions) SetChangeLevel(value bool)
SetChangeLevel if true, compacted files will be moved to the minimum level capable of holding the data or given level (specified non-negative target_level).
func (*CompactRangeOptions) SetExclusiveManualCompaction ¶
func (opts *CompactRangeOptions) SetExclusiveManualCompaction(value bool)
SetExclusiveManualCompaction if more than one thread calls manual compaction, only one will actually schedule it while the other threads will simply wait for the scheduled manual compaction to complete. If exclusive_manual_compaction is set to true, the call will disable scheduling of automatic compaction jobs and wait for existing automatic compaction jobs to finish.
Default: true
func (*CompactRangeOptions) SetFullHistoryTsLow ¶ added in v1.7.5
func (opts *CompactRangeOptions) SetFullHistoryTsLow(ts []byte)
SetFullHistoryTsLow user-defined timestamp low bound, the data with older timestamp than low bound maybe GCed by compaction. Default: nullptr
func (*CompactRangeOptions) SetTargetLevel ¶
func (opts *CompactRangeOptions) SetTargetLevel(value int32)
SetTargetLevel if change_level is true and target_level have non-negative value, compacted files will be moved to target_level.
Default: -1 - dynamically
func (*CompactRangeOptions) TargetLevel ¶ added in v1.6.21
func (opts *CompactRangeOptions) TargetLevel() int32
TargetLevel returns target level.
type CompactionAccessPattern ¶
type CompactionAccessPattern uint
CompactionAccessPattern specifies the access patern in compaction.
type CompactionFilter ¶
type CompactionFilter interface { // If the Filter function returns false, it indicates // that the kv should be preserved, while a return value of true // indicates that this key-value should be removed from the // output of the compaction. The application can inspect // the existing value of the key and make decision based on it. // // When the value is to be preserved, the application has the option // to modify the existing value and pass it back through a new value. // To retain the previous value, simply return nil // // If multithreaded compaction is being used *and* a single CompactionFilter // instance was supplied via SetCompactionFilter, this the Filter function may be // called from different threads concurrently. The application must ensure // that the call is thread-safe. Filter(level int, key, val []byte) (remove bool, newVal []byte) // The name of the compaction filter, for logging Name() string // SetIgnoreSnapshots before release 6.0, if there is a snapshot taken later than // the key/value pair, RocksDB always try to prevent the key/value pair from being // filtered by compaction filter so that users can preserve the same view from a // snapshot, unless the compaction filter returns IgnoreSnapshots() = true. However, // this feature is deleted since 6.0, after realized that the feature has a bug which // can't be easily fixed. Since release 6.0, with compaction filter enabled, RocksDB // always invoke filtering for any key, even if it knows it will make a snapshot // not repeatable. SetIgnoreSnapshots(value bool) // Destroy underlying pointer/data. Destroy() }
A CompactionFilter can be used to filter keys during compaction time.
func NewNativeCompactionFilter ¶
func NewNativeCompactionFilter(c unsafe.Pointer) CompactionFilter
NewNativeCompactionFilter creates a CompactionFilter object.
type CompactionPri ¶ added in v1.9.3
type CompactionPri int
CompactionPri is in Level-based compaction, it Determines which file from a level to be picked to merge to the next level. We suggest people try KMinOverlappingRatio first when you tune your database.
type Comparator ¶
type Comparator struct {
// contains filtered or unexported fields
}
NativeComparator wraps c-comparator pointer.
func NewComparator ¶ added in v1.6.47
func NewComparator(name string, compare Comparing) *Comparator
NewComparator creates a Comparator object which contains native c-comparator pointer.
func NewComparatorWithTimestamp ¶ added in v1.7.5
func NewComparatorWithTimestamp(name string, tsSize uint64, compare, compareTs Comparing, compareWithoutTs ComparingWithoutTimestamp) *Comparator
NewComparatorWithTimestamp creates a Timestamp Aware Comparator object which contains native c-comparator pointer.
func (*Comparator) Compare ¶
func (c *Comparator) Compare(a, b []byte) int
func (*Comparator) CompareTimestamp ¶ added in v1.7.5
func (c *Comparator) CompareTimestamp(a, b []byte) int
func (*Comparator) CompareWithoutTimestamp ¶ added in v1.7.5
func (*Comparator) Destroy ¶
func (c *Comparator) Destroy()
func (*Comparator) Name ¶
func (c *Comparator) Name() string
func (*Comparator) TimestampSize ¶ added in v1.7.5
func (c *Comparator) TimestampSize() uint64
type Comparing ¶ added in v1.6.47
Comparing functor.
Three-way comparison. Returns value:
< 0 iff "a" < "b", == 0 iff "a" == "b", > 0 iff "a" > "b"
Note that Compare(a, b) also compares timestamp if timestamp size is non-zero. For the same user key with different timestamps, larger (newer) timestamp comes first.
type ComparingWithoutTimestamp ¶ added in v1.7.5
ComparingWithoutTimestamp functor.
Three-way comparison. Returns value:
< 0 if "a" < "b", == 0 if "a" == "b", > 0 if "a" > "b"
type CompressionOptions ¶
CompressionOptions represents options for different compression algorithms like Zlib.
func NewCompressionOptions ¶
func NewCompressionOptions(windowBits, level, strategy, maxDictBytes int) CompressionOptions
NewCompressionOptions creates a CompressionOptions object.
func NewDefaultCompressionOptions ¶
func NewDefaultCompressionOptions() CompressionOptions
NewDefaultCompressionOptions creates a default CompressionOptions object.
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 CuckooTableOptions ¶
type CuckooTableOptions struct {
// contains filtered or unexported fields
}
CuckooTableOptions are options for cuckoo table.
func NewCuckooTableOptions ¶
func NewCuckooTableOptions() *CuckooTableOptions
NewCuckooTableOptions returns new cuckoo table options.
func (*CuckooTableOptions) SetCuckooBlockSize ¶
func (opts *CuckooTableOptions) SetCuckooBlockSize(value uint32)
SetCuckooBlockSize in case of collision while inserting, the builder attempts to insert in the next cuckoo_block_size locations before skipping over to the next Cuckoo hash function. This makes lookups more cache friendly in case of collisions.
Default: 5.
func (*CuckooTableOptions) SetHashRatio ¶
func (opts *CuckooTableOptions) SetHashRatio(value float64)
SetHashRatio determines the utilization of hash tables. Smaller values result in larger hash tables with fewer collisions.
Default: 0.9.
func (*CuckooTableOptions) SetIdentityAsFirstHash ¶
func (opts *CuckooTableOptions) SetIdentityAsFirstHash(value bool)
SetIdentityAsFirstHash if this option is enabled, user key is treated as uint64_t and its value is used as hash value directly. This option changes builder's behavior. Reader ignore this option and behave according to what specified in table property.
Default: false.
func (*CuckooTableOptions) SetMaxSearchDepth ¶
func (opts *CuckooTableOptions) SetMaxSearchDepth(value uint32)
SetMaxSearchDepth property used by builder to determine the depth to go to to search for a path to displace elements in case of collision. See Builder.MakeSpaceForKey method. Higher values result in more efficient hash tables with fewer lookups but take more time to build.
Default: 100.
func (*CuckooTableOptions) SetUseModuleHash ¶
func (opts *CuckooTableOptions) SetUseModuleHash(value bool)
SetUseModuleHash if this option is set to true, module is used during hash calculation. This often yields better space efficiency at the cost of performance. If this option is set to false, # of entries in table is constrained to be power of two, and bit and is used to calculate hash, which is faster in general.
Default: true
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a reusable handle to a RocksDB database on disk, created by Open.
func OpenDbAsSecondary ¶
OpenDbAsSecondary creates a secondary instance that can dynamically tail the MANIFEST of a primary that must have already been created. User can call TryCatchUpWithPrimary to make the secondary instance catch up with primary (WAL tailing is NOT supported now) whenever the user feels necessary. Column families created by the primary after the secondary instance starts are currently ignored by the secondary instance. Column families opened by secondary and dropped by the primary will be dropped by secondary as well. However the user of the secondary instance can still access the data of such dropped column family as long as they do not destroy the corresponding column family handle. WAL tailing is not supported at present, but will arrive soon.
func OpenDbForReadOnly ¶
OpenDbForReadOnly opens a database with the specified options for readonly usage.
func OpenDbWithTTL ¶
OpenDbWithTTL opens a database with TTL support with the specified options.
func (*DB) CancelAllBackgroundWork ¶ added in v1.6.20
CancelAllBackgroundWork requests stopping background work, if wait is true wait until it's done
func (*DB) CompactRange ¶
CompactRange runs a manual compaction on the Range of keys given. This is not likely to be needed for typical usage.
func (*DB) CompactRangeCF ¶
func (db *DB) CompactRangeCF(cf *ColumnFamilyHandle, r Range)
CompactRangeCF runs a manual compaction on the Range of keys given on the given column family. This is not likely to be needed for typical usage.
func (*DB) CompactRangeCFOpt ¶
func (db *DB) CompactRangeCFOpt(cf *ColumnFamilyHandle, r Range, opt *CompactRangeOptions)
CompactRangeCFOpt runs a manual compaction on the Range of keys given on the given column family with provided options. This is not likely to be needed for typical usage.
func (*DB) CompactRangeOpt ¶
func (db *DB) CompactRangeOpt(r Range, opt *CompactRangeOptions)
CompactRangeOpt runs a manual compaction on the Range of keys given with provided options. This is not likely to be needed for typical usage.
func (*DB) CreateColumnFamilies ¶ added in v1.8.4
func (db *DB) CreateColumnFamilies(opts *Options, names []string) (handles []*ColumnFamilyHandle, err error)
CreateColumnFamilies creates new column families.
func (*DB) CreateColumnFamily ¶
func (db *DB) CreateColumnFamily(opts *Options, name string) (handle *ColumnFamilyHandle, err error)
CreateColumnFamily create a new column family.
func (*DB) CreateColumnFamilyWithTTL ¶ added in v1.6.21
func (db *DB) CreateColumnFamilyWithTTL(opts *Options, name string, ttl int) (handle *ColumnFamilyHandle, err error)
CreateColumnFamilyWithTTL create a new column family along with its ttl.
BEHAVIOUR: TTL is accepted in seconds (int32_t)Timestamp(creation) is suffixed to values in Put internally Expired TTL values deleted in compaction only:(Timestamp+ttl<time_now) Get/Iterator may return expired entries(compaction not run on them yet) Different TTL may be used during different Opens Example: Open1 at t=0 with ttl=4 and insert k1,k2, close at t=2 Open2 at t=3 with ttl=5. Now k1,k2 should be deleted at t>=5 read_only=true opens in the usual read-only mode. Compactions will not be triggered(neither manual nor automatic), so no expired entries removed
CONSTRAINTS: Not specifying/passing or non-positive TTL behaves like TTL = infinity
func (*DB) Delete ¶
func (db *DB) Delete(opts *WriteOptions, key []byte) (err error)
Delete removes the data associated with the key from the database.
func (*DB) DeleteCF ¶
func (db *DB) DeleteCF(opts *WriteOptions, cf *ColumnFamilyHandle, key []byte) (err error)
DeleteCF removes the data associated with the key from the database and column family.
func (*DB) DeleteCFWithTS ¶ added in v1.7.5
func (db *DB) DeleteCFWithTS(opts *WriteOptions, cf *ColumnFamilyHandle, key, ts []byte) (err error)
DeleteCFWithTS removes the data associated with the key and timestamp from the database and column family.
func (*DB) DeleteFile ¶
DeleteFile deletes the file name from the db directory and update the internal state to reflect that. Supports deletion of sst and log files only. 'name' must be path relative to the db directory. eg. 000001.sst, /archive/000003.log.
func (*DB) DeleteFileInRange ¶
DeleteFileInRange deletes SST files that contain keys between the Range, [r.Start, r.Limit]
func (*DB) DeleteFileInRangeCF ¶
func (db *DB) DeleteFileInRangeCF(cf *ColumnFamilyHandle, r Range) (err error)
DeleteFileInRangeCF deletes SST files that contain keys between the Range, [r.Start, r.Limit], and belong to a given column family
func (*DB) DeleteRangeCF ¶ added in v1.6.17
func (db *DB) DeleteRangeCF(opts *WriteOptions, cf *ColumnFamilyHandle, startKey, endKey []byte) (err error)
DeleteRangeCF deletes keys that are between [startKey, endKey)
func (*DB) DeleteWithTS ¶ added in v1.7.5
func (db *DB) DeleteWithTS(opts *WriteOptions, key, ts []byte) (err error)
DeleteWithTS removes the data associated with the key and timestamp from the database.
func (*DB) DisableFileDeletions ¶
DisableFileDeletions disables file deletions and should be used when backup the database.
func (*DB) DisableManualCompaction ¶ added in v1.7.5
func (db *DB) DisableManualCompaction()
DisableManualCompaction disables manual compaction.
func (*DB) DropColumnFamily ¶
func (db *DB) DropColumnFamily(c *ColumnFamilyHandle) (err error)
DropColumnFamily drops a column family.
func (*DB) EnableFileDeletions ¶
EnableFileDeletions enables file deletions for the database.
func (*DB) EnableManualCompaction ¶ added in v1.7.5
func (db *DB) EnableManualCompaction()
EnableManualCompaction enables manual compaction.
func (*DB) Flush ¶
func (db *DB) Flush(opts *FlushOptions) (err error)
Flush triggers a manual flush for the database.
func (*DB) FlushCF ¶
func (db *DB) FlushCF(cf *ColumnFamilyHandle, opts *FlushOptions) (err error)
FlushCF triggers a manual flush for the database on specific column family.
func (*DB) FlushCFs ¶ added in v1.8.0
func (db *DB) FlushCFs(cfs []*ColumnFamilyHandle, opts *FlushOptions) (err error)
FlushCFs triggers a manual flush for the database on specific column families.
func (*DB) FlushWAL ¶ added in v1.6.37
FlushWAL flushes the WAL memory buffer to the file. If sync is true, it calls SyncWAL afterwards.
func (*DB) Get ¶
func (db *DB) Get(opts *ReadOptions, key []byte) (slice *Slice, err error)
Get returns the data associated with the key from the database.
func (*DB) GetApproximateSizes ¶
GetApproximateSizes returns the approximate number of bytes of file system space used by one or more key ranges.
The keys counted will begin at Range.Start and end on the key before Range.Limit.
func (*DB) GetApproximateSizesCF ¶
func (db *DB) GetApproximateSizesCF(cf *ColumnFamilyHandle, ranges []Range) ([]uint64, error)
GetApproximateSizesCF returns the approximate number of bytes of file system space used by one or more key ranges in the column family.
The keys counted will begin at Range.Start and end on the key before Range.Limit.
func (*DB) GetBytes ¶
func (db *DB) GetBytes(opts *ReadOptions, key []byte) (data []byte, err error)
GetBytes is like Get but returns a copy of the data.
func (*DB) GetBytesWithTS ¶ added in v1.7.5
func (db *DB) GetBytesWithTS(opts *ReadOptions, key []byte) (data, timestamp []byte, err error)
GetBytesWithTS is like Get but returns a copy of the data and timestamp.
func (*DB) GetCF ¶
func (db *DB) GetCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
GetCF returns the data associated with the key from the database and column family.
func (*DB) GetCFWithTS ¶ added in v1.7.5
func (db *DB) GetCFWithTS(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (value, timestamp *Slice, err error)
GetCFWithTS returns the data and timestamp associated with the key from the database and column family.
func (*DB) GetColumnFamilyMetadata ¶ added in v1.7.6
func (db *DB) GetColumnFamilyMetadata() (m *ColumnFamilyMetadata)
GetColumnFamilyMetadata returns the metadata of the default column family.
func (*DB) GetColumnFamilyMetadataCF ¶ added in v1.7.6
func (db *DB) GetColumnFamilyMetadataCF(cf *ColumnFamilyHandle) (m *ColumnFamilyMetadata)
GetColumnFamilyMetadataCF returns the metadata of the specified column family.
func (*DB) GetDefaultColumnFamily ¶ added in v1.9.5
func (db *DB) GetDefaultColumnFamily() *ColumnFamilyHandle
GetDefaultColumnFamily gets default column family handle.
func (*DB) GetFullHistoryTsLow ¶ added in v1.7.5
func (db *DB) GetFullHistoryTsLow(handle *ColumnFamilyHandle) (slice *Slice, err error)
GetFullHistoryTsLow returns current full_history_ts value.
func (*DB) GetIntProperty ¶
GetIntProperty similar to `GetProperty`, but only works for a subset of properties whose return value is an integer. Return the value by integer.
func (*DB) GetIntPropertyCF ¶
func (db *DB) GetIntPropertyCF(propName string, cf *ColumnFamilyHandle) (value uint64, success bool)
GetIntPropertyCF similar to `GetProperty`, but only works for a subset of properties whose return value is an integer. Return the value by integer.
func (*DB) GetLatestSequenceNumber ¶
GetLatestSequenceNumber returns sequence number of the most recent transaction.
func (*DB) GetLiveFilesMetaData ¶
func (db *DB) GetLiveFilesMetaData() []LiveFileMetadata
GetLiveFilesMetaData returns a list of all table files with their level, start key and end key.
func (*DB) GetPinned ¶
func (db *DB) GetPinned(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
GetPinned returns the data associated with the key from the database.
func (*DB) GetPinnedCF ¶
func (db *DB) GetPinnedCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
GetPinnedCF returns the data associated with the key from the database, specific column family.
func (*DB) GetProperty ¶
GetProperty returns the value of a database property.
func (*DB) GetPropertyCF ¶
func (db *DB) GetPropertyCF(propName string, cf *ColumnFamilyHandle) (value string)
GetPropertyCF returns the value of a database property.
func (*DB) GetUpdatesSince ¶
func (db *DB) GetUpdatesSince(seqNumber uint64) (iter *WalIterator, err error)
GetUpdatesSince if the sequence number is non existent, it returns an iterator at the first available seq_no after the requested seq_no.
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.
Note: this API is not yet consistent with WritePrepared transactions. Sets iter to an iterator that is positioned at a write-batch containing seq_number.
func (*DB) GetWithTS ¶ added in v1.7.5
func (db *DB) GetWithTS(opts *ReadOptions, key []byte) (value, timestamp *Slice, err error)
GetWithTS returns the data and timestamp associated with the key from the database.
func (*DB) IncreaseFullHistoryTsLow ¶ added in v1.7.5
func (db *DB) IncreaseFullHistoryTsLow(handle *ColumnFamilyHandle, ts []byte) (err error)
IncreaseFullHistoryTsLow increases the full_history_ts of column family. The new ts_low value should be newer than current full_history_ts value. If another thread updates full_history_ts_low concurrently to a higher timestamp than the requested ts_low, a try again error will be returned.
func (*DB) IngestExternalFile ¶
func (db *DB) IngestExternalFile(filePaths []string, opts *IngestExternalFileOptions) (err error)
IngestExternalFile loads a list of external SST files.
func (*DB) IngestExternalFileCF ¶
func (db *DB) IngestExternalFileCF(handle *ColumnFamilyHandle, filePaths []string, opts *IngestExternalFileOptions) (err error)
IngestExternalFileCF loads a list of external SST files for a column family.
func (*DB) KeyMayExists ¶ added in v1.6.21
func (db *DB) KeyMayExists(opts *ReadOptions, key []byte, timestamp string) (slice *Slice)
KeyMayExists the value is only allocated (using malloc) and returned if it is found and value_found isn't NULL. In that case the user is responsible for freeing it.
func (*DB) KeyMayExistsCF ¶ added in v1.6.21
func (db *DB) KeyMayExistsCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte, timestamp string) (slice *Slice)
KeyMayExistsCF the value is only allocated (using malloc) and returned if it is found and value_found isn't NULL. In that case the user is responsible for freeing it.
func (*DB) Merge ¶
func (db *DB) Merge(opts *WriteOptions, key, value []byte) (err error)
Merge merges the data associated with the key with the actual data in the database.
func (*DB) MergeCF ¶
func (db *DB) MergeCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
MergeCF merges the data associated with the key with the actual data in the database and column family.
func (*DB) MultiGet ¶
func (db *DB) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error)
MultiGet returns the data associated with the passed keys from the database
func (*DB) MultiGetCF ¶
func (db *DB) MultiGetCF(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, error)
MultiGetCF returns the data associated with the passed keys from the column family
func (*DB) MultiGetCFMultiCF ¶
func (db *DB) MultiGetCFMultiCF(opts *ReadOptions, cfs ColumnFamilyHandles, keys [][]byte) (Slices, error)
MultiGetCFMultiCF returns the data associated with the passed keys and column families.
func (*DB) MultiGetCFWithTS ¶ added in v1.7.5
func (db *DB) MultiGetCFWithTS(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, Slices, error)
MultiGetCFWithTS returns the data and timestamp associated with the passed keys from the column family
func (*DB) MultiGetMultiCFWithTS ¶ added in v1.7.5
func (db *DB) MultiGetMultiCFWithTS(opts *ReadOptions, cfs ColumnFamilyHandles, keys [][]byte) (Slices, Slices, error)
MultiGetMultiCFWithTS returns the data and timestamp associated with the passed keys and column families.
func (*DB) MultiGetWithTS ¶ added in v1.7.5
MultiGetWithTS returns the data and timestamps associated with the passed keys from the database
func (*DB) NewCheckpoint ¶
func (db *DB) NewCheckpoint() (cp *Checkpoint, err error)
NewCheckpoint creates a new Checkpoint for this db.
func (*DB) NewIterator ¶
func (db *DB) NewIterator(opts *ReadOptions) *Iterator
NewIterator returns an Iterator over the the database that uses the ReadOptions given.
func (*DB) NewIteratorCF ¶
func (db *DB) NewIteratorCF(opts *ReadOptions, cf *ColumnFamilyHandle) *Iterator
NewIteratorCF returns an Iterator over the the database and column family that uses the ReadOptions given.
func (*DB) NewIterators ¶
func (db *DB) NewIterators(opts *ReadOptions, cfs []*ColumnFamilyHandle) (iters []*Iterator, err error)
NewIterators returns iterators from a consistent database state across multiple column families. Iterators are heap allocated and need to be deleted before the db is deleted
func (*DB) NewSnapshot ¶
NewSnapshot creates a new snapshot of the database.
func (*DB) Put ¶
func (db *DB) Put(opts *WriteOptions, key, value []byte) (err error)
Put writes data associated with a key to the database.
func (*DB) PutCF ¶
func (db *DB) PutCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
PutCF writes data associated with a key to the database and column family.
func (*DB) PutCFWithTS ¶ added in v1.7.5
func (db *DB) PutCFWithTS(opts *WriteOptions, cf *ColumnFamilyHandle, key, ts, value []byte) (err error)
PutCFWithTS writes data associated with a key and timestamp to the database and column family.
func (*DB) PutWithTS ¶ added in v1.7.5
func (db *DB) PutWithTS(opts *WriteOptions, key, ts, value []byte) (err error)
PutWithTS writes data associated with a key and timestamp to the database.
func (*DB) ReleaseSnapshot ¶
ReleaseSnapshot releases the snapshot and its resources.
func (*DB) SetOptions ¶
SetOptions dynamically changes options through the SetOptions API.
func (*DB) SetOptionsCF ¶
func (db *DB) SetOptionsCF(cf *ColumnFamilyHandle, keys, values []string) (err error)
SetOptionsCF dynamically changes options through the SetOptions API for specific Column Family.
func (*DB) SingleDelete ¶ added in v1.7.5
func (db *DB) SingleDelete(opts *WriteOptions, key []byte) (err error)
SingleDelete removes the database entry for "key". Requires that the key exists and was not overwritten. Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
If a key is overwritten (by calling Put() multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.
Note: consider setting options.sync = true.
func (*DB) SingleDeleteCF ¶ added in v1.7.5
func (db *DB) SingleDeleteCF(opts *WriteOptions, cf *ColumnFamilyHandle, key []byte) (err error)
SingleDeleteCF removes the database entry for "key". Requires that the key exists and was not overwritten. Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
If a key is overwritten (by calling Put() multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.
Note: consider setting options.sync = true.
func (*DB) SingleDeleteCFWithTS ¶ added in v1.7.5
func (db *DB) SingleDeleteCFWithTS(opts *WriteOptions, cf *ColumnFamilyHandle, key, ts []byte) (err error)
SingleDeleteCFWithTS removes the data associated with the key and timestamp from the database and column family.
func (*DB) SingleDeleteWithTS ¶ added in v1.7.5
func (db *DB) SingleDeleteWithTS(opts *WriteOptions, key, ts []byte) (err error)
SingleDeleteWithTS removes the data associated with the key and timestamp from the database.
func (*DB) SuggestCompactRange ¶ added in v1.7.6
SuggestCompactRange only for leveled compaction.
func (*DB) SuggestCompactRangeCF ¶ added in v1.7.6
func (db *DB) SuggestCompactRangeCF(cf *ColumnFamilyHandle, r Range) (err error)
SuggestCompactRangeCF only for leveled compaction.
func (*DB) TryCatchUpWithPrimary ¶
TryCatchUpWithPrimary to make the secondary instance catch up with primary (WAL tailing is NOT supported now) whenever the user feels necessary. Column families created by the primary after the secondary instance starts are currently ignored by the secondary instance. Column families opened by secondary and dropped by the primary will be dropped by secondary as well. However the user of the secondary instance can still access the data of such dropped column family as long as they do not destroy the corresponding column family handle. WAL tailing is not supported at present, but will arrive soon.
func (*DB) WaitForCompact ¶ added in v1.8.8
func (db *DB) WaitForCompact(opts *WaitForCompactOptions) (err error)
WaitForCompact waits for all flush and compactions jobs to finish. Jobs to wait include the unscheduled (queued, but not scheduled yet). If the db is shutting down, Status::ShutdownInProgress will be returned.
NOTE: This may also never return if there's sufficient ongoing writes that keeps flush and compaction going without stopping. The user would have to cease all the writes to DB to make this eventually return in a stable state. The user may also use timeout option in WaitForCompactOptions to make this stop waiting and return when timeout expires.
func (*DB) Write ¶
func (db *DB) Write(opts *WriteOptions, batch *WriteBatch) (err error)
Write a batch to the database.
func (*DB) WriteWI ¶
func (db *DB) WriteWI(opts *WriteOptions, batch *WriteBatchWI) (err error)
WriteWI writes a batch wi to the database.
type DBPath ¶
type DBPath struct {
// contains filtered or unexported fields
}
DBPath represents options for a dbpath.
func NewDBPathsFromData ¶
NewDBPathsFromData creates a slice with allocated DBPath objects from paths and target_sizes.
type DataBlockIndexType ¶ added in v1.6.17
type DataBlockIndexType uint
DataBlockIndexType specifies index type that will be used for the data block.
const ( // KDataBlockIndexTypeBinarySearch is traditional block type KDataBlockIndexTypeBinarySearch DataBlockIndexType = 0 // KDataBlockIndexTypeBinarySearchAndHash additional hash index KDataBlockIndexTypeBinarySearchAndHash DataBlockIndexType = 1 )
type EncodingType ¶ added in v1.8.4
type EncodingType byte
const ( // EncodingTypePlain always write full keys without any special encoding. EncodingTypePlain EncodingType = iota // EncodingTypePrefix find opportunity to write the same prefix once for multiple rows. // In some cases, when a key follows a previous key with the same prefix, // instead of writing out the full key, it just writes out the size of the // shared prefix, as well as other bytes, to save some bytes. // // When using this option, the user is required to use the same prefix // extractor to make sure the same prefix will be extracted from the same key. // The Name() value of the prefix extractor will be stored in the file. When // reopening the file, the name of the options.prefix_extractor given will be // bitwise compared to the prefix extractors stored in the file. An error // will be returned if the two don't match. EncodingTypePrefix )
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a system call environment used by a database.
func NewMemEnv ¶
func NewMemEnv() *Env
NewMemEnv returns a new environment that stores its data in memory and delegates all non-file-storage tasks to base_env.
func (*Env) GetBackgroundThreads ¶ added in v1.6.28
GetBackgroundThreads sets the number of background worker threads of a specific thread pool for this environment. 'LOW' is the default pool.
func (*Env) GetBottomPriorityBackgroundThreads ¶ added in v1.6.28
GetBottomPriorityBackgroundThreads gets the size of thread pool that can be used to prevent bottommost compactions from stalling memtable flushes.
func (*Env) GetHighPriorityBackgroundThreads ¶ added in v1.6.28
GetHighPriorityBackgroundThreads gets the size of the high priority thread pool that can be used to prevent compactions from stalling memtable flushes.
func (*Env) GetLowPriorityBackgroundThreads ¶ added in v1.6.28
GetLowPriorityBackgroundThreads gets the size of the low priority thread pool that can be used to prevent compactions from stalling memtable flushes.
func (*Env) JoinAllThreads ¶
func (env *Env) JoinAllThreads()
JoinAllThreads wait for all threads started by StartThread to terminate.
func (*Env) LowerHighPriorityThreadPoolCPUPriority ¶
func (env *Env) LowerHighPriorityThreadPoolCPUPriority()
LowerHighPriorityThreadPoolCPUPriority lower CPU priority for high priority thread pool.
func (*Env) LowerHighPriorityThreadPoolIOPriority ¶
func (env *Env) LowerHighPriorityThreadPoolIOPriority()
LowerHighPriorityThreadPoolIOPriority lower IO priority for high priority thread pool.
func (*Env) LowerThreadPoolCPUPriority ¶
func (env *Env) LowerThreadPoolCPUPriority()
LowerThreadPoolCPUPriority lower CPU priority for threads from the specified pool.
func (*Env) LowerThreadPoolIOPriority ¶
func (env *Env) LowerThreadPoolIOPriority()
LowerThreadPoolIOPriority lower IO priority for threads from the specified pool.
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) SetBottomPriorityBackgroundThreads ¶ added in v1.6.21
SetBottomPriorityBackgroundThreads sets the size of thread pool that can be used to prevent bottommost compactions from stalling memtable flushes.
func (*Env) SetHighPriorityBackgroundThreads ¶
SetHighPriorityBackgroundThreads sets the size of the high priority thread pool that can be used to prevent compactions from stalling memtable flushes.
func (*Env) SetLowPriorityBackgroundThreads ¶ added in v1.6.21
SetLowPriorityBackgroundThreads sets the size of the low priority thread pool that can be used to prevent compactions from stalling memtable flushes.
type EnvOptions ¶
type EnvOptions struct {
// contains filtered or unexported fields
}
EnvOptions represents options for env.
func NewDefaultEnvOptions ¶
func NewDefaultEnvOptions() *EnvOptions
NewDefaultEnvOptions creates a default EnvOptions object.
func (*EnvOptions) Destroy ¶
func (opts *EnvOptions) Destroy()
Destroy deallocates the EnvOptions object.
type FIFOCompactionOptions ¶
type FIFOCompactionOptions struct {
// contains filtered or unexported fields
}
FIFOCompactionOptions represent all of the available options for FIFO compaction.
func NewDefaultFIFOCompactionOptions ¶
func NewDefaultFIFOCompactionOptions() *FIFOCompactionOptions
NewDefaultFIFOCompactionOptions creates a default FIFOCompactionOptions object.
func (*FIFOCompactionOptions) AllowCompaction ¶ added in v1.8.0
func (opts *FIFOCompactionOptions) AllowCompaction() bool
AllowCompaction checks if compaction is allowed.
func (*FIFOCompactionOptions) Destroy ¶
func (opts *FIFOCompactionOptions) Destroy()
Destroy deallocates the FIFOCompactionOptions object.
func (*FIFOCompactionOptions) GetMaxTableFilesSize ¶ added in v1.6.28
func (opts *FIFOCompactionOptions) GetMaxTableFilesSize() uint64
GetMaxTableFilesSize gets the max table file size. Once the total sum of table files reaches this, we will delete the oldest table file
func (*FIFOCompactionOptions) SetAllowCompaction ¶ added in v1.8.0
func (opts *FIFOCompactionOptions) SetAllowCompaction(allow bool)
SetAllowCompaction allows compaction or not.
func (*FIFOCompactionOptions) SetMaxTableFilesSize ¶
func (opts *FIFOCompactionOptions) SetMaxTableFilesSize(value uint64)
SetMaxTableFilesSize sets the max table file size. Once the total sum of table files reaches this, we will delete the oldest table file
Default: 1GB
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 (opts *FlushOptions) Destroy()
Destroy deallocates the FlushOptions object.
func (*FlushOptions) IsWait ¶ added in v1.6.21
func (opts *FlushOptions) IsWait() bool
IsWait returns if the flush will wait until the flush is done.
func (*FlushOptions) SetWait ¶
func (opts *FlushOptions) SetWait(value bool)
SetWait specify if the flush will wait until the flush is done.
Default: true
type HistogramData ¶ added in v1.8.7
type HistogramData struct { Median float64 P95 float64 P99 float64 Average float64 StdDev float64 Max float64 Min float64 Count uint64 Sum uint64 }
HistogramData histogram metrics.
type HistogramType ¶ added in v1.8.7
type HistogramType uint32
const ( HistogramType_DB_GET HistogramType = iota HistogramType_DB_WRITE HistogramType_COMPACTION_TIME HistogramType_COMPACTION_CPU_TIME HistogramType_SUBCOMPACTION_SETUP_TIME HistogramType_TABLE_SYNC_MICROS HistogramType_COMPACTION_OUTFILE_SYNC_MICROS HistogramType_WAL_FILE_SYNC_MICROS HistogramType_MANIFEST_FILE_SYNC_MICROS // TIME SPENT IN IO DURING TABLE OPEN HistogramType_TABLE_OPEN_IO_MICROS HistogramType_DB_MULTIGET HistogramType_READ_BLOCK_COMPACTION_MICROS HistogramType_READ_BLOCK_GET_MICROS HistogramType_WRITE_RAW_BLOCK_MICROS HistogramType_NUM_FILES_IN_SINGLE_COMPACTION HistogramType_DB_SEEK HistogramType_WRITE_STALL // Time spent in reading block-based or plain SST table HistogramType_SST_READ_MICROS // Time spent in reading SST table (currently only block-based table) or blob // file corresponding to `Env::IOActivity` HistogramType_FILE_READ_FLUSH_MICROS HistogramType_FILE_READ_COMPACTION_MICROS HistogramType_FILE_READ_DB_OPEN_MICROS // The following `FILE_READ_*` require stats level greater than // `StatsLevel::kExceptDetailedTimers` HistogramType_FILE_READ_GET_MICROS HistogramType_FILE_READ_MULTIGET_MICROS HistogramType_FILE_READ_DB_ITERATOR_MICROS HistogramType_FILE_READ_VERIFY_DB_CHECKSUM_MICROS HistogramType_FILE_READ_VERIFY_FILE_CHECKSUMS_MICROS // The number of subcompactions actually scheduled during a compaction HistogramType_NUM_SUBCOMPACTIONS_SCHEDULED // Value size distribution in each operation HistogramType_BYTES_PER_READ HistogramType_BYTES_PER_WRITE HistogramType_BYTES_PER_MULTIGET HistogramType_BYTES_COMPRESSED // DEPRECATED / unused (see BYTES_COMPRESSED_{FROMTO}) HistogramType_BYTES_DECOMPRESSED // DEPRECATED / unused (see BYTES_DECOMPRESSED_{FROMTO}) HistogramType_COMPRESSION_TIMES_NANOS HistogramType_DECOMPRESSION_TIMES_NANOS // Number of merge operands passed to the merge operator in user read // requests. HistogramType_READ_NUM_MERGE_OPERANDS // BlobDB specific stats // Size of keys written to BlobDB. Only applicable to legacy BlobDB. HistogramType_BLOB_DB_KEY_SIZE // Size of values written to BlobDB. Only applicable to legacy BlobDB. HistogramType_BLOB_DB_VALUE_SIZE // BlobDB Put/PutWithTTL/PutUntil/Write latency. Only applicable to legacy // BlobDB. HistogramType_BLOB_DB_WRITE_MICROS // BlobDB Get latency. Only applicable to legacy BlobDB. HistogramType_BLOB_DB_GET_MICROS // BlobDB MultiGet latency. Only applicable to legacy BlobDB. HistogramType_BLOB_DB_MULTIGET_MICROS // BlobDB Seek/SeekToFirst/SeekToLast/SeekForPrev latency. Only applicable to // legacy BlobDB. HistogramType_BLOB_DB_SEEK_MICROS // BlobDB Next latency. Only applicable to legacy BlobDB. HistogramType_BLOB_DB_NEXT_MICROS // BlobDB Prev latency. Only applicable to legacy BlobDB. HistogramType_BLOB_DB_PREV_MICROS // Blob file write latency. HistogramType_BLOB_DB_BLOB_FILE_WRITE_MICROS // Blob file read latency. HistogramType_BLOB_DB_BLOB_FILE_READ_MICROS // Blob file sync latency. HistogramType_BLOB_DB_BLOB_FILE_SYNC_MICROS // BlobDB compression time. HistogramType_BLOB_DB_COMPRESSION_MICROS // BlobDB decompression time. HistogramType_BLOB_DB_DECOMPRESSION_MICROS // Time spent flushing memtable to disk HistogramType_FLUSH_TIME HistogramType_SST_BATCH_SIZE // MultiGet stats logged per level // Num of index and filter blocks read from file system per level. HistogramType_NUM_INDEX_AND_FILTER_BLOCKS_READ_PER_LEVEL // Num of sst files read from file system per level. HistogramType_NUM_SST_READ_PER_LEVEL // Error handler statistics HistogramType_ERROR_HANDLER_AUTORESUME_RETRY_COUNT // Stats related to asynchronous read requests. HistogramType_ASYNC_READ_BYTES HistogramType_POLL_WAIT_MICROS // Number of prefetched bytes discarded by RocksDB. HistogramType_PREFETCHED_BYTES_DISCARDED // Number of IOs issued in parallel in a MultiGet batch HistogramType_MULTIGET_IO_BATCH_SIZE // Number of levels requiring IO for MultiGet HistogramType_NUM_LEVEL_READ_PER_MULTIGET // Wait time for aborting async read in FilePrefetchBuffer destructor HistogramType_ASYNC_PREFETCH_ABORT_MICROS // Number of bytes read for RocksDB's prefetching contents (as opposed to file // system's prefetch) from the end of SST table during block based table open HistogramType_TABLE_OPEN_PREFETCH_TAIL_READ_BYTES )
type HyperClockCacheOptions ¶ added in v1.8.0
type HyperClockCacheOptions struct {
// contains filtered or unexported fields
}
HyperClockCacheOptions are options for HyperClockCache.
HyperClockCache is a lock-free Cache alternative for RocksDB block cache that offers much improved CPU efficiency vs. LRUCache under high parallel load or high contention, with some caveats: * Not a general Cache implementation: can only be used for BlockBasedTableOptions::block_cache, which RocksDB uses in a way that is compatible with HyperClockCache. * Requires an extra tuning parameter: see estimated_entry_charge below. Similarly, substantially changing the capacity with SetCapacity could harm efficiency. * SecondaryCache is not yet supported. * Cache priorities are less aggressively enforced, which could cause cache dilution from long range scans (unless they use fill_cache=false). * Can be worse for small caches, because if almost all of a cache shard is pinned (more likely with non-partitioned filters), then CLOCK eviction becomes very CPU intensive.
See internal cache/clock_cache.h for full description.
func NewHyperClockCacheOptions ¶ added in v1.8.0
func NewHyperClockCacheOptions(capacity, estimatedEntryCharge int) *HyperClockCacheOptions
NewHyperClockCacheOptions creates new options for hyper clock cache.
func (*HyperClockCacheOptions) Destroy ¶ added in v1.8.0
func (h *HyperClockCacheOptions) Destroy()
Destroy the options.
func (*HyperClockCacheOptions) SetCapacity ¶ added in v1.8.0
func (h *HyperClockCacheOptions) SetCapacity(capacity int)
SetCapacity sets the capacity of the cache.
func (*HyperClockCacheOptions) SetEstimatedEntryCharge ¶ added in v1.8.0
func (h *HyperClockCacheOptions) SetEstimatedEntryCharge(v int)
SetEstimatedEntryCharge sets the estimated average `charge` associated with cache entries.
This is a critical configuration parameter for good performance from the hyper cache, because having a table size that is fixed at creation time greatly reduces the required synchronization between threads. * If the estimate is substantially too low (e.g. less than half the true average) then metadata space overhead with be substantially higher (e.g. 200 bytes per entry rather than 100). With kFullChargeCacheMetadata, this can slightly reduce cache hit rates, and slightly reduce access times due to the larger working memory size. * If the estimate is substantially too high (e.g. 25% higher than the true average) then there might not be sufficient slots in the hash table for both efficient operation and capacity utilization (hit rate). The hyper cache will evict entries to prevent load factors that could dramatically affect lookup times, instead letting the hit rate suffer by not utilizing the full capacity.
A reasonable choice is the larger of block_size and metadata_block_size. When WriteBufferManager (and similar) charge memory usage to the block cache, this can lead to the same effect as estimate being too low, which is better than the opposite. Therefore, the general recommendation is to assume that other memory charged to block cache could be negligible, and ignore it in making the estimate.
The best parameter choice based on a cache in use is given by GetUsage() / GetOccupancyCount(), ignoring metadata overheads such as with kDontChargeCacheMetadata. More precisely with kFullChargeCacheMetadata is (GetUsage() - 64 * GetTableAddressCount()) / GetOccupancyCount(). However, when the average value size might vary (e.g. balance between metadata and data blocks in cache), it is better to estimate toward the lower side than the higher side.
func (*HyperClockCacheOptions) SetMemoryAllocator ¶ added in v1.8.0
func (h *HyperClockCacheOptions) SetMemoryAllocator(m *MemoryAllocator)
SetMemoryAllocator for this cache.
func (*HyperClockCacheOptions) SetNumShardBits ¶ added in v1.8.0
func (h *HyperClockCacheOptions) SetNumShardBits(n int)
SetCapacity sets number of shards used for this cache.
type IndexType ¶
type IndexType uint
IndexType specifies the index type that will be used for this table.
const ( // KBinarySearchIndexType a space efficient index block that is optimized for // binary-search-based index. KBinarySearchIndexType IndexType = 0x00 // KHashSearchIndexType the hash index, if enabled, will do the hash lookup when // `Options.prefix_extractor` is provided. KHashSearchIndexType IndexType = 0x01 // KTwoLevelIndexSearchIndexType a two-level index implementation. Both levels are binary search indexes. KTwoLevelIndexSearchIndexType IndexType = 0x02 // KBinarySearchWithFirstKey like KBinarySearchIndexType, but index also contains // first key of each block. // // This allows iterators to defer reading the block until it's actually // needed. May significantly reduce read amplification of short range scans. // Without it, iterator seek usually reads one block from each level-0 file // and from each level, which may be expensive. // Works best in combination with: // - IndexShorteningMode::kNoShortening, // - custom FlushBlockPolicy to cut blocks at some meaningful boundaries, // e.g. when prefix changes. // Makes the index significantly bigger (2x or more), especially when keys // are long. // // IO errors are not handled correctly in this mode right now: if an error // happens when lazily reading a block in value(), value() returns empty // slice, and you need to call Valid()/status() afterwards. KBinarySearchWithFirstKey IndexType = 0x03 )
type IngestExternalFileOptions ¶
type IngestExternalFileOptions struct {
// contains filtered or unexported fields
}
IngestExternalFileOptions represents available options when ingesting external files.
func NewDefaultIngestExternalFileOptions ¶
func NewDefaultIngestExternalFileOptions() *IngestExternalFileOptions
NewDefaultIngestExternalFileOptions creates a default IngestExternalFileOptions object.
func (*IngestExternalFileOptions) Destroy ¶
func (opts *IngestExternalFileOptions) Destroy()
Destroy deallocates the IngestExternalFileOptions object.
func (*IngestExternalFileOptions) SetAllowBlockingFlush ¶
func (opts *IngestExternalFileOptions) SetAllowBlockingFlush(flag bool)
SetAllowBlockingFlush sets allow_blocking_flush. If set to false and the file key range overlaps with the memtable key range (memtable flush required), IngestExternalFile will fail. Default to true.
func (*IngestExternalFileOptions) SetAllowGlobalSeqNo ¶
func (opts *IngestExternalFileOptions) SetAllowGlobalSeqNo(flag bool)
SetAllowGlobalSeqNo sets allow_global_seqno. If set to false,IngestExternalFile() will fail if the file key range overlaps with existing keys or tombstones in the DB. Default true.
func (*IngestExternalFileOptions) SetFailIfNotBottommostLevel ¶ added in v1.8.0
func (opts *IngestExternalFileOptions) SetFailIfNotBottommostLevel(flag bool)
SetFailIfNotBottommostLevel sets to TRUE if user wants file to be ingested to the bottommost level. An error of Status::TryAgain() will be returned if a file cannot fit in the bottommost level when calling DB::IngestExternalFile()/DB::IngestExternalFiles().
The user should clear the bottommost level in the overlapping range before re-attempt. Ingest_behind takes precedence over fail_if_not_bottommost_level.
func (*IngestExternalFileOptions) SetIngestionBehind ¶
func (opts *IngestExternalFileOptions) SetIngestionBehind(flag bool)
SetIngestionBehind sets ingest_behind Set to true if you would like duplicate keys in the file being ingested to be skipped rather than overwriting existing data under that key. Usecase: back-fill of some historical data in the database without over-writing existing newer version of data. This option could only be used if the DB has been running with allow_ingest_behind=true since the dawn of time. All files will be ingested at the bottommost level with seqno=0.
func (*IngestExternalFileOptions) SetMoveFiles ¶
func (opts *IngestExternalFileOptions) SetMoveFiles(flag bool)
SetMoveFiles specifies if it should move the files instead of copying them. Default to false.
func (*IngestExternalFileOptions) SetSnapshotConsistency ¶
func (opts *IngestExternalFileOptions) SetSnapshotConsistency(flag bool)
SetSnapshotConsistency if specifies the consistency. If set to false, an ingested file key could appear in existing snapshots that were created before the file was ingested. Default to true.
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 (*Iterator) Err ¶
Err returns nil if no errors happened during iteration, or the actual error otherwise.
func (*Iterator) Next ¶
func (iter *Iterator) Next()
Next moves the iterator to the next sequential key in the database.
func (*Iterator) Prev ¶
func (iter *Iterator) Prev()
Prev moves the iterator to the previous sequential key in the database.
func (*Iterator) Refresh ¶ added in v1.9.5
Refresh if supported, the DB state that the iterator reads from is updated to the latest state. The iterator will be invalidated after the call. Regardless of whether the iterator was created/refreshed previously with or without a snapshot, the iterator will be reading the latest DB state after this call. Note that you will need to call a Seek*() function to get the iterator back into a valid state before calling a function that assumes the state is already valid, like Next().
func (*Iterator) SeekForPrev ¶
SeekForPrev moves the iterator to the last key that less than or equal to the target key, in contrast with Seek.
func (*Iterator) SeekToFirst ¶
func (iter *Iterator) SeekToFirst()
SeekToFirst moves the iterator to the first key in the database.
func (*Iterator) SeekToLast ¶
func (iter *Iterator) SeekToLast()
SeekToLast moves the iterator to the last key in the database.
func (*Iterator) Timestamp ¶ added in v1.7.5
Timestamp returns the timestamp in the database the iterator currently holds.
func (*Iterator) Valid ¶
Valid returns false only when an Iterator has iterated past either the first or the last key in the database.
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 LRUCacheOptions ¶ added in v1.6.37
type LRUCacheOptions struct {
// contains filtered or unexported fields
}
LRUCacheOptions are options for LRU Cache.
func NewLRUCacheOptions ¶ added in v1.6.37
func NewLRUCacheOptions() *LRUCacheOptions
NewLRUCacheOptions creates lru cache options.
func (*LRUCacheOptions) Destroy ¶ added in v1.6.37
func (l *LRUCacheOptions) Destroy()
Destroy lru cache options.
func (*LRUCacheOptions) SetCapacity ¶ added in v1.6.37
func (l *LRUCacheOptions) SetCapacity(s uint)
SetCapacity sets capacity for this lru cache.
func (*LRUCacheOptions) SetMemoryAllocator ¶ added in v1.6.37
func (l *LRUCacheOptions) SetMemoryAllocator(m *MemoryAllocator)
SetMemoryAllocator for this lru cache.
func (*LRUCacheOptions) SetNumShardBits ¶ added in v1.7.6
func (l *LRUCacheOptions) SetNumShardBits(n int)
SetCapacity sets number of shards used for this lru cache.
type LatestOptions ¶ added in v1.7.6
type LatestOptions struct {
// contains filtered or unexported fields
}
func LoadLatestOptions ¶ added in v1.7.6
func LoadLatestOptions(path string, env *Env, ignoreUnknownOpts bool, cache *Cache) (lo *LatestOptions, err error)
LoadLatestOptions loads the latest rocksdb options from the specified db_path.
On success, num_column_families will be updated with a non-zero number indicating the number of column families.
func (*LatestOptions) ColumnFamilyNames ¶ added in v1.7.7
func (l *LatestOptions) ColumnFamilyNames() []string
ColumnFamilyNames gets column family names.
func (*LatestOptions) ColumnFamilyOpts ¶ added in v1.7.7
func (l *LatestOptions) ColumnFamilyOpts() []Options
ColumnFamilyOpts returns corresponding options of column families.
func (*LatestOptions) Destroy ¶ added in v1.7.6
func (l *LatestOptions) Destroy()
Destroy release underlying db_options, column_family_names, and column_family_options.
func (*LatestOptions) Options ¶ added in v1.7.16
func (l *LatestOptions) Options() *Options
Options gets the latest options.
type LevelMetadata ¶ added in v1.7.6
type LevelMetadata struct {
// contains filtered or unexported fields
}
LevelMetadata represents the metadata that describes a level.
func (*LevelMetadata) Level ¶ added in v1.7.6
func (l *LevelMetadata) Level() int
Level returns level value.
func (*LevelMetadata) Size ¶ added in v1.7.6
func (l *LevelMetadata) Size() uint64
Size returns the sum of the file size in this level.
func (*LevelMetadata) SstMetas ¶ added in v1.7.6
func (l *LevelMetadata) SstMetas() []SstMetadata
SstMetas returns metadata(s) of sst-file(s) in this level.
type LiveFileMetadata ¶
type LiveFileMetadata struct { Name string ColumnFamilyName string Level int Size int64 SmallestKey []byte LargestKey []byte Entries uint64 // number of entries Deletions uint64 // number of deletions }
LiveFileMetadata is a metadata which is associated with each SST file.
type Logger ¶ added in v1.9.1
type Logger struct {
// contains filtered or unexported fields
}
Logger struct.
func NewStderrLogger ¶ added in v1.9.1
func NewStderrLogger(level InfoLogLevel, prefix string) *Logger
type MemoryAllocator ¶ added in v1.6.37
type MemoryAllocator struct {
// contains filtered or unexported fields
}
MemoryAllocator wraps memory allocator for rocksdb.
func (*MemoryAllocator) Destroy ¶ added in v1.6.37
func (m *MemoryAllocator) Destroy()
Destroy this mem allocator.
type MemoryUsage ¶
type MemoryUsage struct { // MemTableTotal estimates memory usage of all mem-tables MemTableTotal uint64 // MemTableUnflushed estimates memory usage of unflushed mem-tables MemTableUnflushed uint64 // MemTableReadersTotal memory usage of table readers (indexes and bloom filters) MemTableReadersTotal uint64 // CacheTotal memory usage of cache CacheTotal uint64 }
MemoryUsage contains memory usage statistics provided by RocksDB
func GetApproximateMemoryUsageByType ¶
func GetApproximateMemoryUsageByType(dbs []*DB, caches []*Cache) (result *MemoryUsage, err error)
GetApproximateMemoryUsageByType returns summary memory usage stats for given databases and caches.
type MergeOperator ¶
type MergeOperator interface { // Gives the client a way to express the read -> modify -> write semantics // key: The key that's associated with this merge operation. // Client could multiplex the merge operator based on it // if the key space is partitioned and different subspaces // refer to different types of data which have different // merge operation semantics. // existingValue: null indicates that the key does not exist before this op. // operands: the sequence of merge operations to apply, front() first. // // Return true on success. // // All values passed in will be client-specific values. So if this method // returns false, it is because client specified bad data or there was // internal corruption. This will be treated as an error by the library. FullMerge(key, existingValue []byte, operands [][]byte) ([]byte, bool) // The name of the MergeOperator. Name() string }
A MergeOperator specifies the SEMANTICS of a merge, which only client knows. It could be numeric addition, list append, string concatenation, edit data structure, ... , anything. The library, on the other hand, is concerned with the exercise of this interface, at the right time (during get, iteration, compaction...)
Please read the RocksDB documentation <http://rocksdb.org/> for more details and example implementations.
func NewNativeMergeOperator ¶
func NewNativeMergeOperator(c unsafe.Pointer) MergeOperator
NewNativeMergeOperator creates a MergeOperator object.
type MultiMerger ¶
type MultiMerger interface { // PartialMerge performs merge on multiple operands // when all of the operands are themselves merge operation types // that you would have passed to a db.Merge() call in the same order // (i.e.: db.Merge(key,operand[0]), followed by db.Merge(key,operand[1]), // ... db.Merge(key, operand[n])). // // PartialMerge should combine them into a single merge operation. // The return value should be constructed such that a call to // db.Merge(key, new_value) would yield the same result as a call // to db.Merge(key,operand[0]), followed by db.Merge(key,operand[1]), // ... db.Merge(key, operand[n])). // // If it is impossible or infeasible to combine the operations, return false. // The library will internally keep track of the operations, and apply them in the // correct order once a base-value (a Put/Delete/End-of-Database) is seen. PartialMergeMulti(key []byte, operands [][]byte) ([]byte, bool) // Destroy pointer/underlying data Destroy() }
MultiMerger implements PartialMergeMulti(key []byte, operands [][]byte) ([]byte, err) When a MergeOperator implements this interface, PartialMergeMulti will be called in addition to FullMerge for compactions across levels
type NativeFilterPolicy ¶ added in v1.7.0
type NativeFilterPolicy struct {
// contains filtered or unexported fields
}
NativeFilterPolicy wraps over rocksdb filter policy.
func NewBloomFilter ¶
func NewBloomFilter(bitsPerKey float64) *NativeFilterPolicy
NewBloomFilter returns a new filter policy that uses a 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 NewBloomFilterFull ¶
func NewBloomFilterFull(bitsPerKey float64) *NativeFilterPolicy
NewBloomFilterFull returns a new filter policy that uses a full 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 NewRibbonFilterPolicy ¶ added in v1.6.39
func NewRibbonFilterPolicy(bloomEquivalentBitsPerKey float64) *NativeFilterPolicy
NewRibbonFilterPolicy creates a new Bloom alternative that saves about 30% space compared to Bloom filters, with similar query times but roughly 3-4x CPU time and 3x temporary space usage during construction.
For example: if you pass in 10 for bloom_equivalent_bits_per_key, you'll get the same 0.95% FP rate as Bloom filter but only using about 7 bits per key.
The space savings of Ribbon filters makes sense for lower (higher numbered; larger; longer-lived) levels of LSM, whereas the speed of Bloom filters make sense for highest levels of LSM.
Ribbon filters are compatible with RocksDB >= 6.15.0. Earlier versions reading the data will behave as if no filter was used (degraded performance until compaction rebuilds filters). All built-in FilterPolicies (Bloom or Ribbon) are able to read other kinds of built-in filters.
Note: the current Ribbon filter schema uses some extra resources when constructing very large filters. For example, for 100 million keys in a single filter (one SST file without partitioned filters), 3GB of temporary, untracked memory is used, vs. 1GB for Bloom. However, the savings in filter space from just ~60 open SST files makes up for the additional temporary memory use.
Also consider using optimize_filters_for_memory to save filter memory.
func NewRibbonHybridFilterPolicy ¶ added in v1.7.0
func NewRibbonHybridFilterPolicy(bloomEquivalentBitsPerKey float64, bloomBeforeLevel int) *NativeFilterPolicy
NewRibbonHybridFilterPolicy similar to Ribbon.
Setting bloom_before_level allows for this design with Level and Universal compaction styles. For example, bloom_before_level=1 means that Bloom filters will be used in level 0, including flushes, and Ribbon filters elsewhere, including FIFO compaction and external SST files. For this option, memtable flushes are considered level -1 (so that flushes can be distinguished from intra-L0 compaction). bloom_before_level=0 (default) -> Generate Bloom filters only for flushes under Level and Universal compaction styles. bloom_before_level=-1 -> Always generate Ribbon filters (except in some extreme or exceptional cases).
func (*NativeFilterPolicy) Destroy ¶ added in v1.7.0
func (fp *NativeFilterPolicy) Destroy()
type OptimisticTransactionDB ¶
type OptimisticTransactionDB struct {
// contains filtered or unexported fields
}
OptimisticTransactionDB is a reusable handle to a RocksDB optimistic transactional database on disk.
func OpenOptimisticTransactionDb ¶
func OpenOptimisticTransactionDb( opts *Options, name string, ) (tdb *OptimisticTransactionDB, err error)
OpenOptimisticTransactionDb opens a database with the specified options.
func (*OptimisticTransactionDB) Close ¶
func (db *OptimisticTransactionDB) Close()
Close closes the database.
func (*OptimisticTransactionDB) CloseBaseDB ¶
func (db *OptimisticTransactionDB) CloseBaseDB(base *DB)
CloseBaseDB closes base-database.
func (*OptimisticTransactionDB) GetBaseDB ¶
func (db *OptimisticTransactionDB) GetBaseDB() *DB
GetBaseDB returns base-database.
func (*OptimisticTransactionDB) NewCheckpoint ¶ added in v1.6.42
func (db *OptimisticTransactionDB) NewCheckpoint() (cp *Checkpoint, err error)
NewCheckpoint creates a new Checkpoint for this db.
func (*OptimisticTransactionDB) TransactionBegin ¶
func (db *OptimisticTransactionDB) TransactionBegin( opts *WriteOptions, transactionOpts *OptimisticTransactionOptions, oldTransaction *Transaction, ) *Transaction
TransactionBegin begins a new transaction with the WriteOptions and TransactionOptions given.
func (*OptimisticTransactionDB) Write ¶ added in v1.6.40
func (db *OptimisticTransactionDB) Write(opts *WriteOptions, batch *WriteBatch) (err error)
Write batch.
type OptimisticTransactionOptions ¶
type OptimisticTransactionOptions struct {
// contains filtered or unexported fields
}
OptimisticTransactionOptions represent all of the available options options for a optimistic transaction on the database.
func NewDefaultOptimisticTransactionOptions ¶
func NewDefaultOptimisticTransactionOptions() *OptimisticTransactionOptions
NewDefaultOptimisticTransactionOptions creates a default TransactionOptions object.
func (*OptimisticTransactionOptions) Destroy ¶
func (opts *OptimisticTransactionOptions) Destroy()
Destroy deallocates the TransactionOptions object.
func (*OptimisticTransactionOptions) SetSetSnapshot ¶
func (opts *OptimisticTransactionOptions) SetSetSnapshot(value bool)
SetSetSnapshot to true is the same as calling Transaction::SetSnapshot().
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options represent all of the available options when opening a database with Open.
func GetOptionsFromString ¶
GetOptionsFromString creates a Options object from existing opt and string. If base is nil, a default opt create by NewDefaultOptions will be used as base opt.
func NewDefaultOptions ¶
func NewDefaultOptions() *Options
NewDefaultOptions creates the default Options.
func (*Options) AddCompactOnDeletionCollectorFactory ¶ added in v1.6.37
AddCompactOnDeletionCollectorFactory marks a SST file as need-compaction when it observe at least "D" deletion entries in any "N" consecutive entries or the ratio of tombstone entries in the whole file >= the specified deletion ratio.
func (*Options) AddCompactOnDeletionCollectorFactoryWithRatio ¶ added in v1.8.3
func (opts *Options) AddCompactOnDeletionCollectorFactoryWithRatio(windowSize, numDelsTrigger uint, deletionRatio float64)
AddCompactOnDeletionCollectorFactoryWithRatio similar to AddCompactOnDeletionCollectorFactory with specific deletion ratio.
func (*Options) AdviseRandomOnOpen ¶ added in v1.6.21
AdviseRandomOnOpen returns whether we will hint the underlying file system that the file access pattern is random, when a sst file is opened.
func (*Options) AllowConcurrentMemtableWrites ¶ added in v1.6.21
AllowConcurrentMemtableWrites 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) AllowIngestBehind ¶ added in v1.6.20
AllowIngestBehind checks if allow_ingest_behind is set
func (*Options) AllowMmapReads ¶ added in v1.6.21
AllowMmapReads returns setting for enable/disable mmap reads for sst tables.
func (*Options) AllowMmapWrites ¶ added in v1.6.21
AllowMmapWrites returns setting for enable/disable mmap writes for sst tables.
func (*Options) AvoidUnnecessaryBlockingIO ¶ added in v1.7.13
AvoidUnnecessaryBlockingIO if true, working thread may avoid doing unnecessary and long-latency operation (such as deleting obsolete files directly or deleting memtable) and will instead schedule a background job to do it. Use it if you're latency-sensitive.
If set to true, takes precedence over ReadOptions::background_purge_on_iterator_cleanup.
func (*Options) CompactionReadaheadSize ¶
CompactionReadaheadSize if non-zero, we perform bigger reads when doing compaction. If you're running RocksDB on spinning disks, you should set this to at least 2MB. That way RocksDB's compaction is doing sequential instead of random reads.
When non-zero, we also force new_table_reader_for_compaction_inputs to true.
Default: 0
Dynamically changeable through SetDBOptions() API.
func (*Options) CreateIfMissing ¶ added in v1.6.20
CreateIfMissing checks if create_if_mission option is set
func (*Options) CreateIfMissingColumnFamilies ¶ added in v1.6.20
CreateIfMissingColumnFamilies checks if create_if_missing_cf option is set
func (*Options) DisabledAutoCompactions ¶ added in v1.6.21
DisabledAutoCompactions returns if automatic compactions is disabled.
func (*Options) EnableBlobFiles ¶ added in v1.6.36
EnableBlobFiles when set, large values (blobs) are written to separate blob files, and only pointers to them are stored in SST files. This can reduce write amplification for large-value use cases at the cost of introducing a level of indirection for reads. See also the options min_blob_size, blob_file_size, blob_compression_type, enable_blob_garbage_collection, and blob_garbage_collection_age_cutoff below.
Default: false
Dynamically changeable through the API.
func (*Options) EnableBlobGC ¶ added in v1.6.36
EnableBlobGC toggles garbage collection of blobs. Blob GC is performed as part of compaction. Valid blobs residing in blob files older than a cutoff get relocated to new files as they are encountered during compaction, which makes it possible to clean up blob files once they contain nothing but obsolete/garbage blobs. See also blob_garbage_collection_age_cutoff below.
Default: false
Dynamically changeable through the API.
func (*Options) EnableStatistics ¶
func (opts *Options) EnableStatistics()
EnableStatistics enable statistics.
func (*Options) EnabledPipelinedWrite ¶ added in v1.6.20
EnabledPipelinedWrite check if enable_pipelined_write is turned on.
func (*Options) EnabledWriteThreadAdaptiveYield ¶ added in v1.6.21
EnabledWriteThreadAdaptiveYield if true, threads synchronizing with the write batch group leader will wait for up to write_thread_max_yield_usec before blocking on a mutex. This can substantially improve throughput for concurrent workloads, regardless of whether allow_concurrent_memtable_write is enabled.
func (*Options) ErrorIfExists ¶ added in v1.6.20
ErrorIfExists checks if error_if_exist option is set
func (*Options) GetArenaBlockSize ¶ added in v1.6.21
GetArenaBlockSize returns the size of one block in arena memory allocation.
func (*Options) GetAvoidUnnecessaryBlockingIOFlag ¶ added in v1.7.13
GetAvoidUnnecessaryBlockingIOFlag returns value of avoid unnecessary blocking io flag.
func (*Options) GetBlobCompactionReadaheadSize ¶ added in v1.6.44
GetBlobCompactionReadaheadSize returns compaction readahead size for blob files.
func (*Options) GetBlobCompressionType ¶ added in v1.6.36
func (opts *Options) GetBlobCompressionType() CompressionType
GetBlobCompressionType gets the compression algorithm to use for large values stored in blob files. Note that enable_blob_files has to be set in order for this option to have any effect.
func (*Options) GetBlobFileSize ¶ added in v1.6.36
GetBlobFileSize gets the size limit for blob files.
func (*Options) GetBlobFileStartingLevel ¶ added in v1.7.5
GetBlobFileStartingLevel returns blob starting level.
func (*Options) GetBlobGCAgeCutoff ¶ added in v1.6.36
GetBlobGCAgeCutoff returns the cutoff in terms of blob file age for garbage collection.
func (*Options) GetBlobGCForceThreshold ¶ added in v1.6.43
GetBlobGCForceThreshold get the threshold for ratio of garbage in the oldest blob files. See also: `SetBlobGCForceThreshold`
Default: 1.0
func (*Options) GetBloomLocality ¶ added in v1.6.21
GetBloomLocality returns control locality of bloom filter probes to improve cache miss rate. This option only applies to memtable prefix bloom and plaintable prefix bloom. It essentially limits the max number of cache lines each bloom filter check can touch. This optimization is turned off when set to 0. The number should never be greater than number of probes. This option can boost performance for in-memory workload but should use with care since it can cause higher false positive rate.
func (*Options) GetBottommostCompression ¶ added in v1.6.21
func (opts *Options) GetBottommostCompression() CompressionType
GetBottommostCompression returns the compression algorithm for bottommost level.
func (*Options) GetBottommostCompressionOptionsZstdDictTrainer ¶ added in v1.7.12
GetBottommostCompressionOptionsZstdDictTrainer returns if zstd dict trainer is used or not.
func (*Options) GetBytesPerSync ¶ added in v1.6.21
GetBytesPerSync return setting for bytes (size) per sync.
func (*Options) GetCompactionPri ¶ added in v1.9.3
func (opts *Options) GetCompactionPri() CompactionPri
GetCompactionPri gets in level-based compaction.
func (*Options) GetCompactionReadaheadSize ¶ added in v1.6.20
GetCompactionReadaheadSize gets readahead size
func (*Options) GetCompactionStyle ¶ added in v1.6.21
func (opts *Options) GetCompactionStyle() CompactionStyle
GetCompactionStyle returns compaction style.
func (*Options) GetCompression ¶ added in v1.6.21
func (opts *Options) GetCompression() CompressionType
GetCompression returns the compression algorithm.
func (*Options) GetCompressionOptionsMaxDictBufferBytes ¶ added in v1.6.37
GetCompressionOptionsMaxDictBufferBytes returns the limit on data buffering when gathering samples to build a dictionary. Zero means no limit. When dictionary is disabled (`max_dict_bytes == 0`), enabling this limit (`max_dict_buffer_bytes != 0`) has no effect.
func (*Options) GetCompressionOptionsParallelThreads ¶ added in v1.6.37
GetCompressionOptionsParallelThreads returns number of threads for parallel compression. Parallel compression is enabled only if threads > 1.
This option is valid only when BlockBasedTable is used. Default: 1.
Note: THE FEATURE IS STILL EXPERIMENTAL
func (*Options) GetCompressionOptionsZstdDictTrainer ¶ added in v1.7.4
GetCompressionOptionsZstdDictTrainer returns if zstd dict trainer is used or not.
func (*Options) GetCompressionOptionsZstdMaxTrainBytes ¶ added in v1.6.37
GetCompressionOptionsZstdMaxTrainBytes gets maximum size of training data passed to zstd's dictionary trainer. Using zstd's dictionary trainer can achieve even better compression ratio improvements than using `max_dict_bytes` alone.
func (*Options) GetDbWriteBufferSize ¶ added in v1.6.20
GetDbWriteBufferSize gets db_write_buffer_size which is set in options
func (*Options) GetDeleteObsoleteFilesPeriodMicros ¶ added in v1.6.21
GetDeleteObsoleteFilesPeriodMicros returns the periodicity when obsolete files get deleted.
func (*Options) GetHardPendingCompactionBytesLimit ¶ added in v1.6.21
GetHardPendingCompactionBytesLimit returns the threshold at which all writes will be slowed down to at least delayed_write_rate if estimated bytes needed to be compaction exceed this threshold.
func (*Options) GetHistogramData ¶ added in v1.8.7
func (opts *Options) GetHistogramData(histogramType HistogramType) (histogram HistogramData)
func (*Options) GetInfoLog ¶ added in v1.9.1
GetInfoLog gets info logger.
func (*Options) GetInfoLogLevel ¶ added in v1.6.20
func (opts *Options) GetInfoLogLevel() InfoLogLevel
GetInfoLogLevel gets the info log level which options hold
func (*Options) GetInplaceUpdateNumLocks ¶ added in v1.6.21
GetInplaceUpdateNumLocks returns number of locks used for inplace upddate.
func (*Options) GetKeepLogFileNum ¶ added in v1.6.21
GetKeepLogFileNum return setting for maximum info log files to be kept.
func (*Options) GetLevel0FileNumCompactionTrigger ¶ added in v1.6.20
GetLevel0FileNumCompactionTrigger gets the number of files to trigger level-0 compaction.
func (*Options) GetLevel0SlowdownWritesTrigger ¶ added in v1.6.20
GetLevel0SlowdownWritesTrigger gets the soft limit on number of level-0 files. We start slowing down writes at this point.
func (*Options) GetLevel0StopWritesTrigger ¶ added in v1.6.20
GetLevel0StopWritesTrigger gets the maximum number of level-0 files. We stop writes at this point.
func (*Options) GetLevelCompactionDynamicLevelBytes ¶ added in v1.6.20
GetLevelCompactionDynamicLevelBytes checks if level_compaction_dynamic_level_bytes option is set.
func (*Options) GetLogFileTimeToRoll ¶ added in v1.6.21
GetLogFileTimeToRoll returns the time for info log file to roll (in seconds).
func (*Options) GetManifestPreallocationSize ¶ added in v1.6.21
GetManifestPreallocationSize returns the number of bytes to preallocate (via fallocate) the manifest files.
func (*Options) GetMaxBackgroundCompactions ¶ added in v1.6.21
GetMaxBackgroundCompactions returns maximum number of concurrent background compaction jobs setting.
func (*Options) GetMaxBackgroundFlushes ¶ added in v1.6.21
GetMaxBackgroundFlushes returns the maximum number of concurrent background memtable flush jobs setting.
func (*Options) GetMaxBackgroundJobs ¶ added in v1.6.21
GetMaxBackgroundJobs returns maximum number of concurrent background jobs setting.
func (*Options) GetMaxBytesForLevelBase ¶ added in v1.6.20
GetMaxBytesForLevelBase gets the maximum total data size for a level.
func (*Options) GetMaxBytesForLevelMultiplier ¶ added in v1.6.20
GetMaxBytesForLevelMultiplier gets the max bytes for level multiplier.
func (*Options) GetMaxCompactionBytes ¶ added in v1.6.21
GetMaxCompactionBytes returns the maximum number of bytes in all compacted files. We try to limit number of bytes in one compaction to be lower than this threshold. But it's not guaranteed.
func (*Options) GetMaxFileOpeningThreads ¶ added in v1.6.20
GetMaxFileOpeningThreads gets the maximum number of file opening threads.
func (*Options) GetMaxLogFileSize ¶ added in v1.6.21
GetMaxLogFileSize returns setting for maximum size of the info log file.
func (*Options) GetMaxManifestFileSize ¶ added in v1.6.21
GetMaxManifestFileSize returns the maximum manifest file size until is rolled over. The older manifest file be deleted.
func (*Options) GetMaxOpenFiles ¶ added in v1.6.20
GetMaxOpenFiles gets the number of open files that can be used by the DB.
func (*Options) GetMaxSequentialSkipInIterations ¶ added in v1.6.21
GetMaxSequentialSkipInIterations returns the number of keys (with the same userkey) that will be sequentially skipped before a reseek is issued.
func (*Options) GetMaxSubcompactions ¶ added in v1.6.20
GetMaxSubcompactions gets the maximum number of threads that will concurrently perform a compaction job by breaking it into multiple, smaller ones that are run simultaneously.
func (*Options) GetMaxSuccessiveMerges ¶ added in v1.6.21
GetMaxSuccessiveMerges returns the maximum number of successive merge operations on a key in the memtable.
When a merge operation is added to the memtable and the maximum number of successive merges is reached, the value of the key will be calculated and inserted into the memtable instead of the merge operation. This will ensure that there are never more than max_successive_merges merge operations in the memtable.
func (*Options) GetMaxTotalWalSize ¶ added in v1.6.20
GetMaxTotalWalSize gets the maximum total wal size (in bytes).
func (*Options) GetMaxWriteBufferNumber ¶ added in v1.6.20
GetMaxWriteBufferNumber gets the maximum number of write buffers that are built up in memory.
func (*Options) GetMaxWriteBufferNumberToMaintain
deprecated
added in
v1.6.20
GetMaxWriteBufferNumberToMaintain gets total maximum number of write buffers to maintain in memory including copies of buffers that have already been flushed. Unlike max_write_buffer_number, this parameter does not affect flushing. This controls the minimum amount of write history that will be available in memory for conflict checking when Transactions are used.
Deprecated: soon
func (*Options) GetMaxWriteBufferSizeToMaintain ¶ added in v1.6.20
GetMaxWriteBufferSizeToMaintain gets the total maximum size(bytes) of write buffers to maintain in memory including copies of buffers that have already been flushed. This parameter only affects trimming of flushed buffers and does not affect flushing. This controls the maximum amount of write history that will be available in memory for conflict checking when Transactions are used. The actual size of write history (flushed Memtables) might be higher than this limit if further trimming will reduce write history total size below this limit. For example, if max_write_buffer_size_to_maintain is set to 64MB, and there are three flushed Memtables, with sizes of 32MB, 20MB, 20MB. Because trimming the next Memtable of size 20MB will reduce total memory usage to 52MB which is below the limit, RocksDB will stop trimming.
func (*Options) GetMemTablePrefixBloomSizeRatio ¶ added in v1.6.21
GetMemTablePrefixBloomSizeRatio returns memtable_prefix_bloom_size_ratio.
func (*Options) GetMempurgeThreshold ¶ added in v1.7.6
GetMempurgeThreshold gets current mempurge threshold value.
func (*Options) GetMemtableHugePageSize ¶ added in v1.6.21
GetMemtableHugePageSize returns the page size for huge page for arena used by the memtable.
func (*Options) GetMinBlobSize ¶ added in v1.6.36
GetMinBlobSize returns the size of the smallest value to be stored separately in a blob file.
func (*Options) GetMinWriteBufferNumberToMerge ¶ added in v1.6.20
GetMinWriteBufferNumberToMerge gets the minimum number of write buffers that will be merged together before writing to storage.
func (*Options) GetNumLevels ¶ added in v1.6.20
GetNumLevels gets the number of levels.
func (*Options) GetPeriodicCompactionSeconds ¶ added in v1.8.11
GetPeriodicCompactionSeconds gets periodic periodic_compaction_seconds option.
func (*Options) GetPrepopulateBlobCache ¶ added in v1.7.10
func (opts *Options) GetPrepopulateBlobCache() PrepopulateBlob
GetPrepopulateBlobCache gets prepopulate blob caching strategy
func (*Options) GetRecycleLogFileNum ¶ added in v1.6.21
GetRecycleLogFileNum returns setting for number of recycling log files.
func (*Options) GetSoftPendingCompactionBytesLimit ¶ added in v1.6.21
GetSoftPendingCompactionBytesLimit returns the threshold at which all writes will be slowed down to at least delayed_write_rate if estimated bytes needed to be compaction exceed this threshold.
func (*Options) GetStatisticsLevel ¶ added in v1.8.7
func (opts *Options) GetStatisticsLevel() StatisticsLevel
GetStatisticsLevel get statistics level.
func (*Options) GetStatisticsString ¶
GetStatisticsString returns the statistics as a string.
func (*Options) GetStatsDumpPeriodSec ¶ added in v1.6.21
GetStatsDumpPeriodSec returns the stats dump period in seconds.
func (*Options) GetStatsPersistPeriodSec ¶ added in v1.6.21
GetStatsPersistPeriodSec returns number of sec that RocksDB periodically dump stats.
func (*Options) GetTableCacheNumshardbits ¶ added in v1.6.21
GetTableCacheNumshardbits returns the number of shards used for table cache.
func (*Options) GetTargetFileSizeBase ¶ added in v1.6.20
GetTargetFileSizeBase gets the target file size base for compaction.
func (*Options) GetTargetFileSizeMultiplier ¶ added in v1.6.20
GetTargetFileSizeMultiplier gets the target file size multiplier for compaction.
func (*Options) GetTickerCount ¶ added in v1.8.7
func (opts *Options) GetTickerCount(tickerType TickerType) uint64
func (*Options) GetWALBytesPerSync ¶ added in v1.6.21
GetWALBytesPerSync same as bytes_per_sync, but applies to WAL files.
func (*Options) GetWALCompression ¶ added in v1.7.0
func (opts *Options) GetWALCompression() CompressionType
GetWALCompression returns compression type of WAL.
func (*Options) GetWALRecoveryMode ¶ added in v1.6.21
func (opts *Options) GetWALRecoveryMode() WALRecoveryMode
GetWALRecoveryMode returns the recovery mode.
func (*Options) GetWALTtlSeconds ¶ added in v1.6.21
GetWALTtlSeconds returns WAL ttl in seconds.
func (*Options) GetWalSizeLimitMb ¶ added in v1.6.21
GetWalSizeLimitMb returns the WAL size limit in MB.
func (*Options) GetWritableFileMaxBufferSize ¶ added in v1.6.21
GetWritableFileMaxBufferSize returns the maximum buffer size that is used by WritableFileWriter. On Windows, we need to maintain an aligned buffer for writes. We allow the buffer to grow until it's size hits the limit in buffered IO and fix the buffer size when using direct IO to ensure alignment of write requests if the logical sector size is unusual
func (*Options) GetWriteBufferSize ¶ added in v1.6.20
GetWriteBufferSize gets write_buffer_size which is set for options
func (*Options) IncreaseParallelism ¶
IncreaseParallelism sets the parallelism.
By default, RocksDB uses only one background thread for flush and compaction. Calling this function will set it up such that total of `total_threads` is used. Good value for `total_threads` is the number of cores. You almost definitely want to call this function if your system is bottlenecked by RocksDB.
func (*Options) InplaceUpdateSupport ¶ added in v1.6.21
InplaceUpdateSupport returns setting for enable/disable thread-safe inplace updates.
func (*Options) IsAtomicFlush ¶ added in v1.6.21
IsAtomicFlush returns setting for atomic flushing. 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) IsBlobFilesEnabled ¶ added in v1.6.36
IsBlobFilesEnabled returns if blob-file setting is enabled.
func (*Options) IsBlobGCEnabled ¶ added in v1.6.36
IsBlobGCEnabled returns if blob garbage collection is enabled.
func (*Options) IsDBIDWrittenToManifest ¶ added in v1.9.5
IsDBIDWrittenToManifest returns if historically DB ID has always been stored in Identity File in DB folder.
func (*Options) IsFdCloseOnExec ¶ added in v1.6.21
IsFdCloseOnExec returns setting for enable/dsiable child process inherit open files.
func (*Options) IsIdentityFileWritten ¶ added in v1.9.7
IsIdentityFileWritten checks if identity file written.
func (*Options) IsManualWALFlush ¶ added in v1.6.37
IsManualWALFlush returns true if WAL is not flushed automatically after each write.
func (*Options) OptimizeFiltersForHits ¶ added in v1.6.21
OptimizeFiltersForHits gets setting for optimize_filters_for_hits.
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) OptimizeLevelStyleCompaction ¶
OptimizeLevelStyleCompaction optimize the DB for leveld compaction.
Default values for some parameters in ColumnFamilyOptions are not optimized for heavy workloads and big datasets, which means you might observe write stalls under some conditions. As a starting point for tuning RocksDB options, use the following two functions: * OptimizeLevelStyleCompaction -- optimizes level style compaction * OptimizeUniversalStyleCompaction -- optimizes universal style compaction Universal style compaction is focused on reducing Write Amplification Factor for big data sets, but increases Space Amplification. You can learn more about the different styles here: https://github.com/facebook/rocksdb/wiki/Rocksdb-Architecture-Guide Make sure to also call IncreaseParallelism(), which will provide the biggest performance gains. Note: we might use more memory than memtable_memory_budget during high write rate period
func (*Options) OptimizeUniversalStyleCompaction ¶
OptimizeUniversalStyleCompaction optimize the DB for universal compaction. See note on OptimizeLevelStyleCompaction.
func (*Options) ParanoidChecks ¶ added in v1.6.20
ParanoidChecks checks if paranoid_check option is set
func (*Options) PrepareForBulkLoad ¶
func (opts *Options) PrepareForBulkLoad()
PrepareForBulkLoad prepare the DB for bulk loading.
All data will be in level 0 without any automatic compaction. It's recommended to manually call CompactRange(NULL, NULL) before reading from the database, because otherwise the read can be very slow.
func (*Options) ReportBackgroundIOStats ¶ added in v1.6.21
ReportBackgroundIOStats returns if measureing IO stats in compactions and flushes is turned on.
func (*Options) SetAdviseRandomOnOpen ¶
SetAdviseRandomOnOpen specifies whether we will hint the underlying file system that the file access pattern is random, when a sst file is opened. Default: true
func (*Options) SetAllowConcurrentMemtableWrites ¶
SetAllowConcurrentMemtableWrites 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) SetAllowIngestBehind ¶
SetAllowIngestBehind sets allow_ingest_behind Set this option to true during creation of database if you want to be able to ingest behind (call IngestExternalFile() skipping keys that already exist, rather than overwriting matching keys). Setting this option to true will affect 2 things: 1) Disable some internal optimizations around SST file compression 2) Reserve bottom-most level for ingested files only. 3) Note that num_levels should be >= 3 if this option is turned on.
Default: false
func (*Options) SetAllowMmapReads ¶
SetAllowMmapReads enable/disable mmap reads for reading sst tables. Default: false
func (*Options) SetAllowMmapWrites ¶
SetAllowMmapWrites enable/disable mmap writes for writing sst tables. Default: false
func (*Options) SetArenaBlockSize ¶
SetArenaBlockSize sets the size of one block in arena memory allocation.
If <= 0, a proper value is automatically calculated (usually 1/10 of writer_buffer_size).
Default: 0
func (*Options) SetAtomicFlush ¶ added in v1.6.17
SetAtomicFlush 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) SetBlobCache ¶ added in v1.7.8
SetBlobCache caches blob.
func (*Options) SetBlobCompactionReadaheadSize ¶ added in v1.6.44
SetBlobCompactionReadaheadSize sets compaction readahead for blob files.
Default: 0
Dynamically changeable through the SetOptions() API.
func (*Options) SetBlobCompressionType ¶ added in v1.6.36
func (opts *Options) SetBlobCompressionType(compressionType CompressionType)
SetBlobCompressionType sets the compression algorithm to use for large values stored in blob files. Note that enable_blob_files has to be set in order for this option to have any effect.
Default: no compression
Dynamically changeable through the API.
func (*Options) SetBlobFileSize ¶ added in v1.6.36
SetBlobFileSize sets the size limit for blob files. When writing blob files, a new file is opened once this limit is reached. Note that enable_blob_files has to be set in order for this option to have any effect.
Default: 256 MB
Dynamically changeable through the API.
func (*Options) SetBlobFileStartingLevel ¶ added in v1.7.5
SetBlobFileStartingLevel enables blob files starting from a certain LSM tree level.
For certain use cases that have a mix of short-lived and long-lived values, it might make sense to support extracting large values only during compactions whose output level is greater than or equal to a specified LSM tree level (e.g. compactions into L1/L2/... or above). This could reduce the space amplification caused by large values that are turned into garbage shortly after being written at the price of some write amplification incurred by long-lived values whose extraction to blob files is delayed.
Default: 0
Dynamically changeable through the SetOptions() API
func (*Options) SetBlobGCAgeCutoff ¶ added in v1.6.36
SetBlobGCAgeCutoff sets the cutoff in terms of blob file age for garbage collection. Blobs in the oldest N blob files will be relocated when encountered during compaction, where N = garbage_collection_cutoff * number_of_blob_files. Note that enable_blob_garbage_collection has to be set in order for this option to have any effect.
Default: 0.25
Dynamically changeable through the API.
func (*Options) SetBlobGCForceThreshold ¶ added in v1.6.43
SetBlobGCForceThreshold if the ratio of garbage in the oldest blob files exceeds this threshold, targeted compactions are scheduled in order to force garbage collecting the blob files in question, assuming they are all eligible based on the value of blob_garbage_collection_age_cutoff above. This option is currently only supported with leveled compactions. Note that enable_blob_garbage_collection has to be set in order for this option to have any effect.
Default: 1.0
func (*Options) SetBlockBasedTableFactory ¶
func (opts *Options) SetBlockBasedTableFactory(value *BlockBasedTableOptions)
SetBlockBasedTableFactory sets the block based table factory.
func (*Options) SetBloomLocality ¶
SetBloomLocality sets the bloom locality.
Control locality of bloom filter probes to improve cache miss rate. This option only applies to memtable prefix bloom and plaintable prefix bloom. It essentially limits the max number of cache lines each bloom filter check can touch. This optimization is turned off when set to 0. The number should never be greater than number of probes. This option can boost performance for in-memory workload but should use with care since it can cause higher false positive rate. Default: 0
func (*Options) SetBottommostCompression ¶ added in v1.6.20
func (opts *Options) SetBottommostCompression(value CompressionType)
SetBottommostCompression sets the compression algorithm for bottommost level.
func (*Options) SetBottommostCompressionOptions ¶ added in v1.6.20
func (opts *Options) SetBottommostCompressionOptions(value CompressionOptions, enabled bool)
SetBottommostCompressionOptions sets different options for compression algorithms, for bottommost.
`enabled` true to use these compression options.
func (*Options) SetBottommostCompressionOptionsMaxDictBufferBytes ¶ added in v1.6.35
SetBottommostCompressionOptionsMaxDictBufferBytes limits on data buffering when gathering samples to build a dictionary, for bottom most level. Zero means no limit. When dictionary is disabled (`max_dict_bytes == 0`), enabling this limit (`max_dict_buffer_bytes != 0`) has no effect.
In compaction, the buffering is limited to the target file size (see `target_file_size_base` and `target_file_size_multiplier`) even if this setting permits more buffering. Since we cannot determine where the file should be cut until data blocks are compressed with dictionary, buffering more than the target file size could lead to selecting samples that belong to a later output SST.
Limiting too strictly may harm dictionary effectiveness since it forces RocksDB to pick samples from the initial portion of the output SST, which may not be representative of the whole file. Configuring this limit below `zstd_max_train_bytes` (when enabled) can restrict how many samples we can pass to the dictionary trainer. Configuring it below `max_dict_bytes` can restrict the size of the final dictionary.
Default: 0 (unlimited)
func (*Options) SetBottommostCompressionOptionsZstdDictTrainer ¶ added in v1.7.12
SetBottommostCompressionOptionsZstdDictTrainer uses/not use zstd trainer to generate dictionaries. When this option is set to true, zstd_max_train_bytes of training data sampled from max_dict_buffer_bytes buffered data will be passed to zstd dictionary trainer to generate a dictionary of size max_dict_bytes.
When this option is false, zstd's API ZDICT_finalizeDictionary() will be called to generate dictionaries. zstd_max_train_bytes of training sampled data will be passed to this API. Using this API should save CPU time on dictionary training, but the compression ratio may not be as good as using a dictionary trainer.
Default: true
func (*Options) SetBottommostCompressionOptionsZstdMaxTrainBytes ¶ added in v1.6.20
SetBottommostCompressionOptionsZstdMaxTrainBytes sets maximum size of training data passed to zstd's dictionary trainer for bottommost level. Using zstd's dictionary trainer can achieve even better compression ratio improvements than using `max_dict_bytes` alone.
`enabled` true to use these compression options.
func (*Options) SetBytesPerSync ¶
SetBytesPerSync sets the bytes per sync.
Allows OS to incrementally sync files to disk while they are being written, asynchronously, in the background. Issue one request for every bytes_per_sync written. Default: 0 (disabled)
func (*Options) SetCFPaths ¶ added in v1.8.11
SetCFPaths sets cf_paths option. cf_paths is a list of paths where SST files for this column family can be put into, with its target size.
Similar to db_paths, newer data is placed into paths specified earlier in the vector while older data gradually moves to paths specified later in the vector.
Note that, if a path is supplied to multiple column families, it would have files and total size from all the column families combined. User should provision for the total size(from all the column families) in such cases.
If left empty, db_paths will be used. Default: empty
func (*Options) SetCompactionFilter ¶
func (opts *Options) SetCompactionFilter(value CompactionFilter)
SetCompactionFilter sets the specified compaction filter which will be applied on compactions.
Default: nil
func (*Options) SetCompactionPri ¶ added in v1.9.3
func (opts *Options) SetCompactionPri(pri CompactionPri)
SetCompactionPri sets in level-based compaction.
Default: KMinOverlappingRatioCompactionPri
func (*Options) SetCompactionStyle ¶
func (opts *Options) SetCompactionStyle(value CompactionStyle)
SetCompactionStyle sets compaction style.
Default: LevelCompactionStyle
func (*Options) SetComparator ¶
func (opts *Options) SetComparator(cmp *Comparator)
SetComparator sets the comparator which define the order of keys in the table. This operation is `move`, thus underlying native c-pointer is owned by Options. `cmp` is no longer usable.
Default: a comparator that uses lexicographic byte-wise ordering
func (*Options) SetCompression ¶
func (opts *Options) SetCompression(value CompressionType)
SetCompression sets the compression algorithm.
Default: SnappyCompression, which gives lightweight but fast compression.
func (*Options) SetCompressionOptions ¶
func (opts *Options) SetCompressionOptions(value CompressionOptions)
SetCompressionOptions sets different options for compression algorithms.
func (*Options) SetCompressionOptionsMaxDictBufferBytes ¶ added in v1.6.35
SetCompressionOptionsMaxDictBufferBytes limits on data buffering when gathering samples to build a dictionary. Zero means no limit. When dictionary is disabled (`max_dict_bytes == 0`), enabling this limit (`max_dict_buffer_bytes != 0`) has no effect.
In compaction, the buffering is limited to the target file size (see `target_file_size_base` and `target_file_size_multiplier`) even if this setting permits more buffering. Since we cannot determine where the file should be cut until data blocks are compressed with dictionary, buffering more than the target file size could lead to selecting samples that belong to a later output SST.
Limiting too strictly may harm dictionary effectiveness since it forces RocksDB to pick samples from the initial portion of the output SST, which may not be representative of the whole file. Configuring this limit below `zstd_max_train_bytes` (when enabled) can restrict how many samples we can pass to the dictionary trainer. Configuring it below `max_dict_bytes` can restrict the size of the final dictionary.
Default: 0 (unlimited)
func (*Options) SetCompressionOptionsParallelThreads ¶ added in v1.6.37
SetCompressionOptionsParallelThreads sets number of threads for parallel compression. Parallel compression is enabled only if threads > 1.
This option is valid only when BlockBasedTable is used.
When parallel compression is enabled, SST size file sizes might be more inflated compared to the target size, because more data of unknown compressed size is in flight when compression is parallelized. To be reasonably accurate, this inflation is also estimated by using historical compression ratio and current bytes inflight.
Default: 1.
Note: THE FEATURE IS STILL EXPERIMENTAL
func (*Options) SetCompressionOptionsZstdDictTrainer ¶ added in v1.7.4
SetCompressionOptionsZstdDictTrainer uses/not use zstd trainer to generate dictionaries. When this option is set to true, zstd_max_train_bytes of training data sampled from max_dict_buffer_bytes buffered data will be passed to zstd dictionary trainer to generate a dictionary of size max_dict_bytes.
When this option is false, zstd's API ZDICT_finalizeDictionary() will be called to generate dictionaries. zstd_max_train_bytes of training sampled data will be passed to this API. Using this API should save CPU time on dictionary training, but the compression ratio may not be as good as using a dictionary trainer.
Default: true
func (*Options) SetCompressionOptionsZstdMaxTrainBytes ¶ added in v1.6.20
SetCompressionOptionsZstdMaxTrainBytes sets maximum size of training data passed to zstd's dictionary trainer. Using zstd's dictionary trainer can achieve even better compression ratio improvements than using `max_dict_bytes` alone.
The training data will be used to generate a dictionary of max_dict_bytes.
Default: 0.
func (*Options) SetCompressionPerLevel ¶
func (opts *Options) SetCompressionPerLevel(value []CompressionType)
SetCompressionPerLevel sets different compression algorithm per level.
Different levels can have different compression policies. There are cases where most lower levels would like to quick compression algorithm while the higher levels (which have more data) use compression algorithms that have better compression but could be slower. This array should have an entry for each level of the database. This array overrides the value specified in the previous field '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) SetCuckooTableFactory ¶
func (opts *Options) SetCuckooTableFactory(cuckooOpts *CuckooTableOptions)
SetCuckooTableFactory sets to use cuckoo table factory.
Note: move semantic. Don't use cuckoo options after calling this function.
Default: nil.
func (*Options) SetDBPaths ¶
SetDBPaths sets the db_paths option.
db_paths is a list of paths where SST files can be put into, with its target size. Newer data is placed into paths specified earlier in the vector while older data gradually moves to paths specified later in the vector.
For example, you have a flash device with 10GB allocated for the DB, as well as a hard drive of 2TB, you should config it to be:
[{"/flash_path", 10GB}, {"/hard_drive", 2TB}]
The system will try to guarantee data under each path is close to but not larger than the target size. But current and future file sizes used by determining where to place a file are based on best-effort estimation, which means there is a chance that the actual size under the directory is slightly more than target size under some workloads. User should give some buffer room for those cases.
If none of the paths has sufficient room to place a file, the file will be placed to the last path anyway, despite to the target size.
Placing newer data to earlier paths is also best-efforts. User should expect user files to be placed in higher levels in some extreme cases.
If left empty, only one path will be used, which is db_name passed when opening the DB.
Default: empty
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) SetDeleteObsoleteFilesPeriodMicros ¶
SetDeleteObsoleteFilesPeriodMicros sets the periodicity when obsolete files get deleted.
The files that get out of scope by compaction process will still get automatically delete on every compaction, regardless of this setting. Default: 6 hours
func (*Options) SetDisableAutoCompactions ¶
SetDisableAutoCompactions enable/disable automatic compactions.
Manual compactions can still be issued on this database.
Default: false
func (*Options) SetDumpMallocStats ¶ added in v1.6.19
SetDumpMallocStats if true, then print malloc stats together with rocksdb.stats when printing to LOG.
func (*Options) SetEnablePipelinedWrite ¶
SetEnablePipelinedWrite enables pipelined write.
By default, a single write thread queue is maintained. 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.
If enable_pipelined_write is true, separate write thread queue is maintained for WAL write and memtable write. A write thread first enter WAL writer queue and then memtable writer queue. Pending thread on the WAL writer queue thus only have to wait for previous writers to finish their WAL writing but not the memtable writing. Enabling the feature may improve write throughput and reduce latency of the prepare phase of two-phase commit.
Default: false
func (*Options) SetEnableWriteThreadAdaptiveYield ¶
SetEnableWriteThreadAdaptiveYield if true, threads synchronizing with the write batch group leader will wait for up to write_thread_max_yield_usec before blocking on a mutex. This can substantially improve throughput for concurrent workloads, regardless of whether allow_concurrent_memtable_write is enabled.
Default: true
func (*Options) SetEnv ¶
SetEnv sets the specified object to interact with the environment, e.g. to read/write files, schedule background work, etc.
NOTE: move semantic. Don't use env after calling this function
func (*Options) SetErrorIfExists ¶
SetErrorIfExists specifies whether an error should be raised if the database already exists. Default: false
func (*Options) SetFIFOCompactionOptions ¶
func (opts *Options) SetFIFOCompactionOptions(value *FIFOCompactionOptions)
SetFIFOCompactionOptions sets the options for FIFO compaction style.
Note: move semantic. Don't use fifo compaction options after calling this function
Default: nil
func (*Options) SetHardPendingCompactionBytesLimit ¶
SetHardPendingCompactionBytesLimit sets the bytes threshold at which all writes are stopped if estimated bytes needed to be compaction exceed this threshold.
Default: 256GB
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 (opts *Options) SetHashSkipListRep(bucketCount uint, 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) SetInfoLog ¶ added in v1.9.1
SetInfoLog sets info logger.
func (*Options) SetInfoLogLevel ¶
func (opts *Options) SetInfoLogLevel(value InfoLogLevel)
SetInfoLogLevel sets the info log level.
Default: InfoInfoLogLevel
func (*Options) SetInplaceUpdateNumLocks ¶
SetInplaceUpdateNumLocks sets the number of locks used for inplace update.
Default: 10000, if inplace_update_support = true, else 0.
func (*Options) SetInplaceUpdateSupport ¶
SetInplaceUpdateSupport enable/disable thread-safe inplace updates.
Requires updates if * key exists in current memtable * new sizeof(new_value) <= sizeof(old_value) * old_value for that key is a put i.e. kTypeValue
Default: false.
func (*Options) SetIsFdCloseOnExec ¶
SetIsFdCloseOnExec enable/dsiable child process inherit open files. Default: true
func (*Options) SetKeepLogFileNum ¶
SetKeepLogFileNum sets the maximum 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: 2
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: 20
func (*Options) SetLevel0StopWritesTrigger ¶
SetLevel0StopWritesTrigger sets the maximum number of level-0 files. We stop writes at this point.
Default: 36
func (*Options) SetLevelCompactionDynamicLevelBytes ¶
SetLevelCompactionDynamicLevelBytes specifies whether to pick target size of each level dynamically.
We will pick a base level b >= 1. L0 will be directly merged into level b, instead of always into level 1. Level 1 to b-1 need to be empty. We try to pick b and its target size so that
- target size is in the range of (max_bytes_for_level_base / max_bytes_for_level_multiplier, max_bytes_for_level_base]
- target size of the last level (level num_levels-1) equals to extra size of the level.
At the same time max_bytes_for_level_multiplier and max_bytes_for_level_multiplier_additional are still satisfied.
With this option on, from an empty DB, we make last level the base level, which means merging L0 data into the last level, until it exceeds max_bytes_for_level_base. And then we make the second last level to be base level, to start to merge L0 data to second last level, with its target size to be 1/max_bytes_for_level_multiplier of the last level's extra size. After the data accumulates more so that we need to move the base level to the third last one, and so on.
For example, assume max_bytes_for_level_multiplier=10, num_levels=6, and max_bytes_for_level_base=10MB. Target sizes of level 1 to 5 starts with: [- - - - 10MB] with base level is level. Target sizes of level 1 to 4 are not applicable because they will not be used. Until the size of Level 5 grows to more than 10MB, say 11MB, we make base target to level 4 and now the targets looks like: [- - - 1.1MB 11MB] While data are accumulated, size targets are tuned based on actual data of level 5. When level 5 has 50MB of data, the target is like: [- - - 5MB 50MB] Until level 5's actual size is more than 100MB, say 101MB. Now if we keep level 4 to be the base level, its target size needs to be 10.1MB, which doesn't satisfy the target size range. So now we make level 3 the target size and the target sizes of the levels look like: [- - 1.01MB 10.1MB 101MB] In the same way, while level 5 further grows, all levels' targets grow, like [- - 5MB 50MB 500MB] Until level 5 exceeds 1000MB and becomes 1001MB, we make level 2 the base level and make levels' target sizes like this: [- 1.001MB 10.01MB 100.1MB 1001MB] and go on...
By doing it, we give max_bytes_for_level_multiplier a priority against max_bytes_for_level_base, for a more predictable LSM tree shape. It is useful to limit worse case space amplification.
max_bytes_for_level_multiplier_additional is ignored with this flag on.
Turning this feature on or off for an existing DB can cause unexpected LSM tree structure so it's not recommended.
Default: false
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) SetManifestPreallocationSize ¶
SetManifestPreallocationSize sets the number of bytes to preallocate (via fallocate) the manifest files.
Default is 4MB, which is reasonable to reduce random IO as well as prevent overallocation for mounts that preallocate large amounts of data (such as xfs's allocsize option).
func (*Options) SetManualWALFlush ¶ added in v1.6.37
SetManualWALFlush if true WAL is not flushed automatically after each write. Instead it relies on manual invocation of db.FlushWAL to write the WAL buffer to its file.
Default: false
func (*Options) SetMaxBackgroundCompactions
deprecated
SetMaxBackgroundCompactions sets the maximum number of concurrent background compaction jobs, submitted to the default LOW priority thread pool Default: 1
Deprecated: RocksDB automatically decides this based on the value of max_background_jobs. For backwards compatibility we will set `max_background_jobs = max_background_compactions + max_background_flushes` in the case where user sets at least one of `max_background_compactions` or `max_background_flushes` (we replace -1 by 1 in case one option is unset).
func (*Options) SetMaxBackgroundFlushes
deprecated
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
Deprecated: RocksDB automatically decides this based on the value of max_background_jobs. For backwards compatibility we will set `max_background_jobs = max_background_compactions + max_background_flushes` in the case where user sets at least one of `max_background_compactions` or `max_background_flushes`.
func (*Options) SetMaxBackgroundJobs ¶
SetMaxBackgroundJobs maximum number of concurrent background jobs (compactions and flushes).
Default: 2
Dynamically changeable through SetDBOptions() API.
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) SetMaxBytesForLevelMultiplierAdditional ¶
SetMaxBytesForLevelMultiplierAdditional sets different max-size multipliers for different levels.
These are multiplied by max_bytes_for_level_multiplier to arrive at the max-size of each level.
Default: 1 for each level
func (*Options) SetMaxCompactionBytes ¶
SetMaxCompactionBytes sets the maximum number of bytes in all compacted files. We try to limit number of bytes in one compaction to be lower than this threshold. But it's not guaranteed. Value 0 will be sanitized.
Default: result.target_file_size_base * 25
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 maximum 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) SetMaxManifestFileSize ¶
SetMaxManifestFileSize sets the maximum manifest file size until is rolled over. The older manifest file be deleted. Default: MAX_INT so that roll-over does not take place.
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: -1 - unlimited
func (*Options) SetMaxSequentialSkipInIterations ¶
SetMaxSequentialSkipInIterations specifies whether an iteration->Next() sequentially skips over keys with the same user-key or not.
This number specifies the number of keys (with the same userkey) that will be sequentially skipped before a reseek is issued.
Default: 8
func (*Options) SetMaxSubcompactions ¶
SetMaxSubcompactions represents 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) SetMaxSuccessiveMerges ¶
SetMaxSuccessiveMerges sets the maximum number of successive merge operations on a key in the memtable.
When a merge operation is added to the memtable and the maximum number of successive merges is reached, the value of the key will be calculated and inserted into the memtable instead of the merge operation. This will ensure that there are never more than max_successive_merges merge operations in the memtable. Default: 0 (disabled)
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 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) SetMaxWriteBufferNumberToMaintain
deprecated
SetMaxWriteBufferNumberToMaintain sets total maximum number of write buffers to maintain in memory including copies of buffers that have already been flushed. Unlike max_write_buffer_number, this parameter does not affect flushing. This controls the minimum amount of write history that will be available in memory for conflict checking when Transactions are used.
When using an OptimisticTransactionDB: If this value is too low, some transactions may fail at commit time due to not being able to determine whether there were any write conflicts.
When using a TransactionDB: If Transaction::SetSnapshot is used, TransactionDB will read either in-memory write buffers or SST files to do write-conflict checking. Increasing this value can reduce the number of reads to SST files done for conflict detection.
Setting this value to 0 will cause write buffers to be freed immediately after they are flushed. If this value is set to -1, 'max_write_buffer_number' will be used.
Default: If using a TransactionDB/OptimisticTransactionDB, the default value will be set to the value of 'max_write_buffer_number' if it is not explicitly set by the user. Otherwise, the default is 0.
Deprecated: soon
func (*Options) SetMaxWriteBufferSizeToMaintain ¶ added in v1.6.11
SetMaxWriteBufferSizeToMaintain is the total maximum size(bytes) of write buffers to maintain in memory including copies of buffers that have already been flushed. This parameter only affects trimming of flushed buffers and does not affect flushing. This controls the maximum amount of write history that will be available in memory for conflict checking when Transactions are used. The actual size of write history (flushed Memtables) might be higher than this limit if further trimming will reduce write history total size below this limit. For example, if max_write_buffer_size_to_maintain is set to 64MB, and there are three flushed Memtables, with sizes of 32MB, 20MB, 20MB. Because trimming the next Memtable of size 20MB will reduce total memory usage to 52MB which is below the limit, RocksDB will stop trimming.
When using an OptimisticTransactionDB: If this value is too low, some transactions may fail at commit time due to not being able to determine whether there were any write conflicts.
When using a TransactionDB: If Transaction::SetSnapshot is used, TransactionDB will read either in-memory write buffers or SST files to do write-conflict checking. Increasing this value can reduce the number of reads to SST files done for conflict detection.
Setting this value to 0 will cause write buffers to be freed immediately after they are flushed. If this value is set to -1, 'max_write_buffer_number * write_buffer_size' will be used.
Default: If using a TransactionDB/OptimisticTransactionDB, the default value will be set to the value of 'max_write_buffer_number * write_buffer_size' if it is not explicitly set by the user. Otherwise, the default is 0.
func (*Options) SetMemTablePrefixBloomSizeRatio ¶
SetMemTablePrefixBloomSizeRatio sets memtable_prefix_bloom_size_ratio if prefix_extractor is set and memtable_prefix_bloom_size_ratio is not 0, create prefix bloom for memtable with the size of write_buffer_size * memtable_prefix_bloom_size_ratio. If it is larger than 0.25, it is sanitized to 0.25.
Default: 0 (disable)
func (*Options) SetMempurgeThreshold ¶ added in v1.7.6
SetMempurgeThreshold is experimental function to set mempurge threshold.
It is used to activate or deactive the Mempurge feature (memtable garbage collection, which is deactivated by default).
At every flush, the total useful payload (total entries minus garbage entries) is estimated as a ratio [useful payload bytes]/[size of a memtable (in bytes)]. This ratio is then compared to this `threshold` value:
- if ratio<threshold: the flush is replaced by a mempurge operation
- else: a regular flush operation takes place.
Threshold values:
0.0: mempurge deactivated (default). 1.0: recommended threshold value. >1.0 : aggressive mempurge. 0 < threshold < 1.0: mempurge triggered only for very low useful payload ratios.
func (*Options) SetMemtableHugePageSize ¶
SetMemtableHugePageSize sets the page size for huge page for arena used by the memtable. If <=0, it won't allocate from huge page but from malloc. Users are responsible to reserve huge pages for it to be allocated. For example:
sysctl -w vm.nr_hugepages=20
See linux doc Documentation/vm/hugetlbpage.txt If there isn't enough free huge page available, it will fall back to malloc.
Dynamically changeable through SetOptions() API
func (*Options) SetMemtableVectorRep ¶
func (opts *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) SetMemtableWholeKeyFiltering ¶ added in v1.6.19
SetMemtableWholeKeyFiltering enable whole key bloom filter in memtable. Note this will only take effect if memtable_prefix_bloom_size_ratio is not 0. Enabling whole key filtering can potentially reduce CPU usage for point-look-ups.
Default: false (disable)
Dynamically changeable through SetOptions() API
func (*Options) SetMergeOperator ¶
func (opts *Options) SetMergeOperator(value MergeOperator)
SetMergeOperator sets the merge operator which will be called if a merge operations are used.
Default: nil
func (*Options) SetMinBlobSize ¶ added in v1.6.36
SetMinBlogSize sets the size of the smallest value to be stored separately in a blob file. Values which have an uncompressed size smaller than this threshold are stored alongside the keys in SST files in the usual fashion. A value of zero for this option means that all values are stored in blob files. Note that enable_blob_files has to be set in order for this option to have any effect.
Default: 0
Dynamically changeable through the API.
func (*Options) SetMinLevelToCompress ¶
SetMinLevelToCompress sets the start level to use compression.
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) SetNativeComparator ¶ added in v1.6.47
SetNativeComparator sets the comparator which define the order of keys in the table.
Default: a comparator that uses lexicographic byte-wise ordering
func (*Options) SetOptimizeFiltersForHits ¶
SetOptimizeFiltersForHits sets optimize_filters_for_hits This flag specifies that the implementation should optimize the filters mainly for cases where keys are found rather than also optimize for keys missed. This would be used in cases where the application knows that there are very few misses or the performance in the case of misses is not important.
For now, this flag allows us to not store filters for the last level i.e the largest level which contains data of the LSM store. For keys which are hits, the filters in this level are not useful because we will search for the data anyway. NOTE: the filters in other levels are still useful even for key hit because they tell us whether to look in that level or go to the higher level.
Default: false
func (*Options) SetParanoidChecks ¶
SetParanoidChecks enable/disable paranoid checks.
If true, the implementation will do aggressive checking of the data it is processing and will stop early if it detects any errors. This may have unforeseen ramifications: for example, a corruption of one DB entry may cause a large number of entries to become unreadable or for the entire DB to become unopenable. If any of the writes to the database fails (Put, Delete, Merge, Write), the database will switch to read-only mode and fail all other Write operations. Default: false
func (*Options) SetPeriodicCompactionSeconds ¶ added in v1.8.11
SetPeriodicCompactionSeconds sets periodic_compaction_seconds option.
This option has different meanings for different compaction styles:
Leveled: files older than `periodic_compaction_seconds` will be picked up
for compaction and will be re-written to the same level as they were before.
FIFO: not supported. Setting this option has no effect for FIFO compaction.
Universal: when there are files older than `periodic_compaction_seconds`,
rocksdb will try to do as large a compaction as possible including the last level. Such compaction is only skipped if only last level is to be compacted and no file in last level is older than `periodic_compaction_seconds`. See more in UniversalCompactionBuilder::PickPeriodicCompaction(). For backward compatibility, the effective value of this option takes into account the value of option `ttl`. The logic is as follows: - both options are set to 30 days if they have the default value. - if both options are zero, zero is picked. Otherwise, we take the min value among non-zero options values (i.e. takes the stricter limit).
One main use of the feature is to make sure a file goes through compaction filters periodically. Users can also use the feature to clear up SST files using old format.
A file's age is computed by looking at file_creation_time or creation_time table properties in order, if they have valid non-zero values; if not, the age is based on the file's last modified time (given by the underlying Env).
This option only supports block based table format for any compaction style.
unit: seconds. Ex: 7 days = 7 * 24 * 60 * 60
Values: 0: Turn off Periodic compactions. UINT64_MAX - 1 (0xfffffffffffffffe) is special flag to allow RocksDB to pick default.
Default: 30 days if using block based table format + compaction filter +
leveled compaction or block based table format + universal compaction. 0 (disabled) otherwise.
Dynamically changeable through SetOptions() API
func (*Options) SetPlainTableFactory ¶
func (opts *Options) SetPlainTableFactory( keyLen uint32, bloomBitsPerKey int, hashTableRatio float64, indexSparseness uint, hugePageTlbSize int, encodeType EncodingType, fullScanMode bool, storeIndexInFile bool, )
SetPlainTableFactory sets a plain table factory with prefix-only seek.
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.
keyLen: plain table has optimization for fix-sized keys, which can be specified via keyLen.
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.
hugePageTlbSize: if <=0, allocate hash indexes and blooms from malloc. Otherwise from huge page TLB. The user needs to reserve huge pages for it to be allocated, like: sysctl -w vm.nr_hugepages=20 See linux doc Documentation/vm/hugetlbpage.txt
encodeType: how to encode the keys. See enum EncodingType above for the choices. The value will determine how to encode keys when writing to a new SST file. This value will be stored inside the SST file which will be used when reading from the file, which makes it possible for users to choose different encoding type when reopening a DB. Files with different encoding types can co-exist in the same DB and can be read.
fullScanMode: mode for reading the whole file one record by one without using the index.
storeIndexInFile: compute plain table index and bloom filter during file building and store it in file. When reading file, index will be mapped instead of recomputation.
func (*Options) SetPrefixExtractor ¶
func (opts *Options) SetPrefixExtractor(value 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().
Note: move semantic. Don't use slice transform after calling this function.
func (*Options) SetPrepopulateBlobCache ¶ added in v1.7.10
func (opts *Options) SetPrepopulateBlobCache(strategy PrepopulateBlob)
SetPrepopulateBlobCache sets strategy for prepopulate blob caching strategy.
If enabled, prepopulate warm/hot blobs which are already in memory into blob cache at the time of flush. On a flush, the blob that is in memory (in memtables) get flushed to the device. If using Direct IO, additional IO is incurred to read this blob back into memory again, which is avoided by enabling this option. This further helps if the workload exhibits high temporal locality, where most of the reads go to recently written data. This also helps in case of the remote file system since it involves network traffic and higher latencies.
Default: disabled
Dynamically changeable through this API
func (*Options) SetRateLimiter ¶
func (opts *Options) SetRateLimiter(rateLimiter *RateLimiter)
SetRateLimiter sets the rate limiter of the options. Use to control write rate of flush and compaction. Flush has higher priority than compaction. Rate limiting is disabled if nullptr. If rate limiter is enabled, bytes_per_sync is set to 1MB by default.
Note: move semantic. Don't use rate limiter after calling this function
Default: nil
func (*Options) SetRecycleLogFileNum ¶
SetRecycleLogFileNum if non-zero, we will reuse previously written log files for new logs, overwriting the old data. The value indicates how many such files we will keep around at any point in time for later use. This is more efficient because the blocks are already allocated and fdatasync does not need to update the inode after each write. Default: 0
func (*Options) SetReportBackgroundIOStats ¶
SetReportBackgroundIOStats measures IO stats in compactions and flushes, if true.
Default: false
Dynamically changeable through SetOptions() API
func (*Options) SetRowCache ¶ added in v1.6.18
SetRowCache set global cache for table-level rows.
Default: nil (disabled) Not supported in ROCKSDB_LITE mode!
func (*Options) SetSkipCheckingSSTFileSizesOnDBOpen ¶ added in v1.6.18
SetSkipCheckingSSTFileSizesOnDBOpen skips checking sst file sizes on db openning
Default: false
func (*Options) SetSkipStatsUpdateOnDBOpen ¶
SetSkipStatsUpdateOnDBOpen if true, then DB::Open() will not update the statistics used to optimize compaction decision by loading table properties from many files. Turning off this feature will improve DBOpen time especially in disk environment.
Default: false
func (*Options) SetSoftPendingCompactionBytesLimit ¶
SetSoftPendingCompactionBytesLimit sets the threshold at which all writes will be slowed down to at least delayed_write_rate if estimated bytes needed to be compaction exceed this threshold.
Default: 64GB
func (*Options) SetStatisticsLevel ¶ added in v1.8.7
func (opts *Options) SetStatisticsLevel(level StatisticsLevel)
SetStatisticsLevel set statistics level.
func (*Options) SetStatsDumpPeriodSec ¶
SetStatsDumpPeriodSec sets the stats dump period in seconds.
If not zero, dump stats to LOG every stats_dump_period_sec Default: 3600 (1 hour)
func (*Options) SetStatsPersistPeriodSec ¶ added in v1.6.21
SetStatsPersistPeriodSec if not zero, dump rocksdb.stats to RocksDB every stats_persist_period_sec
Default: 600
func (*Options) SetTTL ¶ added in v1.8.14
SetTTL sets TTL. This option has different meanings for different compaction styles:
Leveled: Non-bottom-level files with all keys older than TTL will go
through the compaction process. This usually happens in a cascading way so that those entries will be compacted to bottommost level/file. The feature is used to remove stale entries that have been deleted or updated from the file system.
FIFO: Files with all keys older than TTL will be deleted. TTL is only
supported if option max_open_files is set to -1.
Universal: users should only set the option `periodic_compaction_seconds`
below instead. For backward compatibility, this option has the same meaning as `periodic_compaction_seconds`. See more in comments for `periodic_compaction_seconds` on the interaction between these two options.
This option only supports block based table format for any compaction style.
unit: seconds. Ex: 1 day = 1 * 24 * 60 * 60 0 means disabling. UINT64_MAX - 1 (0xfffffffffffffffe) is special flag to allow RocksDB to pick default.
Default: 30 days if using block based table. 0 (disable) otherwise.
Dynamically changeable through SetOptions() API Note that dynamically changing this option only works for leveled and FIFO compaction. For universal compaction, dynamically changing this option has no effect, users should dynamically change `periodic_compaction_seconds` instead.
func (*Options) SetTableCacheNumshardbits ¶
SetTableCacheNumshardbits sets the number of shards used for table cache. Default: 4
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: 1MB
func (*Options) SetTargetFileSizeMultiplier ¶
SetTargetFileSizeMultiplier sets the target file size multiplier for compaction.
Default: 1
func (*Options) SetUint64AddMergeOperator ¶ added in v1.6.21
func (opts *Options) SetUint64AddMergeOperator()
SetUint64AddMergeOperator set add/merge operator.
func (*Options) SetUniversalCompactionOptions ¶
func (opts *Options) SetUniversalCompactionOptions(value *UniversalCompactionOptions)
SetUniversalCompactionOptions sets the options needed to support Universal Style compactions.
Note: move semantic. Don't use universal compaction options after calling this function
Default: nil
func (*Options) SetUnorderedWrite ¶
SetUnorderedWrite sets unordered_write to true trades higher write throughput with relaxing the immutability guarantee of snapshots. This violates the repeatability one expects from ::Get from a snapshot, as well as ::MultiGet and Iterator's consistent-point-in-time view property. If the application cannot tolerate the relaxed guarantees, it can implement its own mechanisms to work around that and yet benefit from the higher throughput. Using TransactionDB with WRITE_PREPARED write policy and two_write_queues=true is one way to achieve immutable snapshots despite unordered_write.
By default, i.e., when it is false, rocksdb does not advance the sequence number for new snapshots unless all the writes with lower sequence numbers are already finished. This provides the immutability that we except from snapshots. Moreover, since Iterator and MultiGet internally depend on snapshots, the snapshot immutability results into Iterator and MultiGet offering consistent-point-in-time view. If set to true, although Read-Your-Own-Write property is still provided, the snapshot immutability property is relaxed: the writes issued after the snapshot is obtained (with larger sequence numbers) will be still not visible to the reads from that snapshot, however, there still might be pending writes (with lower sequence number) that will change the state visible to the snapshot after they are landed to the memtable.
Default: false
func (*Options) SetUseAdaptiveMutex ¶
SetUseAdaptiveMutex enable/disable adaptive mutex, which spins in the user space before resorting to kernel.
This could reduce context switch when the mutex is not heavily contended. However, if the mutex is hot, we could end up wasting spin time. Default: false
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) SetWALBytesPerSync ¶
SetWALBytesPerSync same as bytes_per_sync, but applies to WAL files.
Default: 0, turned off
Dynamically changeable through SetDBOptions() API.
func (*Options) SetWALCompression ¶ added in v1.7.0
func (opts *Options) SetWALCompression(cType CompressionType)
SetWALCompression sets compression type for WAL.
Note: this feature is WORK IN PROGRESS If enabled WAL records will be compressed before they are written. Only zstd is supported. Compressed WAL records will be read in supported versions regardless of the wal_compression settings.
Default: no compression
func (*Options) SetWALRecoveryMode ¶
func (opts *Options) SetWALRecoveryMode(mode WALRecoveryMode)
SetWALRecoveryMode sets the recovery mode. Recovery mode to control the consistency while replaying WAL.
Default: PointInTimeRecovery
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 itopts is 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) SetWritableFileMaxBufferSize ¶
SetWritableFileMaxBufferSize is the maximum buffer size that is used by WritableFileWriter. On Windows, we need to maintain an aligned buffer for writes. We allow the buffer to grow until it's size hits the limit in buffered IO and fix the buffer size when using direct IO to ensure alignment of write requests if the logical sector size is unusual
Default: 1024 * 1024 (1 MB)
Dynamically changeable through SetDBOptions() API.
func (*Options) SetWriteBufferManager ¶ added in v1.8.11
func (opts *Options) SetWriteBufferManager(wbm *WriteBufferManager)
SetWriteBufferManager binds with a WriteBufferManager.
The memory usage of memtable will report to this object. The same object can be passed into multiple DBs and it will track the sum of size of all the DBs. If the total size of all live memtables of all the DBs exceeds a limit, a flush will be triggered in the next DB to which the next write is issued, as long as there is one or more column family not already flushing.
If the object is only passed to one DB, the behavior is the same as db_write_buffer_size. When write_buffer_manager is set, the value set will override db_write_buffer_size.
This feature is disabled by default. Specify a non-zero value to enable it.
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: 64MB
func (*Options) SkipCheckingSSTFileSizesOnDBOpen ¶ added in v1.6.20
SkipCheckingSSTFileSizesOnDBOpen checks if skips_checking_sst_file_sizes_on_db_openning is set.
func (*Options) SkipStatsUpdateOnDBOpen ¶ added in v1.6.20
SkipStatsUpdateOnDBOpen checks if skip_stats_update_on_db_open is set.
func (*Options) ToggleTrackAndVerifyWALsInManifestFlag ¶ added in v1.9.5
ToggleTrackAndVerifyWALsInManifestFlag if true, the log numbers and sizes of the synced WALs are tracked in MANIFEST. During DB recovery, if a synced WAL is missing from disk, or the WAL's size does not match the recorded size in MANIFEST, an error will be reported and the recovery will be aborted.
This is one additional protection against WAL corruption besides the per-WAL-entry checksum.
Note that this option does not work with secondary instance. Currently, only syncing closed WALs are tracked. Calling `DB::SyncWAL()`, etc. or writing with `WriteOptions::sync=true` to sync the live WAL is not tracked for performance/efficiency reasons.
Default: false
func (*Options) TrackAndVerifyWALsInManifestFlag ¶ added in v1.9.5
TrackAndVerifyWALsInManifestFlag checks if the log numbers and sizes of the synced WALs are tracked in MANIFEST.
func (*Options) UnorderedWrite ¶ added in v1.6.20
UnorderedWrite checks if unordered_write is turned on.
func (*Options) UseAdaptiveMutex ¶ added in v1.6.21
UseAdaptiveMutex returns setting for enable/disable adaptive mutex, which spins in the user space before resorting to kernel.
func (*Options) UseDirectIOForFlushAndCompaction ¶ added in v1.6.21
UseDirectIOForFlushAndCompaction returns setting for enable/disable direct I/O mode (O_DIRECT) for both reads and writes in background flush and compactions
func (*Options) UseDirectReads ¶ added in v1.6.21
UseDirectReads returns setting for enable/disable direct I/O mode (O_DIRECT) for reads
func (*Options) WriteDBIDToManifest ¶ added in v1.9.5
WriteDBIDToManifest writes/does not write historically DB ID has always been stored in Identity File in DB folder. If this flag is true, the DB ID is written to Manifest file in addition to the Identity file. By doing this 2 problems are solved
- We don't checksum the Identity file where as Manifest file is.
- Since the source of truth for DB is Manifest file DB ID will sit with the source of truth. Previously the Identity file could be copied independent of Manifest and that can result in wrong DB ID.
We recommend setting this flag to true.
Default: false
func (*Options) WriteIdentityFile ¶ added in v1.9.7
WriteIdentityFile toggles identity file writting. It is expected that the Identity file will be obsoleted by recording DB ID in the manifest (see write_dbid_to_manifest). Setting this to true maintains the historical behavior of writing an Identity file, while setting to false is expected to be the future default. This option might eventually be obsolete and removed as Identity files are phased out.
type PartialMerger ¶
type PartialMerger interface { // This function performs merge(left_op, right_op) // when both the operands are themselves merge operation types // that you would have passed to a db.Merge() call in the same order // (i.e.: db.Merge(key,left_op), followed by db.Merge(key,right_op)). // // PartialMerge should combine them into a single merge operation. // The return value should be constructed such that a call to // db.Merge(key, new_value) would yield the same result as a call // to db.Merge(key, left_op) followed by db.Merge(key, right_op). // // If it is impossible or infeasible to combine the two operations, return false. // The library will internally keep track of the operations, and apply them in the // correct order once a base-value (a Put/Delete/End-of-Database) is seen. PartialMerge(key, leftOperand, rightOperand []byte) ([]byte, bool) }
PartialMerger implements PartialMerge(key, leftOperand, rightOperand []byte) ([]byte, err) When a MergeOperator implements this interface, PartialMerge will be called in addition to FullMerge for compactions across levels
type PerfContext ¶
type PerfContext struct {
// contains filtered or unexported fields
}
PerfContext a thread local context for gathering performance counter efficiently and transparently.
func (*PerfContext) Metric ¶
func (ctx *PerfContext) Metric(id int) uint64
Metric returns value of a metric by its id.
Id is one of:
enum { rocksdb_user_key_comparison_count = 0, rocksdb_block_cache_hit_count, rocksdb_block_read_count, rocksdb_block_read_byte, rocksdb_block_read_time, rocksdb_block_checksum_time, rocksdb_block_decompress_time, rocksdb_get_read_bytes, rocksdb_multiget_read_bytes, rocksdb_iter_read_bytes, rocksdb_internal_key_skipped_count, rocksdb_internal_delete_skipped_count, rocksdb_internal_recent_skipped_count, rocksdb_internal_merge_count, rocksdb_get_snapshot_time, rocksdb_get_from_memtable_time, rocksdb_get_from_memtable_count, rocksdb_get_post_process_time, rocksdb_get_from_output_files_time, rocksdb_seek_on_memtable_time, rocksdb_seek_on_memtable_count, rocksdb_next_on_memtable_count, rocksdb_prev_on_memtable_count, rocksdb_seek_child_seek_time, rocksdb_seek_child_seek_count, rocksdb_seek_min_heap_time, rocksdb_seek_max_heap_time, rocksdb_seek_internal_seek_time, rocksdb_find_next_user_entry_time, rocksdb_write_wal_time, rocksdb_write_memtable_time, rocksdb_write_delay_time, rocksdb_write_pre_and_post_process_time, rocksdb_db_mutex_lock_nanos, rocksdb_db_condition_wait_nanos, rocksdb_merge_operator_time_nanos, rocksdb_read_index_block_nanos, rocksdb_read_filter_block_nanos, rocksdb_new_table_block_iter_nanos, rocksdb_new_table_iterator_nanos, rocksdb_block_seek_nanos, rocksdb_find_table_nanos, rocksdb_bloom_memtable_hit_count, rocksdb_bloom_memtable_miss_count, rocksdb_bloom_sst_hit_count, rocksdb_bloom_sst_miss_count, rocksdb_key_lock_wait_time, rocksdb_key_lock_wait_count, rocksdb_env_new_sequential_file_nanos, rocksdb_env_new_random_access_file_nanos, rocksdb_env_new_writable_file_nanos, rocksdb_env_reuse_writable_file_nanos, rocksdb_env_new_random_rw_file_nanos, rocksdb_env_new_directory_nanos, rocksdb_env_file_exists_nanos, rocksdb_env_get_children_nanos, rocksdb_env_get_children_file_attributes_nanos, rocksdb_env_delete_file_nanos, rocksdb_env_create_dir_nanos, rocksdb_env_create_dir_if_missing_nanos, rocksdb_env_delete_dir_nanos, rocksdb_env_get_file_size_nanos, rocksdb_env_get_file_modification_time_nanos, rocksdb_env_rename_file_nanos, rocksdb_env_link_file_nanos, rocksdb_env_lock_file_nanos, rocksdb_env_unlock_file_nanos, rocksdb_env_new_logger_nanos, rocksdb_number_async_seek, rocksdb_blob_cache_hit_count, rocksdb_blob_read_count, rocksdb_blob_read_byte, rocksdb_blob_read_time, rocksdb_blob_checksum_time, rocksdb_blob_decompress_time, rocksdb_total_metric_count = 77 };
func (*PerfContext) Report ¶
func (ctx *PerfContext) Report(excludeZeroCounters bool) (value string)
Report with exclusion of zero counter.
type PerfLevel ¶
type PerfLevel int
PerfLevel indicates how much perf stats to collect. Affects perf_context and iostats_context.
const ( // KUninitialized indicates unknown setting KUninitialized PerfLevel = 0 // KDisable disables perf stats KDisable PerfLevel = 1 // KEnableCount enables only count stats KEnableCount PerfLevel = 2 // KEnableTimeExceptForMutex other than count stats, // also enable time stats except for mutexes KEnableTimeExceptForMutex PerfLevel = 3 // KEnableTimeAndCPUTimeExceptForMutex other than time, // also measure CPU time counters. Still don't measure // time (neither wall time nor CPU time) for mutexes. KEnableTimeAndCPUTimeExceptForMutex PerfLevel = 4 // KEnableTime enables count and time stats KEnableTime PerfLevel = 5 // KOutOfBounds N.B. Must always be the last value! KOutOfBounds PerfLevel = 6 )
type PinnableSliceHandle ¶
type PinnableSliceHandle struct {
// contains filtered or unexported fields
}
PinnableSliceHandle represents a handle to a PinnableSlice.
func (*PinnableSliceHandle) Data ¶
func (h *PinnableSliceHandle) Data() []byte
Data returns the data of the slice.
func (*PinnableSliceHandle) Destroy ¶
func (h *PinnableSliceHandle) Destroy()
Destroy calls the destructor of the underlying pinnable slice handle.
func (*PinnableSliceHandle) Exists ¶ added in v1.6.31
func (h *PinnableSliceHandle) Exists() bool
Exists returns if underlying data exists.
type PrepopulateBlob ¶ added in v1.7.10
type PrepopulateBlob int
PrepopulateBlob represents strategy for prepopulate warm/hot blobs which are already in memory into blob cache at the time of flush.
type Range ¶
Range is a range of keys in the database. GetApproximateSizes calls with it begin at the key Start and end right before the key Limit.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter is used to control write rate of flush and compaction.
func NewAutoTunedRateLimiter ¶ added in v1.8.11
func NewAutoTunedRateLimiter(rateBytesPerSec, refillPeriodMicros int64, fairness int32) *RateLimiter
NewAutoTunedRateLimiter similar to NewRateLimiter, enables dynamic adjustment of rate limit within the range `[rate_bytes_per_sec / 20, rate_bytes_per_sec]`, according to the recent demand for background I/O.
func NewGenericRateLimiter ¶ added in v1.9.1
func NewGenericRateLimiter( rateBytesPerSec, refillPeriodMicros int64, fairness int32, mode RateLimiterMode, autoTuned bool, ) *RateLimiter
NewGenericRateLimiter creates a RateLimiter object, which can be shared among RocksDB instances to control write rate of flush and compaction.
@rate_bytes_per_sec: this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.
@refill_period_us: this controls how often tokens are refilled. For example, when rate_bytes_per_sec is set to 10MB/s and refill_period_us is set to 100ms, then 1MB is refilled every 100ms internally. Larger value can lead to burstier writes while smaller value introduces more CPU overhead. The default should work for most cases.
@fairness: RateLimiter accepts high-pri requests and low-pri requests. A low-pri request is usually blocked in favor of hi-pri request. Currently, RocksDB assigns low-pri to request from compaction and high-pri to request from flush. Low-pri requests can get blocked if flush requests come in continuously. This fairness parameter grants low-pri requests permission by 1/fairness chance even though high-pri requests exist to avoid starvation. You should be good by leaving it at default 10.
@mode: Mode indicates which types of operations count against the limit.
@auto_tuned: Enables dynamic adjustment of rate limit within the range `[rate_bytes_per_sec / 20, rate_bytes_per_sec]`, according to the recent demand for background I/O.
func NewRateLimiter ¶
func NewRateLimiter(rateBytesPerSec, refillPeriodMicros int64, fairness int32) *RateLimiter
NewRateLimiter creates a RateLimiter object, which can be shared among RocksDB instances to control write rate of flush and compaction.
@rate_bytes_per_sec: this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.
@refill_period_us: this controls how often tokens are refilled. For example, when rate_bytes_per_sec is set to 10MB/s and refill_period_us is set to 100ms, then 1MB is refilled every 100ms internally. Larger value can lead to burstier writes while smaller value introduces more CPU overhead. The default should work for most cases.
@fairness: RateLimiter accepts high-pri requests and low-pri requests. A low-pri request is usually blocked in favor of hi-pri request. Currently, RocksDB assigns low-pri to request from compaction and high-pri to request from flush. Low-pri requests can get blocked if flush requests come in continuously. This fairness parameter grants low-pri requests permission by 1/fairness chance even though high-pri requests exist to avoid starvation. You should be good by leaving it at default 10.
func (*RateLimiter) Destroy ¶
func (r *RateLimiter) Destroy()
Destroy deallocates the RateLimiter object.
type RateLimiterMode ¶ added in v1.9.1
type RateLimiterMode int
const ( RateLimiterModeReadsOnly RateLimiterMode = iota RateLimiterModeWritesOnly RateLimiterModeAllIo )
type ReadOptions ¶
type ReadOptions struct {
// contains filtered or unexported fields
}
ReadOptions represent all of the available options when reading from a database.
func NewDefaultReadOptions ¶
func NewDefaultReadOptions() *ReadOptions
NewDefaultReadOptions creates a default ReadOptions object.
func (*ReadOptions) Destroy ¶
func (opts *ReadOptions) Destroy()
Destroy deallocates the ReadOptions object.
func (*ReadOptions) FillCache ¶ added in v1.6.21
func (opts *ReadOptions) FillCache() bool
FillCache returns 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.
func (*ReadOptions) GetBackgroundPurgeOnIteratorCleanup ¶ added in v1.6.21
func (opts *ReadOptions) GetBackgroundPurgeOnIteratorCleanup() bool
GetBackgroundPurgeOnIteratorCleanup returns if background purge on iterator cleanup is turned on.
func (*ReadOptions) GetDeadline ¶ added in v1.6.35
func (opts *ReadOptions) GetDeadline() uint64
GetDeadline for completing an API call (Get/MultiGet/Seek/Next for now) in microseconds.
func (*ReadOptions) GetIOTimeout ¶ added in v1.6.35
func (opts *ReadOptions) GetIOTimeout() uint64
GetIOTimeout gets timeout in microseconds to be passed to the underlying FileSystem for reads. As opposed to deadline, this determines the timeout for each individual file read request. If a MultiGet/Get/Seek/Next etc call results in multiple reads, each read can last upto io_timeout us.
func (*ReadOptions) GetMaxSkippableInternalKeys ¶ added in v1.6.21
func (opts *ReadOptions) GetMaxSkippableInternalKeys() uint64
GetMaxSkippableInternalKeys returns the threshold for the number of keys that can be skipped before failing an iterator seek as incomplete. The default value of 0 should be used to never fail a request as incomplete, even on skipping too many keys.
func (*ReadOptions) GetReadTier ¶ added in v1.6.21
func (opts *ReadOptions) GetReadTier() ReadTier
GetReadTier returns read tier that the request should process data.
func (*ReadOptions) GetReadaheadSize ¶ added in v1.6.21
func (opts *ReadOptions) GetReadaheadSize() uint64
GetReadaheadSize returns the value of "readahead_size".
func (*ReadOptions) GetTotalOrderSeek ¶ added in v1.6.21
func (opts *ReadOptions) GetTotalOrderSeek() bool
GetTotalOrderSeek returns if total order seek is enabled.
func (*ReadOptions) IgnoreRangeDeletions ¶ added in v1.6.21
func (opts *ReadOptions) IgnoreRangeDeletions() bool
IgnoreRangeDeletions returns if ignore range deletion is turned on.
func (*ReadOptions) IsAsyncIO ¶ added in v1.7.16
func (opts *ReadOptions) IsAsyncIO() bool
IsAsyncIO checks if async_io flag is on.
func (*ReadOptions) PinData ¶ added in v1.6.21
func (opts *ReadOptions) PinData() bool
PinData returns the value of "pin_data". If true, it keeps the blocks loaded by the iterator pinned in memory as long as the iterator is not deleted, If used when reading from tables created with BlockBasedTableOptions::use_delta_encoding = false, Iterator's property "rocksdb.iterator.is-key-pinned" is guaranteed to return 1.
func (*ReadOptions) PrefixSameAsStart ¶ added in v1.6.21
func (opts *ReadOptions) PrefixSameAsStart() bool
PrefixSameAsStart returns if the iterator will iterate over the same prefix as the seek.
func (*ReadOptions) SetAsyncIO ¶ added in v1.7.16
func (opts *ReadOptions) SetAsyncIO(value bool)
SetAsyncIO toggles async_io flag.
If async_io is enabled, RocksDB will prefetch some of data asynchronously. RocksDB apply it if reads are sequential and its internal automatic prefetching.
Default: false
Note: Experimental
func (*ReadOptions) SetAutoReadaheadSize ¶ added in v1.8.8
func (opts *ReadOptions) SetAutoReadaheadSize(enable bool)
SetAutoReadaheadSize (Experimental) if auto_readahead_size is set to true, it will auto tune the readahead_size during scans internally. For this feature to enabled, iterate_upper_bound must also be specified.
NOTE: - Recommended for forward Scans only.
- In case of backward scans like Prev or SeekForPrev, the cost of these backward operations might increase and affect the performace. So this option should not be enabled if workload contains backward scans.
- If there is a backward scans, this option will be disabled internally and won't be reset if forward scan is done again.
Default: false
func (*ReadOptions) SetBackgroundPurgeOnIteratorCleanup ¶
func (opts *ReadOptions) SetBackgroundPurgeOnIteratorCleanup(value bool)
SetBackgroundPurgeOnIteratorCleanup if true, when PurgeObsoleteFile is called in CleanupIteratorState, we schedule a background job in the flush job queue and delete obsolete files in background.
Default: false
func (*ReadOptions) SetDeadline ¶ added in v1.6.35
func (opts *ReadOptions) SetDeadline(microseconds uint64)
SetDeadline for completing an API call (Get/MultiGet/Seek/Next for now) in microseconds.
It should be set to microseconds since epoch, i.e, gettimeofday or equivalent plus allowed duration in microseconds. The best way is to use env->NowMicros() + some timeout.
This is best efforts. The call may exceed the deadline if there is IO involved and the file system doesn't support deadlines, or due to checking for deadline periodically rather than for every key if processing a batch
func (*ReadOptions) SetFillCache ¶
func (opts *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) SetIOTimeout ¶ added in v1.6.35
func (opts *ReadOptions) SetIOTimeout(microseconds uint64)
SetIOTimeout sets a timeout in microseconds to be passed to the underlying FileSystem for reads. As opposed to deadline, this determines the timeout for each individual file read request. If a MultiGet/Get/Seek/Next etc call results in multiple reads, each read can last upto io_timeout us.
func (*ReadOptions) SetIgnoreRangeDeletions ¶
func (opts *ReadOptions) SetIgnoreRangeDeletions(value bool)
SetIgnoreRangeDeletions if true, 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
func (*ReadOptions) SetIterStartTimestamp ¶ added in v1.7.5
func (opts *ReadOptions) SetIterStartTimestamp(ts []byte)
SetIterStartTimestamp sets iter_start_ts which is the lower bound (older) and timestamp serves as the upper bound. Versions of the same record that fall in the timestamp range will be returned. If iter_start_ts is nullptr, only the most recent version visible to timestamp is returned. Default: nullptr
func (*ReadOptions) SetIterateLowerBound ¶
func (opts *ReadOptions) SetIterateLowerBound(key []byte)
SetIterateLowerBound specifies `iterate_lower_bound` defines the smallest key at which the backward iterator can return an entry. Once the bound is passed, Valid() will be false. `iterate_lower_bound` is inclusive ie the bound value is a valid entry. If prefix_extractor is not null, the Seek target and `iterate_lower_bound` need to have the same prefix. This is because ordering is not guaranteed outside of prefix domain. Default: nullptr
func (*ReadOptions) SetIterateUpperBound ¶
func (opts *ReadOptions) SetIterateUpperBound(key []byte)
SetIterateUpperBound specifies "iterate_upper_bound", which defines the extent upto which the forward iterator can returns entries. Once the bound is reached, Valid() will be false. "iterate_upper_bound" is exclusive ie the bound value is not a valid entry. If iterator_extractor is not null, the Seek target and iterator_upper_bound need to have the same prefix. This is because ordering is not guaranteed outside of prefix domain. There is no lower bound on the iterator. If needed, that can be easily implemented. Default: nullptr
func (*ReadOptions) SetMaxSkippableInternalKeys ¶
func (opts *ReadOptions) SetMaxSkippableInternalKeys(value uint64)
SetMaxSkippableInternalKeys sets a threshold for the number of keys that can be skipped before failing an iterator seek as incomplete. The default value of 0 should be used to never fail a request as incomplete, even on skipping too many keys.
Default: 0
func (*ReadOptions) SetPinData ¶
func (opts *ReadOptions) SetPinData(value bool)
SetPinData specifies the value of "pin_data". If true, it keeps the blocks loaded by the iterator pinned in memory as long as the iterator is not deleted, If used when reading from tables created with BlockBasedTableOptions::use_delta_encoding = false, Iterator's property "rocksdb.iterator.is-key-pinned" is guaranteed to return 1.
Default: false
func (*ReadOptions) SetPrefixSameAsStart ¶
func (opts *ReadOptions) SetPrefixSameAsStart(value bool)
SetPrefixSameAsStart forces the iterator iterate over the same prefix as the seek.
This option is effective only for prefix seeks, i.e. prefix_extractor is non-null for the column family and total_order_seek is false. Unlike iterate_upper_bound, prefix_same_as_start only works within a prefix but in both directions.
Default: false
func (*ReadOptions) SetReadTier ¶
func (opts *ReadOptions) SetReadTier(value ReadTier)
SetReadTier specify if this read request should process data that ALREADY resides on a particular cache. If the required data is not found at the specified cache, then Status::Incomplete is returned.
Default: ReadAllTier
func (*ReadOptions) SetReadaheadSize ¶
func (opts *ReadOptions) SetReadaheadSize(value uint64)
SetReadaheadSize specifies the value of "readahead_size". If non-zero, NewIterator will create a new table reader which performs reads of the given size. Using a large size (> 2MB) can improve the performance of forward iteration on spinning disks.
Default: 0
func (*ReadOptions) SetSnapshot ¶
func (opts *ReadOptions) SetSnapshot(snap *Snapshot)
SetSnapshot sets the snapshot which should be used for the read. The snapshot must belong to the DB that is being read and must not have been released.
Default: nil
func (*ReadOptions) SetTailing ¶
func (opts *ReadOptions) SetTailing(value bool)
SetTailing specify if we are creating a tailing iterator. A special iterator that has a view of the complete database (i.e. it can also be used to read newly added data) and is optimized for sequential reads. It will return records that were inserted into the database after the creation of the iterator.
Default: false
func (*ReadOptions) SetTimestamp ¶ added in v1.7.5
func (opts *ReadOptions) SetTimestamp(ts []byte)
SetTimestamp sets timestamp. Read should return the latest data visible to the specified timestamp. All timestamps of the same database must be of the same length and format. The user is responsible for providing a customized compare function via Comparator to order <key, timestamp> tuples. Default: nullptr
func (*ReadOptions) SetTotalOrderSeek ¶
func (opts *ReadOptions) SetTotalOrderSeek(value bool)
SetTotalOrderSeek enable a total order seek regardless of index format (e.g. hash index) used in the table. Some table format (e.g. plain table) may not support this option. If true when calling Get(), we also skip prefix bloom when reading from block based table. It provides a way to read existing data after changing implementation of prefix extractor.
Default: false
func (*ReadOptions) SetVerifyChecksums ¶
func (opts *ReadOptions) SetVerifyChecksums(value bool)
SetVerifyChecksums specify if all data read from underlying storage will be verified against corresponding checksums.
Default: false
func (*ReadOptions) Tailing ¶ added in v1.6.21
func (opts *ReadOptions) Tailing() bool
Tailing returns if creating a tailing iterator.
func (*ReadOptions) VerifyChecksums ¶ added in v1.6.21
func (opts *ReadOptions) VerifyChecksums() bool
VerifyChecksums returns if all data read from underlying storage will be verified against corresponding checksums.
type ReadTier ¶
type ReadTier uint
ReadTier controls fetching of data during a read request. An application can issue a read request (via Get/Iterators) and specify if that read should process data that ALREADY resides on a specified cache level. For example, if an application specifies BlockCacheTier then the Get call will process data that is already processed in the memtable or the block cache. It will not page in data from the OS cache or data that resides in storage.
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 SSTFileWriter ¶
type SSTFileWriter struct {
// contains filtered or unexported fields
}
SSTFileWriter is used to create sst files that can be added to database later. All keys in files generated by SstFileWriter will have sequence number = 0.
func NewSSTFileWriter ¶
func NewSSTFileWriter(opts *EnvOptions, dbOpts *Options) *SSTFileWriter
NewSSTFileWriter creates an SSTFileWriter object.
func NewSSTFileWriterWithComparator ¶
func NewSSTFileWriterWithComparator(opts *EnvOptions, dbOpts *Options, cmp *Comparator) *SSTFileWriter
NewSSTFileWriterWithComparator creates an SSTFileWriter object with comparator.
func NewSSTFileWriterWithNativeComparator ¶ added in v1.6.47
func NewSSTFileWriterWithNativeComparator(opts *EnvOptions, dbOpts *Options, cmp unsafe.Pointer) *SSTFileWriter
NewSSTFileWriterWithNativeComparator creates an SSTFileWriter object with native comparator.
func (*SSTFileWriter) Add ¶
func (w *SSTFileWriter) Add(key, value []byte) (err error)
Add adds key, value to currently opened file. REQUIRES: key is after any previously added key according to comparator.
func (*SSTFileWriter) Delete ¶
func (w *SSTFileWriter) Delete(key []byte) (err error)
Delete key from currently opened file.
func (*SSTFileWriter) DeleteRange ¶ added in v1.7.10
func (w *SSTFileWriter) DeleteRange(startKey, endKey []byte) (err error)
DeleteRange deletes keys that are between [startKey, endKey)
func (*SSTFileWriter) DeleteWithTS ¶ added in v1.7.5
func (w *SSTFileWriter) DeleteWithTS(key, ts []byte) (err error)
DeleteWithTS deletes key with timestamp to the currently opened file
func (*SSTFileWriter) Destroy ¶
func (w *SSTFileWriter) Destroy()
Destroy destroys the SSTFileWriter object.
func (*SSTFileWriter) FileSize ¶
func (w *SSTFileWriter) FileSize() (size uint64)
FileSize returns size of currently opened file.
func (*SSTFileWriter) Finish ¶
func (w *SSTFileWriter) Finish() (err error)
Finish finishes writing to sst file and close file.
func (*SSTFileWriter) Merge ¶
func (w *SSTFileWriter) Merge(key, value []byte) (err error)
Merge key, value to currently opened file.
func (*SSTFileWriter) Open ¶
func (w *SSTFileWriter) Open(path string) (err error)
Open prepares SstFileWriter to write into file located at "path".
func (*SSTFileWriter) Put ¶
func (w *SSTFileWriter) Put(key, value []byte) (err error)
Put key, value to currently opened file.
func (*SSTFileWriter) PutWithTS ¶ added in v1.7.5
func (w *SSTFileWriter) PutWithTS(key, ts, value []byte) (err error)
Put key with timestamp, value to the currently opened file
type ShareFilesNaming ¶ added in v1.6.28
type ShareFilesNaming uint32
ShareFilesNaming describes possible naming schemes for backup table file names when the table files are stored in the shared_checksum directory (i.e., both share_table_files and share_files_with_checksum are true).
const ( // LegacyCrc32cAndFileSize indicates backup SST filenames are <file_number>_<crc32c>_<file_size>.sst // where <crc32c> is an unsigned decimal integer. This is the // original/legacy naming scheme for share_files_with_checksum, // with two problems: // * At massive scale, collisions on this triple with different file // contents is plausible. // * Determining the name to use requires computing the checksum, // so generally requires reading the whole file even if the file // is already backed up. // ** ONLY RECOMMENDED FOR PRESERVING OLD BEHAVIOR ** LegacyCrc32cAndFileSize ShareFilesNaming = 1 // UseDBSessionID indicates backup SST filenames are <file_number>_s<db_session_id>.sst. This // pair of values should be very strongly unique for a given SST file // and easily determined before computing a checksum. The 's' indicates // the value is a DB session id, not a checksum. // // Exceptions: // * For old SST files without a DB session id, kLegacyCrc32cAndFileSize // will be used instead, matching the names assigned by RocksDB versions // not supporting the newer naming scheme. // * See also flags below. UseDBSessionID ShareFilesNaming = 2 MaskNoNamingFlags ShareFilesNaming = 0xffff // FlagIncludeFileSize if not already part of the naming scheme, insert // _<file_size> // before .sst in the name. In case of user code actually parsing the // last _<whatever> before the .sst as the file size, this preserves that // feature of kLegacyCrc32cAndFileSize. In other words, this option makes // official that unofficial feature of the backup metadata. // // We do not consider SST file sizes to have sufficient entropy to // contribute significantly to naming uniqueness. FlagIncludeFileSize ShareFilesNaming = 1 << 31 // FlagMatchInterimNaming indicates when encountering an SST file from a Facebook-internal early // release of 6.12, use the default naming scheme in effect for // when the SST file was generated (assuming full file checksum // was not set to GetFileChecksumGenCrc32cFactory()). That naming is // <file_number>_<db_session_id>.sst // and ignores kFlagIncludeFileSize setting. // NOTE: This flag is intended to be temporary and should be removed // in a later release. FlagMatchInterimNaming ShareFilesNaming = 1 << 30 MaskNamingFlags ShareFilesNaming = ^MaskNoNamingFlags )
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
Slice is used as a wrapper for non-copy values
type SliceTransform ¶
type SliceTransform interface { // Transform a src in domain to a dst in the range. Transform(src []byte) []byte // Determine whether this is a valid src upon the function applies. InDomain(src []byte) bool // Determine whether dst=Transform(src) for some src. InRange(src []byte) bool // Return the name of this transformation. Name() string // Destroy underlying pointer/data Destroy() }
A SliceTransform can be used as a prefix extractor.
func NewFixedPrefixTransform ¶
func NewFixedPrefixTransform(prefixLen int) SliceTransform
NewFixedPrefixTransform creates a new fixed prefix transform.
func NewNativeSliceTransform ¶
func NewNativeSliceTransform(c unsafe.Pointer) SliceTransform
NewNativeSliceTransform creates a SliceTransform object.
func NewNoopPrefixTransform ¶
func NewNoopPrefixTransform() SliceTransform
NewNoopPrefixTransform creates a new no-op prefix transform.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot provides a consistent view of read operations in a DB.
func (*Snapshot) Destroy ¶ added in v1.6.17
func (snapshot *Snapshot) Destroy()
Destroy deallocates the Snapshot object.
func (*Snapshot) GetSequenceNumber ¶ added in v1.9.1
GetSequenceNumber gets sequence number of the Snapshot.
type SstMetadata ¶ added in v1.7.6
type SstMetadata struct {
// contains filtered or unexported fields
}
SstMetadata represents metadata of sst file.
func (*SstMetadata) LargestKey ¶ added in v1.7.6
func (s *SstMetadata) LargestKey() []byte
LargestKey returns largest-key in this sst file.
func (*SstMetadata) RelativeFileName ¶ added in v1.7.6
func (s *SstMetadata) RelativeFileName() string
RelativeFileName returns relative file name.
func (*SstMetadata) Size ¶ added in v1.7.6
func (s *SstMetadata) Size() uint64
Size returns size of this sst file.
func (*SstMetadata) SmallestKey ¶ added in v1.7.6
func (s *SstMetadata) SmallestKey() []byte
SmallestKey returns smallest-key in this sst file.
type StatisticsLevel ¶ added in v1.8.7
type StatisticsLevel int
StatisticsLevel can be used to reduce statistics overhead by skipping certain types of stats in the stats collection process.
const ( // StatisticsLevelDisableAll disable all metrics. StatisticsLevelDisableAll StatisticsLevel = iota // StatisticsLevelExceptHistogramOrTimers disable timer stats and skip histogram stats. StatisticsLevelExceptHistogramOrTimers // StatisticsLevelExceptTimers skip timer stats StatisticsLevelExceptTimers // StatisticsLevelExceptDetailedTimers collect all stats except time inside mutex lock AND time spent on // compression. StatisticsLevelExceptDetailedTimers // StatisticsLevelExceptTimeForMutex collect all stats except the counters requiring to get time inside the // mutex lock. StatisticsLevelExceptTimeForMutex // StatisticsLevelAll collect 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. StatisticsLevelAll )
type TickerType ¶ added in v1.8.7
type TickerType uint32
const ( // total block cache misses // REQUIRES: BLOCK_CACHE_MISS == BLOCK_CACHE_INDEX_MISS + // BLOCK_CACHE_FILTER_MISS + // BLOCK_CACHE_DATA_MISS; TickerType_BLOCK_CACHE_MISS TickerType = iota // total block cache hit // REQUIRES: BLOCK_CACHE_HIT == BLOCK_CACHE_INDEX_HIT + // BLOCK_CACHE_FILTER_HIT + // BLOCK_CACHE_DATA_HIT; TickerType_BLOCK_CACHE_HIT // # of blocks added to block cache. TickerType_BLOCK_CACHE_ADD // # of failures when adding blocks to block cache. TickerType_BLOCK_CACHE_ADD_FAILURES // # of times cache miss when accessing index block from block cache. TickerType_BLOCK_CACHE_INDEX_MISS // # of times cache hit when accessing index block from block cache. TickerType_BLOCK_CACHE_INDEX_HIT // # of index blocks added to block cache. TickerType_BLOCK_CACHE_INDEX_ADD // # of bytes of index blocks inserted into cache TickerType_BLOCK_CACHE_INDEX_BYTES_INSERT // # of times cache miss when accessing filter block from block cache. TickerType_BLOCK_CACHE_FILTER_MISS // # of times cache hit when accessing filter block from block cache. TickerType_BLOCK_CACHE_FILTER_HIT // # of filter blocks added to block cache. TickerType_BLOCK_CACHE_FILTER_ADD // # of bytes of bloom filter blocks inserted into cache TickerType_BLOCK_CACHE_FILTER_BYTES_INSERT // # of times cache miss when accessing data block from block cache. TickerType_BLOCK_CACHE_DATA_MISS // # of times cache hit when accessing data block from block cache. TickerType_BLOCK_CACHE_DATA_HIT // # of data blocks added to block cache. TickerType_BLOCK_CACHE_DATA_ADD // # of bytes of data blocks inserted into cache TickerType_BLOCK_CACHE_DATA_BYTES_INSERT // # of bytes read from cache. TickerType_BLOCK_CACHE_BYTES_READ // # of bytes written into cache. TickerType_BLOCK_CACHE_BYTES_WRITE // # of times bloom filter has avoided file reads i.e. negatives. TickerType_BLOOM_FILTER_USEFUL // # of times bloom FullFilter has not avoided the reads. TickerType_BLOOM_FILTER_FULL_POSITIVE // # of times bloom FullFilter has not avoided the reads and data actually // exist. TickerType_BLOOM_FILTER_FULL_TRUE_POSITIVE // # persistent cache hit TickerType_PERSISTENT_CACHE_HIT // # persistent cache miss TickerType_PERSISTENT_CACHE_MISS // # total simulation block cache hits TickerType_SIM_BLOCK_CACHE_HIT // # total simulation block cache misses TickerType_SIM_BLOCK_CACHE_MISS // # of memtable hits. TickerType_MEMTABLE_HIT // # of memtable misses. TickerType_MEMTABLE_MISS // # of Get() queries served by L0 TickerType_GET_HIT_L0 // # of Get() queries served by L1 TickerType_GET_HIT_L1 // # of Get() queries served by L2 and up TickerType_GET_HIT_L2_AND_UP /** * COMPACTION_KEY_DROP_* count the reasons for key drop during compaction * There are 4 reasons currently. */ TickerType_COMPACTION_KEY_DROP_NEWER_ENTRY // key was written with a newer value. // Also includes keys dropped for range del. TickerType_COMPACTION_KEY_DROP_OBSOLETE // The key is obsolete. TickerType_COMPACTION_KEY_DROP_RANGE_DEL // key was covered by a range tombstone. TickerType_COMPACTION_KEY_DROP_USER // user compaction function has dropped the key. TickerType_COMPACTION_RANGE_DEL_DROP_OBSOLETE // all keys in range were deleted. // Deletions obsoleted before bottom level due to file gap optimization. TickerType_COMPACTION_OPTIMIZED_DEL_DROP_OBSOLETE // If a compaction was canceled in sfm to prevent ENOSPC TickerType_COMPACTION_CANCELLED // Number of keys written to the database via the Put and Write call's TickerType_NUMBER_KEYS_WRITTEN // Number of Keys read TickerType_NUMBER_KEYS_READ // Number keys updated if inplace update is enabled TickerType_NUMBER_KEYS_UPDATED // The number of uncompressed bytes issued by DB::Put() DB::Delete() // DB::Merge() and DB::Write(). TickerType_BYTES_WRITTEN // 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 NUMBER_MULTIGET_BYTES_READ. TickerType_BYTES_READ // The number of calls to seek/next/prev TickerType_NUMBER_DB_SEEK TickerType_NUMBER_DB_NEXT TickerType_NUMBER_DB_PREV // The number of calls to seek/next/prev that returned data TickerType_NUMBER_DB_SEEK_FOUND TickerType_NUMBER_DB_NEXT_FOUND TickerType_NUMBER_DB_PREV_FOUND // The number of uncompressed bytes read from an iterator. // Includes size of key and value. TickerType_ITER_BYTES_READ TickerType_NO_FILE_OPENS TickerType_NO_FILE_ERRORS // Writer has to wait for compaction or flush to finish. TickerType_STALL_MICROS // The wait time for db mutex. // Disabled by default. To enable it set stats level to kAll TickerType_DB_MUTEX_WAIT_MICROS // Number of MultiGet calls keys read and bytes read TickerType_NUMBER_MULTIGET_CALLS TickerType_NUMBER_MULTIGET_KEYS_READ TickerType_NUMBER_MULTIGET_BYTES_READ TickerType_NUMBER_MERGE_FAILURES // Prefix filter stats when used for point lookups (Get / MultiGet). // (For prefix filter stats on iterators see *_LEVEL_SEEK_*.) // Checked: filter was queried TickerType_BLOOM_FILTER_PREFIX_CHECKED // Useful: filter returned false so prevented accessing data+index blocks TickerType_BLOOM_FILTER_PREFIX_USEFUL // True positive: found a key matching the point query. When another key // with the same prefix matches it is considered a false positive by // these statistics even though the filter returned a true positive. TickerType_BLOOM_FILTER_PREFIX_TRUE_POSITIVE // Number of times we had to reseek inside an iteration to skip // over large number of keys with same userkey. TickerType_NUMBER_OF_RESEEKS_IN_ITERATION // Record the number of calls to GetUpdatesSince. Useful to keep track of // transaction log iterator refreshes TickerType_GET_UPDATES_SINCE_CALLS TickerType_WAL_FILE_SYNCED // Number of times WAL sync is done TickerType_WAL_FILE_BYTES // Number of bytes written to WAL // Writes can be processed by requesting thread or by the thread at the // head of the writers queue. TickerType_WRITE_DONE_BY_SELF TickerType_WRITE_DONE_BY_OTHER // Equivalent to writes done for others TickerType_WRITE_WITH_WAL // Number of Write calls that request WAL TickerType_COMPACT_READ_BYTES // Bytes read during compaction TickerType_COMPACT_WRITE_BYTES // Bytes written during compaction TickerType_FLUSH_WRITE_BYTES // Bytes written during flush // Compaction read and write statistics broken down by CompactionReason TickerType_COMPACT_READ_BYTES_MARKED TickerType_COMPACT_READ_BYTES_PERIODIC TickerType_COMPACT_READ_BYTES_TTL TickerType_COMPACT_WRITE_BYTES_MARKED TickerType_COMPACT_WRITE_BYTES_PERIODIC TickerType_COMPACT_WRITE_BYTES_TTL // Number of table's properties loaded directly from file without creating // table reader object. TickerType_NUMBER_DIRECT_LOAD_TABLE_PROPERTIES TickerType_NUMBER_SUPERVERSION_ACQUIRES TickerType_NUMBER_SUPERVERSION_RELEASES TickerType_NUMBER_SUPERVERSION_CLEANUPS // # of compressions/decompressions executed TickerType_NUMBER_BLOCK_COMPRESSED TickerType_NUMBER_BLOCK_DECOMPRESSED // DEPRECATED / unused (see NUMBER_BLOCK_COMPRESSION_*) TickerType_NUMBER_BLOCK_NOT_COMPRESSED TickerType_MERGE_OPERATION_TOTAL_TIME TickerType_FILTER_OPERATION_TOTAL_TIME // Row cache. TickerType_ROW_CACHE_HIT TickerType_ROW_CACHE_MISS // Read amplification statistics. // Read amplification can be calculated using this formula // (READ_AMP_TOTAL_READ_BYTES / READ_AMP_ESTIMATE_USEFUL_BYTES) // // REQUIRES: ReadOptions::read_amp_bytes_per_bit to be enabled TickerType_READ_AMP_ESTIMATE_USEFUL_BYTES // Estimate of total bytes actually used. TickerType_READ_AMP_TOTAL_READ_BYTES // Total size of loaded data blocks. // Number of refill intervals where rate limiter's bytes are fully consumed. TickerType_NUMBER_RATE_LIMITER_DRAINS // Number of internal keys skipped by Iterator TickerType_NUMBER_ITER_SKIP // BlobDB specific stats // # of Put/PutTTL/PutUntil to BlobDB. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_PUT // # of Write to BlobDB. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_WRITE // # of Get to BlobDB. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_GET // # of MultiGet to BlobDB. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_MULTIGET // # of Seek/SeekToFirst/SeekToLast/SeekForPrev to BlobDB iterator. Only // applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_SEEK // # of Next to BlobDB iterator. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_NEXT // # of Prev to BlobDB iterator. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_PREV // # of keys written to BlobDB. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_KEYS_WRITTEN // # of keys read from BlobDB. Only applicable to legacy BlobDB. TickerType_BLOB_DB_NUM_KEYS_READ // # of bytes (key + value) written to BlobDB. Only applicable to legacy // BlobDB. TickerType_BLOB_DB_BYTES_WRITTEN // # of bytes (keys + value) read from BlobDB. Only applicable to legacy // BlobDB. TickerType_BLOB_DB_BYTES_READ // # of keys written by BlobDB as non-TTL inlined value. Only applicable to // legacy BlobDB. TickerType_BLOB_DB_WRITE_INLINED // # of keys written by BlobDB as TTL inlined value. Only applicable to legacy // BlobDB. TickerType_BLOB_DB_WRITE_INLINED_TTL // # of keys written by BlobDB as non-TTL blob value. Only applicable to // legacy BlobDB. TickerType_BLOB_DB_WRITE_BLOB // # of keys written by BlobDB as TTL blob value. Only applicable to legacy // BlobDB. TickerType_BLOB_DB_WRITE_BLOB_TTL // # of bytes written to blob file. TickerType_BLOB_DB_BLOB_FILE_BYTES_WRITTEN // # of bytes read from blob file. TickerType_BLOB_DB_BLOB_FILE_BYTES_READ // # of times a blob files being synced. TickerType_BLOB_DB_BLOB_FILE_SYNCED // # of blob index evicted from base DB by BlobDB compaction filter because // of expiration. Only applicable to legacy BlobDB. TickerType_BLOB_DB_BLOB_INDEX_EXPIRED_COUNT // size of blob index evicted from base DB by BlobDB compaction filter // because of expiration. Only applicable to legacy BlobDB. TickerType_BLOB_DB_BLOB_INDEX_EXPIRED_SIZE // # of blob index evicted from base DB by BlobDB compaction filter because // of corresponding file deleted. Only applicable to legacy BlobDB. TickerType_BLOB_DB_BLOB_INDEX_EVICTED_COUNT // size of blob index evicted from base DB by BlobDB compaction filter // because of corresponding file deleted. Only applicable to legacy BlobDB. TickerType_BLOB_DB_BLOB_INDEX_EVICTED_SIZE // # of blob files that were obsoleted by garbage collection. Only applicable // to legacy BlobDB. TickerType_BLOB_DB_GC_NUM_FILES // # of blob files generated by garbage collection. Only applicable to legacy // BlobDB. TickerType_BLOB_DB_GC_NUM_NEW_FILES // # of BlobDB garbage collection failures. Only applicable to legacy BlobDB. TickerType_BLOB_DB_GC_FAILURES // # of keys relocated to new blob file by garbage collection. TickerType_BLOB_DB_GC_NUM_KEYS_RELOCATED // # of bytes relocated to new blob file by garbage collection. TickerType_BLOB_DB_GC_BYTES_RELOCATED // # of blob files evicted because of BlobDB is full. Only applicable to // legacy BlobDB. TickerType_BLOB_DB_FIFO_NUM_FILES_EVICTED // # of keys in the blob files evicted because of BlobDB is full. Only // applicable to legacy BlobDB. TickerType_BLOB_DB_FIFO_NUM_KEYS_EVICTED // # of bytes in the blob files evicted because of BlobDB is full. Only // applicable to legacy BlobDB. TickerType_BLOB_DB_FIFO_BYTES_EVICTED // These counters indicate a performance issue in WritePrepared transactions. // We should not seem them ticking them much. // # of times prepare_mutex_ is acquired in the fast path. TickerType_TXN_PREPARE_MUTEX_OVERHEAD // # of times old_commit_map_mutex_ is acquired in the fast path. TickerType_TXN_OLD_COMMIT_MAP_MUTEX_OVERHEAD // # of times we checked a batch for duplicate keys. TickerType_TXN_DUPLICATE_KEY_OVERHEAD // # of times snapshot_mutex_ is acquired in the fast path. TickerType_TXN_SNAPSHOT_MUTEX_OVERHEAD // # of times ::Get returned TryAgain due to expired snapshot seq TickerType_TXN_GET_TRY_AGAIN // Number of keys actually found in MultiGet calls (vs number requested by // caller) // NUMBER_MULTIGET_KEYS_READ gives the number requested by caller TickerType_NUMBER_MULTIGET_KEYS_FOUND TickerType_NO_ITERATOR_CREATED // number of iterators created TickerType_NO_ITERATOR_DELETED // number of iterators deleted TickerType_BLOCK_CACHE_COMPRESSION_DICT_MISS TickerType_BLOCK_CACHE_COMPRESSION_DICT_HIT TickerType_BLOCK_CACHE_COMPRESSION_DICT_ADD TickerType_BLOCK_CACHE_COMPRESSION_DICT_BYTES_INSERT // # of blocks redundantly inserted into block cache. // REQUIRES: BLOCK_CACHE_ADD_REDUNDANT <= BLOCK_CACHE_ADD TickerType_BLOCK_CACHE_ADD_REDUNDANT // # of index blocks redundantly inserted into block cache. // REQUIRES: BLOCK_CACHE_INDEX_ADD_REDUNDANT <= BLOCK_CACHE_INDEX_ADD TickerType_BLOCK_CACHE_INDEX_ADD_REDUNDANT // # of filter blocks redundantly inserted into block cache. // REQUIRES: BLOCK_CACHE_FILTER_ADD_REDUNDANT <= BLOCK_CACHE_FILTER_ADD TickerType_BLOCK_CACHE_FILTER_ADD_REDUNDANT // # of data blocks redundantly inserted into block cache. // REQUIRES: BLOCK_CACHE_DATA_ADD_REDUNDANT <= BLOCK_CACHE_DATA_ADD TickerType_BLOCK_CACHE_DATA_ADD_REDUNDANT // # of dict blocks redundantly inserted into block cache. // REQUIRES: BLOCK_CACHE_COMPRESSION_DICT_ADD_REDUNDANT // <= BLOCK_CACHE_COMPRESSION_DICT_ADD TickerType_BLOCK_CACHE_COMPRESSION_DICT_ADD_REDUNDANT // # of files marked as trash by sst file manager and will be deleted // later by background thread. TickerType_FILES_MARKED_TRASH // # of trash files deleted by the background thread from the trash queue. TickerType_FILES_DELETED_FROM_TRASH_QUEUE // # of files deleted immediately by sst file manager through delete // scheduler. TickerType_FILES_DELETED_IMMEDIATELY // The counters for error handler not that bg_io_error is the subset of // bg_error and bg_retryable_io_error is the subset of bg_io_error. // The misspelled versions are deprecated and only kept for compatibility. // TODO: remove the misspelled tickers in the next major release. TickerType_ERROR_HANDLER_BG_ERROR_COUNT TickerType_ERROR_HANDLER_BG_ERROR_COUNT_MISSPELLED TickerType_ERROR_HANDLER_BG_IO_ERROR_COUNT TickerType_ERROR_HANDLER_BG_IO_ERROR_COUNT_MISSPELLED TickerType_ERROR_HANDLER_BG_RETRYABLE_IO_ERROR_COUNT TickerType_ERROR_HANDLER_BG_RETRYABLE_IO_ERROR_COUNT_MISSPELLED TickerType_ERROR_HANDLER_AUTORESUME_COUNT TickerType_ERROR_HANDLER_AUTORESUME_RETRY_TOTAL_COUNT TickerType_ERROR_HANDLER_AUTORESUME_SUCCESS_COUNT // Statistics for memtable garbage collection: // Raw bytes of data (payload) present on memtable at flush time. TickerType_MEMTABLE_PAYLOAD_BYTES_AT_FLUSH // Outdated bytes of data present on memtable at flush time. TickerType_MEMTABLE_GARBAGE_BYTES_AT_FLUSH // Secondary cache statistics TickerType_SECONDARY_CACHE_HITS // Bytes read by `VerifyChecksum()` and `VerifyFileChecksums()` APIs. TickerType_VERIFY_CHECKSUM_READ_BYTES // Bytes read/written while creating backups TickerType_BACKUP_READ_BYTES TickerType_BACKUP_WRITE_BYTES // Remote compaction read/write statistics TickerType_REMOTE_COMPACT_READ_BYTES TickerType_REMOTE_COMPACT_WRITE_BYTES // Tiered storage related statistics TickerType_HOT_FILE_READ_BYTES TickerType_WARM_FILE_READ_BYTES TickerType_COLD_FILE_READ_BYTES TickerType_HOT_FILE_READ_COUNT TickerType_WARM_FILE_READ_COUNT TickerType_COLD_FILE_READ_COUNT // Last level and non-last level read statistics TickerType_LAST_LEVEL_READ_BYTES TickerType_LAST_LEVEL_READ_COUNT TickerType_NON_LAST_LEVEL_READ_BYTES TickerType_NON_LAST_LEVEL_READ_COUNT // Statistics on iterator Seek() (and variants) for each sorted run. I.e. a // single user Seek() can result in many sorted run Seek()s. // The stats are split between last level and non-last level. // Filtered: a filter such as prefix Bloom filter indicate the Seek() would // not find anything relevant so avoided a likely access to data+index // blocks. TickerType_LAST_LEVEL_SEEK_FILTERED // Filter match: a filter such as prefix Bloom filter was queried but did // not filter out the seek. TickerType_LAST_LEVEL_SEEK_FILTER_MATCH // At least one data block was accessed for a Seek() (or variant) on a // sorted run. TickerType_LAST_LEVEL_SEEK_DATA // At least one value() was accessed for the seek (suggesting it was useful) // and no filter such as prefix Bloom was queried. TickerType_LAST_LEVEL_SEEK_DATA_USEFUL_NO_FILTER // At least one value() was accessed for the seek (suggesting it was useful) // after querying a filter such as prefix Bloom. TickerType_LAST_LEVEL_SEEK_DATA_USEFUL_FILTER_MATCH // The same set of stats but for non-last level seeks. TickerType_NON_LAST_LEVEL_SEEK_FILTERED TickerType_NON_LAST_LEVEL_SEEK_FILTER_MATCH TickerType_NON_LAST_LEVEL_SEEK_DATA TickerType_NON_LAST_LEVEL_SEEK_DATA_USEFUL_NO_FILTER TickerType_NON_LAST_LEVEL_SEEK_DATA_USEFUL_FILTER_MATCH // Number of block checksum verifications TickerType_BLOCK_CHECKSUM_COMPUTE_COUNT // Number of times RocksDB detected a corruption while verifying a block // checksum. RocksDB does not remember corruptions that happened during user // reads so the same block corruption may be detected multiple times. TickerType_BLOCK_CHECKSUM_MISMATCH_COUNT TickerType_MULTIGET_COROUTINE_COUNT // Integrated BlobDB specific stats // # of times cache miss when accessing blob from blob cache. TickerType_BLOB_DB_CACHE_MISS // # of times cache hit when accessing blob from blob cache. TickerType_BLOB_DB_CACHE_HIT // # of data blocks added to blob cache. TickerType_BLOB_DB_CACHE_ADD // # of failures when adding blobs to blob cache. TickerType_BLOB_DB_CACHE_ADD_FAILURES // # of bytes read from blob cache. TickerType_BLOB_DB_CACHE_BYTES_READ // # of bytes written into blob cache. TickerType_BLOB_DB_CACHE_BYTES_WRITE // Time spent in the ReadAsync file system call TickerType_READ_ASYNC_MICROS // Number of errors returned to the async read callback TickerType_ASYNC_READ_ERROR_COUNT // Fine grained secondary cache stats TickerType_SECONDARY_CACHE_FILTER_HITS TickerType_SECONDARY_CACHE_INDEX_HITS TickerType_SECONDARY_CACHE_DATA_HITS // Number of lookup into the prefetched tail (see // `TABLE_OPEN_PREFETCH_TAIL_READ_BYTES`) // that can't find its data for table open TickerType_TABLE_OPEN_PREFETCH_TAIL_MISS // Number of lookup into the prefetched tail (see // `TABLE_OPEN_PREFETCH_TAIL_READ_BYTES`) // that finds its data for table open TickerType_TABLE_OPEN_PREFETCH_TAIL_HIT // Statistics on the filtering by user-defined timestamps // # of times timestamps are checked on accessing the table TickerType_TIMESTAMP_FILTER_TABLE_CHECKED // # of times timestamps can successfully help skip the table access TickerType_TIMESTAMP_FILTER_TABLE_FILTERED // Number of input bytes (uncompressed) to compression for SST blocks that // are stored compressed. TickerType_BYTES_COMPRESSED_FROM // Number of output bytes (compressed) from compression for SST blocks that // are stored compressed. TickerType_BYTES_COMPRESSED_TO // Number of uncompressed bytes for SST blocks that are stored uncompressed // because compression type is kNoCompression or some error case caused // compression not to run or produce an output. Index blocks are only counted // if enable_index_compression is true. TickerType_BYTES_COMPRESSION_BYPASSED // Number of input bytes (uncompressed) to compression for SST blocks that // are stored uncompressed because the compression result was rejected // either because the ratio was not acceptable (see // CompressionOptions::max_compressed_bytes_per_kb) or found invalid by the // `verify_compression` option. TickerType_BYTES_COMPRESSION_REJECTED // Like BYTES_COMPRESSION_BYPASSED but counting number of blocks TickerType_NUMBER_BLOCK_COMPRESSION_BYPASSED // Like BYTES_COMPRESSION_REJECTED but counting number of blocks TickerType_NUMBER_BLOCK_COMPRESSION_REJECTED // Number of input bytes (compressed) to decompression in reading compressed // SST blocks from storage. TickerType_BYTES_DECOMPRESSED_FROM // Number of output bytes (uncompressed) from decompression in reading // compressed SST blocks from storage. TickerType_BYTES_DECOMPRESSED_TO // Number of times readahead is trimmed during scans when // ReadOptions.auto_readahead_size is set. TickerType_READAHEAD_TRIMMED )
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is used with TransactionDB for transaction support.
func (*Transaction) Commit ¶
func (transaction *Transaction) Commit() (err error)
Commit commits the transaction to the database.
func (*Transaction) Delete ¶
func (transaction *Transaction) Delete(key []byte) (err error)
Delete removes the data associated with the key from the transaction.
func (*Transaction) DeleteCF ¶
func (transaction *Transaction) DeleteCF(cf *ColumnFamilyHandle, key []byte) (err error)
DeleteCF removes the data associated with the key (belongs to specific column family) from the transaction.
func (*Transaction) Destroy ¶
func (transaction *Transaction) Destroy()
Destroy deallocates the transaction object.
func (*Transaction) Get ¶
func (transaction *Transaction) Get(opts *ReadOptions, key []byte) (slice *Slice, err error)
Get returns the data associated with the key from the database given this transaction.
func (*Transaction) GetForUpdate ¶
func (transaction *Transaction) GetForUpdate(opts *ReadOptions, key []byte) (slice *Slice, err error)
GetForUpdate returns the data associated with the key and puts an exclusive lock on the key from the database given this transaction.
func (*Transaction) GetForUpdateWithCF ¶
func (transaction *Transaction) GetForUpdateWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
GetForUpdateWithCF queries the data associated with the key and puts an exclusive lock on the key from the database, with column family, given this transaction.
func (*Transaction) GetName ¶ added in v1.7.5
func (transaction *Transaction) GetName() string
GetName of transaction.
func (*Transaction) GetPinned ¶ added in v1.7.5
func (transaction *Transaction) GetPinned(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
GetPinned returns the data associated with the key from the transaction.
func (*Transaction) GetPinnedForUpdate ¶ added in v1.7.5
func (transaction *Transaction) GetPinnedForUpdate(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
GetPinnedForUpdate returns the data associated with the key and puts an exclusive lock on the key from the database given this transaction.
func (*Transaction) GetPinnedForUpdateWithCF ¶ added in v1.7.5
func (transaction *Transaction) GetPinnedForUpdateWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
GetPinnedForUpdateWithCF returns the data associated with the key and puts an exclusive lock on the key from the database given this transaction.
func (*Transaction) GetPinnedWithCF ¶ added in v1.7.5
func (transaction *Transaction) GetPinnedWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
GetPinnedWithCF returns the data associated with the key from the transaction.
func (*Transaction) GetSnapshot ¶
func (transaction *Transaction) GetSnapshot() *Snapshot
GetSnapshot returns the Snapshot created by the last call to SetSnapshot().
func (*Transaction) GetWithCF ¶
func (transaction *Transaction) GetWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
GetWithCF returns the data associated with the key from the database, with column family, given this transaction.
func (*Transaction) GetWriteBatchWI ¶ added in v1.7.5
func (transaction *Transaction) GetWriteBatchWI() *WriteBatchWI
GetWriteBatchWI returns underlying write batch wi.
func (*Transaction) Merge ¶
func (transaction *Transaction) Merge(key, value []byte) (err error)
Merge key, value to the transaction.
func (*Transaction) MergeCF ¶
func (transaction *Transaction) MergeCF(cf *ColumnFamilyHandle, key, value []byte) (err error)
MergeCF key, value to the transaction on specific column family.
func (*Transaction) MultiGet ¶ added in v1.7.5
func (transaction *Transaction) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error)
MultiGet returns the data associated with the passed keys from the transaction.
func (*Transaction) MultiGetWithCF ¶ added in v1.7.5
func (transaction *Transaction) MultiGetWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, error)
MultiGetWithCF returns the data associated with the passed keys from the transaction.
func (*Transaction) NewIterator ¶
func (transaction *Transaction) NewIterator(opts *ReadOptions) *Iterator
NewIterator returns an iterator that will iterate on all keys in the default column family including both keys in the DB and uncommitted keys in this transaction.
Setting read_options.snapshot will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).
Caller is responsible for deleting the returned Iterator.
func (*Transaction) NewIteratorCF ¶
func (transaction *Transaction) NewIteratorCF(opts *ReadOptions, cf *ColumnFamilyHandle) *Iterator
NewIteratorCF returns an iterator that will iterate on all keys in the specific column family including both keys in the DB and uncommitted keys in this transaction.
Setting read_options.snapshot will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).
Caller is responsible for deleting the returned Iterator.
func (*Transaction) Prepare ¶ added in v1.7.5
func (transaction *Transaction) Prepare() (err error)
Prepare transaction.
func (*Transaction) Put ¶
func (transaction *Transaction) Put(key, value []byte) (err error)
Put writes data associated with a key to the transaction.
func (*Transaction) PutCF ¶
func (transaction *Transaction) PutCF(cf *ColumnFamilyHandle, key, value []byte) (err error)
PutCF writes data associated with a key to the transaction. Key belongs to column family.
func (*Transaction) RebuildFromWriteBatch ¶ added in v1.7.5
func (transaction *Transaction) RebuildFromWriteBatch(wb *WriteBatch) (err error)
RebuildFromWriteBatch rebuilds transaction from write_batch. Note: If no error, write_batch will be destroyed. It's move-op (see also: C++ Move)
func (*Transaction) RebuildFromWriteBatchWI ¶ added in v1.7.5
func (transaction *Transaction) RebuildFromWriteBatchWI(wb *WriteBatchWI) (err error)
RebuildFromWriteBatchWI rebuilds transaction from write_batch. Note: If no error, write_batch will be destroyed. It's move-op (see also: C++ Move)
func (*Transaction) Rollback ¶
func (transaction *Transaction) Rollback() (err error)
Rollback performs a rollback on the transaction.
func (*Transaction) RollbackToSavePoint ¶
func (transaction *Transaction) RollbackToSavePoint() (err error)
RollbackToSavePoint undo all operations in this transaction (Put, Merge, Delete, PutLogData) since the most recent call to SetSavePoint() and removes the most recent SetSavePoint().
func (*Transaction) SetCommitTimestamp ¶ added in v1.7.5
func (transaction *Transaction) SetCommitTimestamp(ts uint64)
SetCommitTimestamp sets the commit timestamp for the transaction. If a transaction's write batch includes at least one key for a column family that enables user-defined timestamp, then the transaction must be assigned a commit timestamp in order to commit. SetCommitTimestamp should be called before transaction commits. If two-phase commit (2PC) is enabled, then SetCommitTimestamp should be called after Transaction Prepare succeeds.
func (*Transaction) SetName ¶ added in v1.7.5
func (transaction *Transaction) SetName(name string) (err error)
SetName of transaction.
func (*Transaction) SetReadTimestampForValidation ¶ added in v1.7.5
func (transaction *Transaction) SetReadTimestampForValidation(ts uint64)
SetReadTimestampForValidation sets the read timestamp for the transaction. Each transaction can have a read timestamp. The transaction will use this timestamp to read data from the database. Any data with timestamp after this read timestamp should be considered invisible to this transaction. The same read timestamp is also used for validation.
func (*Transaction) SetSavePoint ¶
func (transaction *Transaction) SetSavePoint()
SetSavePoint records the state of the transaction for future calls to RollbackToSavePoint(). May be called multiple times to set multiple save points.
type TransactionDB ¶
type TransactionDB struct {
// contains filtered or unexported fields
}
TransactionDB is a reusable handle to a RocksDB transactional database on disk, created by OpenTransactionDb.
func OpenTransactionDb ¶
func OpenTransactionDb( opts *Options, transactionDBOpts *TransactionDBOptions, name string, ) (tdb *TransactionDB, err error)
OpenTransactionDb opens a database with the specified options.
func (*TransactionDB) CreateColumnFamily ¶
func (db *TransactionDB) CreateColumnFamily(opts *Options, name string) (handle *ColumnFamilyHandle, err error)
CreateColumnFamily create a new column family.
func (*TransactionDB) Delete ¶
func (db *TransactionDB) Delete(opts *WriteOptions, key []byte) (err error)
Delete removes the data associated with the key from the database.
func (*TransactionDB) DeleteCF ¶
func (db *TransactionDB) DeleteCF(opts *WriteOptions, cf *ColumnFamilyHandle, key []byte) (err error)
DeleteCF removes the data associated with the key from the database on specific column family.
func (*TransactionDB) Flush ¶ added in v1.7.5
func (db *TransactionDB) Flush(opts *FlushOptions) (err error)
Flush triggers a manual flush for the database.
func (*TransactionDB) FlushCF ¶ added in v1.7.5
func (db *TransactionDB) FlushCF(cf *ColumnFamilyHandle, opts *FlushOptions) (err error)
FlushCF triggers a manual flush for the database on specific column family.
func (*TransactionDB) FlushCFs ¶ added in v1.8.0
func (db *TransactionDB) FlushCFs(cfs []*ColumnFamilyHandle, opts *FlushOptions) (err error)
FlushCFs triggers a manual flush for the database on specific column families.
func (*TransactionDB) FlushWAL ¶ added in v1.7.5
func (db *TransactionDB) FlushWAL(sync bool) (err error)
FlushWAL flushes the WAL memory buffer to the file. If sync is true, it calls SyncWAL afterwards.
func (*TransactionDB) Get ¶
func (db *TransactionDB) Get(opts *ReadOptions, key []byte) (slice *Slice, err error)
Get returns the data associated with the key from the database.
func (*TransactionDB) GetBaseDB ¶ added in v1.8.4
func (db *TransactionDB) GetBaseDB() *DB
GetBaseDB gets base db.
func (*TransactionDB) GetCF ¶
func (db *TransactionDB) GetCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
GetCF returns the data associated with the key from the database, from column family.
func (*TransactionDB) GetIntProperty ¶ added in v1.8.4
func (db *TransactionDB) GetIntProperty(propName string) (value uint64, success bool)
GetIntProperty similar to `GetProperty`, but only works for a subset of properties whose return value is an integer. Return the value by integer.
func (*TransactionDB) GetPinned ¶ added in v1.7.5
func (db *TransactionDB) GetPinned(opts *ReadOptions, key []byte) (handle *PinnableSliceHandle, err error)
GetPinned returns the data associated with the key from the database.
func (*TransactionDB) GetPinnedWithCF ¶ added in v1.7.5
func (db *TransactionDB) GetPinnedWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (handle *PinnableSliceHandle, err error)
GetPinnedWithCF returns the data associated with the key from the database.
func (*TransactionDB) GetProperty ¶ added in v1.8.4
func (db *TransactionDB) GetProperty(propName string) (value string)
GetProperty returns the value of a database property.
func (*TransactionDB) Merge ¶
func (db *TransactionDB) Merge(opts *WriteOptions, key, value []byte) (err error)
Merge writes data associated with a key to the database.
func (*TransactionDB) MergeCF ¶
func (db *TransactionDB) MergeCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
MergeCF writes data associated with a key to the database on specific column family.
func (*TransactionDB) MultiGet ¶ added in v1.7.5
func (db *TransactionDB) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error)
MultiGet returns the data associated with the passed keys from the database.
func (*TransactionDB) MultiGetWithCF ¶ added in v1.7.5
func (db *TransactionDB) MultiGetWithCF(opts *ReadOptions, cf *ColumnFamilyHandle, keys ...[]byte) (Slices, error)
MultiGetWithCF returns the data associated with the passed keys from the database.
func (*TransactionDB) NewCheckpoint ¶
func (db *TransactionDB) NewCheckpoint() (cp *Checkpoint, err error)
NewCheckpoint creates a new Checkpoint for this db.
func (*TransactionDB) NewIterator ¶
func (db *TransactionDB) NewIterator(opts *ReadOptions) *Iterator
NewIterator returns an Iterator over the the database that uses the ReadOptions given.
func (*TransactionDB) NewIteratorCF ¶
func (db *TransactionDB) NewIteratorCF(opts *ReadOptions, cf *ColumnFamilyHandle) *Iterator
NewIteratorCF returns an Iterator over the the database and column family that uses the ReadOptions given.
func (*TransactionDB) NewSnapshot ¶
func (db *TransactionDB) NewSnapshot() *Snapshot
NewSnapshot creates a new snapshot of the database.
func (*TransactionDB) Put ¶
func (db *TransactionDB) Put(opts *WriteOptions, key, value []byte) (err error)
Put writes data associated with a key to the database.
func (*TransactionDB) PutCF ¶
func (db *TransactionDB) PutCF(opts *WriteOptions, cf *ColumnFamilyHandle, key, value []byte) (err error)
PutCF writes data associated with a key to the database on specific column family.
func (*TransactionDB) ReleaseSnapshot ¶
func (db *TransactionDB) ReleaseSnapshot(snapshot *Snapshot)
ReleaseSnapshot releases the snapshot and its resources.
func (*TransactionDB) TransactionBegin ¶
func (db *TransactionDB) TransactionBegin( opts *WriteOptions, transactionOpts *TransactionOptions, oldTransaction *Transaction, ) *Transaction
TransactionBegin begins a new transaction with the WriteOptions and TransactionOptions given.
func (*TransactionDB) Write ¶
func (db *TransactionDB) Write(opts *WriteOptions, batch *WriteBatch) (err error)
Write writes a WriteBatch to the database.
type TransactionDBOptions ¶
type TransactionDBOptions struct {
// contains filtered or unexported fields
}
TransactionDBOptions represent all of the available options when opening a transactional database with OpenTransactionDb.
func NewDefaultTransactionDBOptions ¶
func NewDefaultTransactionDBOptions() *TransactionDBOptions
NewDefaultTransactionDBOptions creates a default TransactionDBOptions object.
func (*TransactionDBOptions) Destroy ¶
func (opts *TransactionDBOptions) Destroy()
Destroy deallocates the TransactionDBOptions object.
func (*TransactionDBOptions) SetDefaultLockTimeout ¶
func (opts *TransactionDBOptions) SetDefaultLockTimeout(defaultLockTimeout int64)
SetDefaultLockTimeout if posititve, specifies the wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by calling DB::Put(),Merge(),Delete(),Write() directly). If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout and will block indefinitely when acquiring a lock.
Not using a timeout can lead to deadlocks. Currently, there is no deadlock-detection to recover from a deadlock. While DB writes cannot deadlock with other DB writes, they can deadlock with a transaction. A negative timeout should only be used if all transactions have a small expiration set.
func (*TransactionDBOptions) SetMaxNumLocks ¶
func (opts *TransactionDBOptions) SetMaxNumLocks(maxNumLocks int64)
SetMaxNumLocks sets the maximum number of keys that can be locked at the same time per column family. If the number of locked keys is greater than max_num_locks, transaction writes (or GetForUpdate) will return an error. If this value is not positive, no limit will be enforced.
func (*TransactionDBOptions) SetNumStripes ¶
func (opts *TransactionDBOptions) SetNumStripes(numStripes uint64)
SetNumStripes sets the concurrency level. Increasing this value will increase the concurrency by dividing the lock table (per column family) into more sub-tables, each with their own separate mutex.
func (*TransactionDBOptions) SetTransactionLockTimeout ¶
func (opts *TransactionDBOptions) SetTransactionLockTimeout(txnLockTimeout int64)
SetTransactionLockTimeout if positive, specifies the default wait timeout in milliseconds when a transaction attempts to lock a key if not specified by TransactionOptions::lock_timeout.
If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout. Not using a timeout is not recommended as it can lead to deadlocks. Currently, there is no deadlock-detection to recover from a deadlock.
type TransactionOptions ¶
type TransactionOptions struct {
// contains filtered or unexported fields
}
TransactionOptions represent all of the available options options for a transaction on the database.
func NewDefaultTransactionOptions ¶
func NewDefaultTransactionOptions() *TransactionOptions
NewDefaultTransactionOptions creates a default TransactionOptions object.
func (*TransactionOptions) Destroy ¶
func (opts *TransactionOptions) Destroy()
Destroy deallocates the TransactionOptions object.
func (*TransactionOptions) SetDeadlockDetect ¶
func (opts *TransactionOptions) SetDeadlockDetect(value bool)
SetDeadlockDetect to true means that before acquiring locks, this transaction will check if doing so will cause a deadlock. If so, it will return with Status::Busy. The user should retry their transaction.
func (*TransactionOptions) SetDeadlockDetectDepth ¶
func (opts *TransactionOptions) SetDeadlockDetectDepth(depth int64)
SetDeadlockDetectDepth sets the number of traversals to make during deadlock detection.
func (*TransactionOptions) SetExpiration ¶
func (opts *TransactionOptions) SetExpiration(expiration int64)
SetExpiration sets the Expiration duration in milliseconds. If non-negative, transactions that last longer than this many milliseconds will fail to commit. If not set, a forgotten transaction that is never committed, rolled back, or deleted will never relinquish any locks it holds. This could prevent keys from being written by other writers.
func (*TransactionOptions) SetLockTimeout ¶
func (opts *TransactionOptions) SetLockTimeout(lockTimeout int64)
SetLockTimeout positive, specifies the wait timeout in milliseconds when a transaction attempts to lock a key. If 0, no waiting is done if a lock cannot instantly be acquired. If negative, TransactionDBOptions::transaction_lock_timeout will be used
func (*TransactionOptions) SetMaxWriteBatchSize ¶
func (opts *TransactionOptions) SetMaxWriteBatchSize(size uint64)
SetMaxWriteBatchSize sets the maximum number of bytes used for the write batch. 0 means no limit.
func (*TransactionOptions) SetSetSnapshot ¶
func (opts *TransactionOptions) SetSetSnapshot(value bool)
SetSetSnapshot to true is the same as calling Transaction::SetSnapshot().
func (*TransactionOptions) SetSkipPrepare ¶ added in v1.7.5
func (opts *TransactionOptions) SetSkipPrepare(skip bool)
SetSkipPrepare skips prepare phase.
type UniversalCompactionOptions ¶
type UniversalCompactionOptions struct {
// contains filtered or unexported fields
}
UniversalCompactionOptions represent all of the available options for universal compaction.
func NewDefaultUniversalCompactionOptions ¶
func NewDefaultUniversalCompactionOptions() *UniversalCompactionOptions
NewDefaultUniversalCompactionOptions creates a default UniversalCompactionOptions object.
func (*UniversalCompactionOptions) Destroy ¶
func (opts *UniversalCompactionOptions) Destroy()
Destroy deallocates the UniversalCompactionOptions object.
func (*UniversalCompactionOptions) GetCompressionSizePercent ¶ added in v1.6.28
func (opts *UniversalCompactionOptions) GetCompressionSizePercent() int
GetCompressionSizePercent gets the percentage of compression size.
If this option is set to be -1, all the output files will follow compression type specified.
If this option is not negative, we will try to make sure compressed size is just above this value. In normal cases, at least this percentage of data will be compressed. When we are compacting to a new file, here is the criteria whether it needs to be compressed: assuming here are the list of files sorted by generation time:
A1...An B1...Bm C1...Ct
where A1 is the newest and Ct is the oldest, and we are going to compact B1...Bm, we calculate the total size of all the files as total_size, as well as the total size of C1...Ct as total_C, the compaction output file will be compressed iff
total_C / total_size < this percentage
func (*UniversalCompactionOptions) GetMaxMergeWidth ¶ added in v1.6.28
func (opts *UniversalCompactionOptions) GetMaxMergeWidth() int
GetMaxMergeWidth gets the maximum number of files in a single compaction run.
func (*UniversalCompactionOptions) GetMaxSizeAmplificationPercent ¶ added in v1.6.28
func (opts *UniversalCompactionOptions) GetMaxSizeAmplificationPercent() int
GetMaxSizeAmplificationPercent gets the size amplification. It is defined as the amount (in percentage) of additional storage needed to store a single byte of data in the database. For example, a size amplification of 2% means that a database that contains 100 bytes of user-data may occupy upto 102 bytes of physical storage. By this definition, a fully compacted database has a size amplification of 0%. Rocksdb uses the following heuristic to calculate size amplification: it assumes that all files excluding the earliest file contribute to the size amplification.
func (*UniversalCompactionOptions) GetMinMergeWidth ¶ added in v1.6.28
func (opts *UniversalCompactionOptions) GetMinMergeWidth() int
GetMinMergeWidth gets the minimum number of files in a single compaction run.
func (*UniversalCompactionOptions) GetSizeRatio ¶ added in v1.6.28
func (opts *UniversalCompactionOptions) GetSizeRatio() int
GetSizeRatio gets the percentage flexibility while comparing file size. If the candidate file(s) size is 1% smaller than the next file's size, then include next file into this candidate set.
func (*UniversalCompactionOptions) GetStopStyle ¶ added in v1.6.28
func (opts *UniversalCompactionOptions) GetStopStyle() UniversalCompactionStopStyle
GetStopStyle gets the algorithm used to stop picking files into a single compaction run.
func (*UniversalCompactionOptions) SetCompressionSizePercent ¶
func (opts *UniversalCompactionOptions) SetCompressionSizePercent(value int)
SetCompressionSizePercent sets the percentage of compression size.
If this option is set to be -1, all the output files will follow compression type specified.
If this option is not negative, we will try to make sure compressed size is just above this value. In normal cases, at least this percentage of data will be compressed. When we are compacting to a new file, here is the criteria whether it needs to be compressed: assuming here are the list of files sorted by generation time:
A1...An B1...Bm C1...Ct
where A1 is the newest and Ct is the oldest, and we are going to compact B1...Bm, we calculate the total size of all the files as total_size, as well as the total size of C1...Ct as total_C, the compaction output file will be compressed iff
total_C / total_size < this percentage
Default: -1
func (*UniversalCompactionOptions) SetMaxMergeWidth ¶
func (opts *UniversalCompactionOptions) SetMaxMergeWidth(value uint)
SetMaxMergeWidth sets the maximum number of files in a single compaction run.
Default: UINT_MAX
func (*UniversalCompactionOptions) SetMaxSizeAmplificationPercent ¶
func (opts *UniversalCompactionOptions) SetMaxSizeAmplificationPercent(value int)
SetMaxSizeAmplificationPercent sets the size amplification. It is defined as the amount (in percentage) of additional storage needed to store a single byte of data in the database. For example, a size amplification of 2% means that a database that contains 100 bytes of user-data may occupy upto 102 bytes of physical storage. By this definition, a fully compacted database has a size amplification of 0%. Rocksdb uses the following heuristic to calculate size amplification: it assumes that all files excluding the earliest file contribute to the size amplification.
Default: 200, which means that a 100 byte database could require upto 300 bytes of storage.
func (*UniversalCompactionOptions) SetMinMergeWidth ¶
func (opts *UniversalCompactionOptions) SetMinMergeWidth(value int)
SetMinMergeWidth sets the minimum number of files in a single compaction run.
Default: 2
func (*UniversalCompactionOptions) SetSizeRatio ¶
func (opts *UniversalCompactionOptions) SetSizeRatio(value int)
SetSizeRatio sets the percentage flexibility while comparing file size. If the candidate file(s) size is 1% smaller than the next file's size, then include next file into this candidate set.
Default: 1
func (*UniversalCompactionOptions) SetStopStyle ¶
func (opts *UniversalCompactionOptions) SetStopStyle(value UniversalCompactionStopStyle)
SetStopStyle sets the algorithm used to stop picking files into a single compaction run.
Default: CompactionStopStyleTotalSize
type UniversalCompactionStopStyle ¶
type UniversalCompactionStopStyle uint
UniversalCompactionStopStyle describes a algorithm used to make a compaction request stop picking new files into a single compaction run.
type WaitForCompactOptions ¶ added in v1.8.8
type WaitForCompactOptions struct {
// contains filtered or unexported fields
}
func NewWaitForCompactOptions ¶ added in v1.8.8
func NewWaitForCompactOptions() *WaitForCompactOptions
func (*WaitForCompactOptions) AbortOnPause ¶ added in v1.8.8
func (w *WaitForCompactOptions) AbortOnPause() bool
IsAbortOnPause checks if abort_on_pause flag is on.
func (*WaitForCompactOptions) CloseDB ¶ added in v1.8.8
func (w *WaitForCompactOptions) CloseDB() bool
CloseDB checks if "close_db" flag is on.
func (*WaitForCompactOptions) Destroy ¶ added in v1.8.8
func (w *WaitForCompactOptions) Destroy()
Destroy the object.
func (*WaitForCompactOptions) Flush ¶ added in v1.8.8
func (w *WaitForCompactOptions) Flush() bool
IsFlush checks if "flush" flag is on.
func (*WaitForCompactOptions) GetTimeout ¶ added in v1.8.8
func (w *WaitForCompactOptions) GetTimeout() uint64
GetTimeout in microseconds.
func (*WaitForCompactOptions) SetAbortOnPause ¶ added in v1.8.8
func (w *WaitForCompactOptions) SetAbortOnPause(v bool)
SetAbortOnPause toggles the abort_on_pause flag, to abort waiting in case of a pause (PauseBackgroundWork() called).
- If true, Status::Aborted will be returned immediately. - If false, ContinueBackgroundWork() must be called to resume the background jobs.
Otherwise, jobs that were queued, but not scheduled yet may never finish and WaitForCompact() may wait indefinitely (if timeout is set, it will expire and return Status::TimedOut).
func (*WaitForCompactOptions) SetCloseDB ¶ added in v1.8.8
func (w *WaitForCompactOptions) SetCloseDB(v bool)
SetCloseDB toggles the "close_db" flag to call Close() after waiting is done. By the time Close() is called here, there should be no background jobs in progress and no new background jobs should be added.
DB may not have been closed if Close() returned Aborted status due to unreleased snapshots in the system.
func (*WaitForCompactOptions) SetFlush ¶ added in v1.8.8
func (w *WaitForCompactOptions) SetFlush(v bool)
SetFlush toggles the "flush" flag to flush all column families before starting to wait.
func (*WaitForCompactOptions) SetTimeout ¶ added in v1.8.8
func (w *WaitForCompactOptions) SetTimeout(microseconds uint64)
SetTimeout in microseconds for waiting for compaction to complete. Status::TimedOut will be returned if timeout expires. when timeout == 0, WaitForCompact() will wait as long as there's background work to finish.
type WalIterator ¶
type WalIterator struct {
// contains filtered or unexported fields
}
WalIterator is iterator for WAL Files.
func (*WalIterator) Err ¶
func (iter *WalIterator) Err() (err error)
Err returns error happened during iteration.
func (*WalIterator) GetBatch ¶
func (iter *WalIterator) GetBatch() (*WriteBatch, uint64)
GetBatch returns the current write_batch and the sequence number of the earliest transaction contained in the batch.
func (*WalIterator) Valid ¶
func (iter *WalIterator) Valid() bool
Valid check if current WAL is valid.
type WriteBatch ¶
type WriteBatch struct {
// contains filtered or unexported fields
}
WriteBatch is a batching of Puts, Merges and Deletes.
func NewWriteBatchWithParams ¶ added in v1.9.5
func NewWriteBatchWithParams(reservedBytes, maxBytes, protectionBytesPerKey, defaultCFTs int) *WriteBatch
NewWriteBatchWithParams with params.
func WriteBatchFrom ¶
func WriteBatchFrom(data []byte) *WriteBatch
WriteBatchFrom creates a write batch from a serialized WriteBatch.
func (*WriteBatch) Clear ¶
func (wb *WriteBatch) Clear()
Clear removes all the enqueued Put and Deletes.
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 queues a deletion of the data at key.
func (*WriteBatch) DeleteCF ¶
func (wb *WriteBatch) DeleteCF(cf *ColumnFamilyHandle, key []byte)
DeleteCF queues a deletion of the data at key in a column family.
func (*WriteBatch) DeleteCFWithTS ¶ added in v1.7.5
func (wb *WriteBatch) DeleteCFWithTS(cf *ColumnFamilyHandle, key, ts []byte)
DeleteCF queues a deletion of the data at key with given timestamp in a column family.
func (*WriteBatch) DeleteRange ¶
func (wb *WriteBatch) DeleteRange(startKey, endKey []byte)
DeleteRange deletes keys that are between [startKey, endKey)
func (*WriteBatch) DeleteRangeCF ¶
func (wb *WriteBatch) DeleteRangeCF(cf *ColumnFamilyHandle, startKey, endKey []byte)
DeleteRangeCF deletes keys that are between [startKey, endKey) and belong to a given column family
func (*WriteBatch) Destroy ¶
func (wb *WriteBatch) Destroy()
Destroy deallocates the WriteBatch object.
func (*WriteBatch) Merge ¶
func (wb *WriteBatch) Merge(key, value []byte)
Merge queues a merge of "value" with the existing value of "key".
func (*WriteBatch) MergeCF ¶
func (wb *WriteBatch) MergeCF(cf *ColumnFamilyHandle, key, value []byte)
MergeCF queues a merge of "value" with the existing value of "key" in a column family.
func (*WriteBatch) NewIterator ¶
func (wb *WriteBatch) NewIterator() *WriteBatchIterator
NewIterator returns a iterator to iterate over the records in the batch.
func (*WriteBatch) PopSavePoint ¶
func (wb *WriteBatch) PopSavePoint() (err error)
PopSavePoint pops the most recent save point. If there is no previous call to SetSavePoint(), Status::NotFound() will be returned.
func (*WriteBatch) PutCF ¶
func (wb *WriteBatch) PutCF(cf *ColumnFamilyHandle, key, value []byte)
PutCF queues a key-value pair in a column family.
func (*WriteBatch) PutCFWithTS ¶ added in v1.7.5
func (wb *WriteBatch) PutCFWithTS(cf *ColumnFamilyHandle, key, ts, value []byte)
PutCFWithTS queues a key-value pair with given timestamp in a column family.
func (*WriteBatch) PutLogData ¶
func (wb *WriteBatch) PutLogData(blob []byte)
PutLogData appends a blob of arbitrary size to the records in this batch.
func (*WriteBatch) RollbackToSavePoint ¶
func (wb *WriteBatch) RollbackToSavePoint() (err error)
RollbackToSavePoint removes all entries in this batch (Put, Merge, Delete, PutLogData) since the most recent call to SetSavePoint() and removes the most recent save point.
func (*WriteBatch) SetSavePoint ¶
func (wb *WriteBatch) SetSavePoint()
SetSavePoint records the state of the batch for future calls to RollbackToSavePoint(). May be called multiple times to set multiple save points.
func (*WriteBatch) SingleDelete ¶ added in v1.6.20
func (wb *WriteBatch) SingleDelete(key []byte)
SingleDelete removes the database entry for "key". Requires that the key exists and was not overwritten. Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
If a key is overwritten (by calling Put() multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.
Note: consider setting options.sync = true.
func (*WriteBatch) SingleDeleteCF ¶ added in v1.6.20
func (wb *WriteBatch) SingleDeleteCF(cf *ColumnFamilyHandle, key []byte)
SingleDeleteCF same as SingleDelete but specific column family
func (*WriteBatch) SingleDeleteCFWithTS ¶ added in v1.7.5
func (wb *WriteBatch) SingleDeleteCFWithTS(cf *ColumnFamilyHandle, key, ts []byte)
SingleDeleteCFWithTS same as SingleDelete but with timestamp for specific column family
type WriteBatchIterator ¶
type WriteBatchIterator struct {
// contains filtered or unexported fields
}
WriteBatchIterator represents a iterator to iterator over records.
func (*WriteBatchIterator) Error ¶
func (iter *WriteBatchIterator) Error() error
Error returns the error if the iteration is failed.
func (*WriteBatchIterator) Next ¶
func (iter *WriteBatchIterator) Next() bool
Next returns the next record. Returns false if no further record exists.
func (*WriteBatchIterator) Record ¶
func (iter *WriteBatchIterator) Record() *WriteBatchRecord
Record returns the current record.
type WriteBatchRecord ¶
type WriteBatchRecord struct { CF int Key []byte Value []byte Type WriteBatchRecordType }
WriteBatchRecord represents a record inside a WriteBatch.
type WriteBatchRecordType ¶
type WriteBatchRecordType byte
WriteBatchRecordType describes the type of a batch record.
const ( WriteBatchDeletionRecord WriteBatchRecordType = 0x0 WriteBatchValueRecord WriteBatchRecordType = 0x1 WriteBatchMergeRecord WriteBatchRecordType = 0x2 WriteBatchLogDataRecord WriteBatchRecordType = 0x3 WriteBatchCFDeletionRecord WriteBatchRecordType = 0x4 WriteBatchCFValueRecord WriteBatchRecordType = 0x5 WriteBatchCFMergeRecord WriteBatchRecordType = 0x6 WriteBatchSingleDeletionRecord WriteBatchRecordType = 0x7 WriteBatchCFSingleDeletionRecord WriteBatchRecordType = 0x8 WriteBatchBeginPrepareXIDRecord WriteBatchRecordType = 0x9 WriteBatchEndPrepareXIDRecord WriteBatchRecordType = 0xA WriteBatchCommitXIDRecord WriteBatchRecordType = 0xB WriteBatchRollbackXIDRecord WriteBatchRecordType = 0xC WriteBatchNoopRecord WriteBatchRecordType = 0xD WriteBatchRangeDeletion WriteBatchRecordType = 0xF WriteBatchCFRangeDeletion WriteBatchRecordType = 0xE WriteBatchCFBlobIndex WriteBatchRecordType = 0x10 WriteBatchBlobIndex WriteBatchRecordType = 0x11 WriteBatchBeginPersistedPrepareXIDRecord WriteBatchRecordType = 0x12 WriteBatchNotUsedRecord WriteBatchRecordType = 0x7F )
Types of batch records.
type WriteBatchWI ¶
type WriteBatchWI struct {
// contains filtered or unexported fields
}
WriteBatchWI is a batching with index of Puts, Merges and Deletes to implement read-your-own-write. See also: https://rocksdb.org/blog/2015/02/27/write-batch-with-index.html
func NewWriteBatchWI ¶
func NewWriteBatchWI(reservedBytes uint, overwriteKeys bool) *WriteBatchWI
NewWriteBatchWI create a WriteBatchWI object.
- reserved_bytes: reserved bytes in underlying WriteBatch
- overwrite_key: if true, overwrite the key in the index when inserting the same key as previously, so iterator will never show two entries with the same key.
func NewWriteBatchWIWithParams ¶ added in v1.9.5
func NewWriteBatchWIWithParams(cp *Comparator, reservedBytes int, overwriteKey bool, maxBytes, protectionBytesPerKey int) *WriteBatchWI
NewWriteBatchWIWithParams with params.
func (*WriteBatchWI) Clear ¶
func (wb *WriteBatchWI) Clear()
Clear removes all the enqueued Put and Deletes.
func (*WriteBatchWI) Count ¶
func (wb *WriteBatchWI) Count() int
Count returns the number of updates in the batch.
func (*WriteBatchWI) Data ¶
func (wb *WriteBatchWI) Data() []byte
Data returns the serialized version of this batch.
func (*WriteBatchWI) Delete ¶
func (wb *WriteBatchWI) Delete(key []byte)
Delete queues a deletion of the data at key.
func (*WriteBatchWI) DeleteCF ¶
func (wb *WriteBatchWI) DeleteCF(cf *ColumnFamilyHandle, key []byte)
DeleteCF queues a deletion of the data at key in a column family.
func (*WriteBatchWI) DeleteRange ¶
func (wb *WriteBatchWI) DeleteRange(startKey, endKey []byte)
DeleteRange deletes keys that are between [startKey, endKey)
func (*WriteBatchWI) DeleteRangeCF ¶
func (wb *WriteBatchWI) DeleteRangeCF(cf *ColumnFamilyHandle, startKey, endKey []byte)
DeleteRangeCF deletes keys that are between [startKey, endKey) and belong to a given column family
func (*WriteBatchWI) Destroy ¶
func (wb *WriteBatchWI) Destroy()
Destroy deallocates the WriteBatch object.
func (*WriteBatchWI) Get ¶
func (wb *WriteBatchWI) Get(opts *Options, key []byte) (slice *Slice, err error)
Get returns the data associated with the key from batch.
func (*WriteBatchWI) GetFromDB ¶
func (wb *WriteBatchWI) GetFromDB(db *DB, opts *ReadOptions, key []byte) (slice *Slice, err error)
GetFromDB returns the data associated with the key from the database and write batch.
func (*WriteBatchWI) GetFromDBWithCF ¶
func (wb *WriteBatchWI) GetFromDBWithCF(db *DB, opts *ReadOptions, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
GetFromDBWithCF returns the data associated with the key from the database and write batch. Key belongs to specific column family.
func (*WriteBatchWI) GetWithCF ¶
func (wb *WriteBatchWI) GetWithCF(opts *Options, cf *ColumnFamilyHandle, key []byte) (slice *Slice, err error)
GetWithCF returns the data associated with the key from batch. Key belongs to specific column family.
func (*WriteBatchWI) Merge ¶
func (wb *WriteBatchWI) Merge(key, value []byte)
Merge queues a merge of "value" with the existing value of "key".
func (*WriteBatchWI) MergeCF ¶
func (wb *WriteBatchWI) MergeCF(cf *ColumnFamilyHandle, key, value []byte)
MergeCF queues a merge of "value" with the existing value of "key" in a column family.
func (*WriteBatchWI) NewIterator ¶
func (wb *WriteBatchWI) NewIterator() *WriteBatchIterator
NewIterator returns a iterator to iterate over the records in the batch.
func (*WriteBatchWI) NewIteratorWithBase ¶ added in v1.7.8
func (wb *WriteBatchWI) NewIteratorWithBase(db *DB, baseIter *Iterator) *Iterator
NewIteratorWithBase will create a new Iterator that will use WBWIIterator as a delta and base_iterator as base.
This function is only supported if the WriteBatchWithIndex was constructed with overwrite_key=true.
The returned iterator should be deleted by the caller. The base_iterator is now 'owned' by the returned iterator. Deleting the returned iterator will also delete the base_iterator.
Updating write batch with the current key of the iterator is not safe. We strongly recommend users not to do it. It will invalidate the current key() and value() of the iterator. This invalidation happens even before the write batch update finishes. The state may recover after Next() is called.
func (*WriteBatchWI) NewIteratorWithBaseCF ¶ added in v1.7.8
func (wb *WriteBatchWI) NewIteratorWithBaseCF(db *DB, baseIter *Iterator, cf *ColumnFamilyHandle) *Iterator
NewIteratorWithBaseCF will create a new Iterator that will use WBWIIterator as a delta and base_iterator as base.
This function is only supported if the WriteBatchWithIndex was constructed with overwrite_key=true.
The returned iterator should be deleted by the caller. The base_iterator is now 'owned' by the returned iterator. Deleting the returned iterator will also delete the base_iterator.
Updating write batch with the current key of the iterator is not safe. We strongly recommend users not to do it. It will invalidate the current key() and value() of the iterator. This invalidation happens even before the write batch update finishes. The state may recover after Next() is called.
func (*WriteBatchWI) Put ¶
func (wb *WriteBatchWI) Put(key, value []byte)
Put queues a key-value pair.
func (*WriteBatchWI) PutCF ¶
func (wb *WriteBatchWI) PutCF(cf *ColumnFamilyHandle, key, value []byte)
PutCF queues a key-value pair in a column family.
func (*WriteBatchWI) PutLogData ¶
func (wb *WriteBatchWI) PutLogData(blob []byte)
PutLogData appends a blob of arbitrary size to the records in this batch.
func (*WriteBatchWI) RollbackToSavePoint ¶
func (wb *WriteBatchWI) RollbackToSavePoint() (err error)
RollbackToSavePoint removes all entries in this batch (Put, Merge, Delete, PutLogData) since the most recent call to SetSavePoint() and removes the most recent save point.
func (*WriteBatchWI) SetSavePoint ¶
func (wb *WriteBatchWI) SetSavePoint()
SetSavePoint records the state of the batch for future calls to RollbackToSavePoint(). May be called multiple times to set multiple save points.
func (*WriteBatchWI) SingleDelete ¶ added in v1.6.20
func (wb *WriteBatchWI) SingleDelete(key []byte)
SingleDelete removes the database entry for "key". Requires that the key exists and was not overwritten. Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
If a key is overwritten (by calling Put() multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.
Note: consider setting options.sync = true.
func (*WriteBatchWI) SingleDeleteCF ¶ added in v1.6.20
func (wb *WriteBatchWI) SingleDeleteCF(cf *ColumnFamilyHandle, key []byte)
SingleDeleteCF same as SingleDelete but specific column family
type WriteBufferManager ¶ added in v1.8.11
type WriteBufferManager struct {
// contains filtered or unexported fields
}
func NewWriteBufferManager ¶ added in v1.8.11
func NewWriteBufferManager(bufferSize int, allowStall bool) *WriteBufferManager
NewWriteBufferManager creates new WriteBufferManager object.
@bufferSize: bufferSize = 0 indicates no limit. Memory won't be capped. memory_usage() won't be valid and ShouldFlush() will always return true.
@allowStall: if set true, it will enable stalling of writes when memory_usage() exceeds buffer_size. It will wait for flush to complete and memory usage to drop down.
func NewWriteBufferManagerWithCache ¶ added in v1.8.11
func NewWriteBufferManagerWithCache(bufferSize int, cache *Cache, allowStall bool) *WriteBufferManager
NewWriteBufferManagerWithCache similars to NewWriteBufferManager, we'll put dummy entries in the cache and cost the memory allocated to the cache. It can be used even if bufferSize = 0.
func (*WriteBufferManager) BufferSize ¶ added in v1.8.11
func (w *WriteBufferManager) BufferSize() int
BufferSize returns the buffer size.
func (*WriteBufferManager) CostToCache ¶ added in v1.8.11
func (w *WriteBufferManager) CostToCache() bool
CostToCache returns true if pointer to cache is passed.
func (*WriteBufferManager) Destroy ¶ added in v1.8.11
func (w *WriteBufferManager) Destroy()
Destroy the object.
func (*WriteBufferManager) DummyEntriesInCacheUsage ¶ added in v1.8.11
func (w *WriteBufferManager) DummyEntriesInCacheUsage() int
DummyEntriesInCacheUsage returns number of dummy entries in cache.
func (*WriteBufferManager) Enabled ¶ added in v1.8.11
func (w *WriteBufferManager) Enabled() bool
Enabled returns true if buffer_limit is passed to limit the total memory usage and is greater than 0.
func (*WriteBufferManager) MemoryUsage ¶ added in v1.8.11
func (w *WriteBufferManager) MemoryUsage() int
MemoryUsage returns the total memory used by memtables. Only valid if enabled().
func (*WriteBufferManager) MemtableMemoryUsage ¶ added in v1.8.11
func (w *WriteBufferManager) MemtableMemoryUsage() int
MemtableMemoryUsage returns the total memory used by active memtables.
func (*WriteBufferManager) SetBufferSize ¶ added in v1.8.11
func (w *WriteBufferManager) SetBufferSize(size int)
SetBufferSize sets buffer size.
func (*WriteBufferManager) ToggleAllowStall ¶ added in v1.8.11
func (w *WriteBufferManager) ToggleAllowStall(v bool)
ToggleAllowStall sets allow stall option.
type WriteOptions ¶
type WriteOptions struct {
// contains filtered or unexported fields
}
WriteOptions represent all of the available options when writing to a database.
func NewDefaultWriteOptions ¶
func NewDefaultWriteOptions() *WriteOptions
NewDefaultWriteOptions creates a default WriteOptions object.
func (*WriteOptions) Destroy ¶
func (opts *WriteOptions) Destroy()
Destroy deallocates the WriteOptions object.
func (*WriteOptions) DisableWAL ¶
func (opts *WriteOptions) DisableWAL(value bool)
DisableWAL 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) IgnoreMissingColumnFamilies ¶ added in v1.6.21
func (opts *WriteOptions) IgnoreMissingColumnFamilies() bool
IgnoreMissingColumnFamilies returns the setting for ignoring missing column famlies.
If true and if user is trying to write to column families that don't exist (they were dropped), ignore the write (don't return an error). If there are multiple writes in a WriteBatch, other writes will succeed.
func (*WriteOptions) IsDisableWAL ¶ added in v1.6.21
func (opts *WriteOptions) IsDisableWAL() bool
IsDisableWAL returns if we turned on DisableWAL flag for writing.
func (*WriteOptions) IsLowPri ¶ added in v1.6.21
func (opts *WriteOptions) IsLowPri() bool
IsLowPri returns if the write request is of lower priority if compaction is behind.
func (*WriteOptions) IsNoSlowdown ¶ added in v1.6.21
func (opts *WriteOptions) IsNoSlowdown() bool
IsNoSlowdown returns no_slow_down setting.
func (*WriteOptions) IsSync ¶ added in v1.6.21
func (opts *WriteOptions) IsSync() bool
IsSync returns if sync mode is turned on.
func (*WriteOptions) MemtableInsertHintPerBatch ¶ added in v1.6.21
func (opts *WriteOptions) MemtableInsertHintPerBatch() bool
MemtableInsertHintPerBatch returns if this writebatch will maintain the last insert positions of each memtable as hints in concurrent write.
func (*WriteOptions) SetIgnoreMissingColumnFamilies ¶
func (opts *WriteOptions) SetIgnoreMissingColumnFamilies(value bool)
SetIgnoreMissingColumnFamilies if true and if user is trying to write to column families that don't exist (they were dropped), ignore the write (don't return an error). If there are multiple writes in a WriteBatch, other writes will succeed.
Default: false
func (*WriteOptions) SetLowPri ¶
func (opts *WriteOptions) SetLowPri(value bool)
SetLowPri if true, this write request is of lower priority if compaction is behind. In this case, no_slowdown = true, the request will be cancelled immediately with Status::Incomplete() returned. Otherwise, it will be slowed down. The slowdown value is determined by RocksDB to guarantee it introduces minimum impacts to high priority writes.
Default: false
func (*WriteOptions) SetMemtableInsertHintPerBatch ¶ added in v1.6.11
func (opts *WriteOptions) SetMemtableInsertHintPerBatch(value bool)
SetMemtableInsertHintPerBatch if true, this writebatch will maintain the last insert positions of each memtable as hints in concurrent write. It can improve write performance in concurrent writes if keys in one writebatch are sequential. In non-concurrent writes (when concurrent_memtable_writes is false) this option will be ignored.
Default: false
func (*WriteOptions) SetNoSlowdown ¶
func (opts *WriteOptions) SetNoSlowdown(value bool)
SetNoSlowdown if true and we need to wait or sleep for the write request, fails immediately with Status::Incomplete().
Default: false
func (*WriteOptions) SetSync ¶
func (opts *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 ¶
- array.go
- backup.go
- cache.go
- cf_handle.go
- cf_metadata.go
- checkpoint.go
- compaction_filter.go
- comparator.go
- cow.go
- cuckoo_table.go
- db.go
- dbpath.go
- doc.go
- env.go
- filter_policy.go
- iterator.go
- logger.go
- mem_alloc.go
- memory_usage.go
- merge_operator.go
- non_builtin.go
- optimistic_transaction_db.go
- options.go
- options_backup.go
- options_block_based_table.go
- options_compaction.go
- options_compression.go
- options_env.go
- options_flush.go
- options_ingest.go
- options_read.go
- options_restore.go
- options_transaction.go
- options_transactiondb.go
- options_wait_for_compact.go
- options_write.go
- perf_context.go
- perf_level.go
- ratelimiter.go
- slice.go
- slice_transform.go
- snapshot.go
- sst_file_writer.go
- stats.go
- transaction.go
- transactiondb.go
- util.go
- wal_iterator.go
- write_batch.go
- write_batch_wi.go
- write_buffer_manager.go