@ -68,8 +68,7 @@ struct CompressionOptions {
strategy ( strategy ) { }
} ;
// Options to control the behavior of a database (passed to DB::Open)
struct Options {
struct ColumnFamilyOptions {
// -------------------
// Parameters that affect behavior
@ -120,36 +119,6 @@ struct Options {
// Default: a factory that doesn't provide any object
std : : shared_ptr < CompactionFilterFactory > compaction_filter_factory ;
// If true, the database will be created if it is missing.
// Default: false
bool create_if_missing ;
// If true, an error is raised if the database already exists.
// Default: false
bool error_if_exists ;
// 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
bool paranoid_checks ;
// Use the specified object to interact with the environment,
// e.g. to read/write files, schedule background work, etc.
// Default: Env::Default()
Env * env ;
// Any internal progress/error information generated by the db will
// be written to info_log if it is non-nullptr, or to a file stored
// in the same directory as the DB contents if info_log is nullptr.
// Default: nullptr
shared_ptr < Logger > info_log ;
// -------------------
// Parameters that affect performance
@ -181,13 +150,6 @@ struct Options {
// individual write buffers. Default: 1
int min_write_buffer_number_to_merge ;
// Number of open files that can be used by the DB. You may need to
// increase this if your database has a large working set (budget
// one open file per 2MB of working set).
//
// Default: 1000
int max_open_files ;
// Control over blocks (user data is stored in a set of blocks, and
// a block is the unit of reading from disk).
@ -357,6 +319,153 @@ struct Options {
// stop building a single file in a level->level+1 compaction.
int max_grandparent_overlap_factor ;
// Disable compaction triggered by seek.
// With bloomfilter and fast storage, a miss on one level
// is very cheap if the file handle is cached in table cache
// (which is true if max_open_files is large).
bool disable_seek_compaction ;
// Puts are delayed 0-1 ms when any level has a compaction score that exceeds
// soft_rate_limit. This is ignored when == 0.0.
// CONSTRAINT: soft_rate_limit <= hard_rate_limit. If this constraint does not
// hold, RocksDB will set soft_rate_limit = hard_rate_limit
// Default: 0 (disabled)
double soft_rate_limit ;
// Puts are delayed 1ms at a time when any level has a compaction score that
// exceeds hard_rate_limit. This is ignored when <= 1.0.
// Default: 0 (disabled)
double hard_rate_limit ;
// Max time a put will be stalled when hard_rate_limit is enforced. If 0, then
// there is no limit.
// Default: 1000
unsigned int rate_limit_delay_max_milliseconds ;
// Disable block cache. If this is set to true,
// then no block cache should be used, and the block_cache should
// point to a nullptr object.
// Default: false
bool no_block_cache ;
// Number of shards used for table cache.
int table_cache_numshardbits ;
// During data eviction of table's LRU cache, it would be inefficient
// to strictly follow LRU because this piece of memory will not really
// be released unless its refcount falls to zero. Instead, make two
// passes: the first pass will release items with refcount = 1,
// and if not enough space releases after scanning the number of
// elements specified by this parameter, we will remove items in LRU
// order.
int table_cache_remove_scan_count_limit ;
// Disable automatic compactions. Manual compactions can still
// be issued on this column family
bool disable_auto_compactions ;
// Purge duplicate/deleted keys when a memtable is flushed to storage.
// Default: true
bool purge_redundant_kvs_while_flush ;
// This is used to close a block before it reaches the configured
// 'block_size'. If the percentage of free space in the current block is less
// than this specified number and adding a new record to the block will
// exceed the configured block size, then this block will be closed and the
// new record will be written to the next block.
// Default is 10.
int block_size_deviation ;
// The compaction style. Default: kCompactionStyleLevel
CompactionStyle compaction_style ;
// The options needed to support Universal Style compactions
CompactionOptionsUniversal compaction_options_universal ;
// Use KeyMayExist API to filter deletes when this is true.
// If KeyMayExist returns false, i.e. the key definitely does not exist, then
// the delete is a noop. KeyMayExist only incurs in-memory look up.
// This optimization avoids writing the delete to storage when appropriate.
// Default: false
bool filter_deletes ;
// An iteration->Next() sequentially skips over keys with the same
// user-key unless this option is set. This number specifies the number
// of keys (with the same userkey) that will be sequentially
// skipped before a reseek is issued.
// Default: 8
uint64_t max_sequential_skip_in_iterations ;
// This is a factory that provides MemTableRep objects.
// Default: a factory that provides a skip-list-based implementation of
// MemTableRep.
std : : shared_ptr < MemTableRepFactory > memtable_factory ;
// This is a factory that provides TableFactory objects.
// Default: a factory that provides a default implementation of
// Table and TableBuilder.
std : : shared_ptr < TableFactory > table_factory ;
// This option allows user to to collect their own interested statistics of
// the tables.
// Default: emtpy vector -- no user-defined statistics collection will be
// performed.
std : : vector < std : : shared_ptr < TablePropertiesCollector > >
table_properties_collectors ;
// Allows thread-safe inplace updates. Requires Updates iff
// * 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.
bool inplace_update_support ;
// Number of locks used for inplace update
// Default: 10000, if inplace_update_support = true, else 0.
size_t inplace_update_num_locks ;
// Create ColumnFamilyOptions with default values for all fields
ColumnFamilyOptions ( ) ;
} ;
struct DBOptions {
// If true, the database will be created if it is missing.
// Default: false
bool create_if_missing ;
// If true, an error is raised if the database already exists.
// Default: false
bool error_if_exists ;
// 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
bool paranoid_checks ;
// Use the specified object to interact with the environment,
// e.g. to read/write files, schedule background work, etc.
// Default: Env::Default()
Env * env ;
// Any internal progress/error information generated by the db will
// be written to info_log if it is non-nullptr, or to a file stored
// in the same directory as the DB contents if info_log is nullptr.
// Default: nullptr
shared_ptr < Logger > info_log ;
// Number of open files that can be used by the DB. You may need to
// increase this if your database has a large working set (budget
// one open file per 2MB of working set).
//
// Default: 1000
int max_open_files ;
// If non-null, then we should collect metrics about database operations
// Statistics objects should not be shared between DB instances as
// it does not use any locks to prevent concurrent updates.
@ -398,12 +507,6 @@ struct Options {
// all log files in wal_dir and the dir itself is deleted
std : : string wal_dir ;
// Disable compaction triggered by seek.
// With bloomfilter and fast storage, a miss on one level
// is very cheap if the file handle is cached in table cache
// (which is true if max_open_files is large).
bool disable_seek_compaction ;
// The periodicity when obsolete files get deleted. The default
// value is 6 hours. The files that get out of scope by compaction
// process will still get automatically delete on every compaction,
@ -444,46 +547,11 @@ struct Options {
// Default: 1000
size_t keep_log_file_num ;
// Puts are delayed 0-1 ms when any level has a compaction score that exceeds
// soft_rate_limit. This is ignored when == 0.0.
// CONSTRAINT: soft_rate_limit <= hard_rate_limit. If this constraint does not
// hold, RocksDB will set soft_rate_limit = hard_rate_limit
// Default: 0 (disabled)
double soft_rate_limit ;
// Puts are delayed 1ms at a time when any level has a compaction score that
// exceeds hard_rate_limit. This is ignored when <= 1.0.
// Default: 0 (disabled)
double hard_rate_limit ;
// Max time a put will be stalled when hard_rate_limit is enforced. If 0, then
// there is no limit.
// Default: 1000
unsigned int rate_limit_delay_max_milliseconds ;
// manifest file is rolled over on reaching this limit.
// The older manifest file be deleted.
// The default value is MAX_INT so that roll-over does not take place.
uint64_t max_manifest_file_size ;
// Disable block cache. If this is set to true,
// then no block cache should be used, and the block_cache should
// point to a nullptr object.
// Default: false
bool no_block_cache ;
// Number of shards used for table cache.
int table_cache_numshardbits ;
// During data eviction of table's LRU cache, it would be inefficient
// to strictly follow LRU because this piece of memory will not really
// be released unless its refcount falls to zero. Instead, make two
// passes: the first pass will release items with refcount = 1,
// and if not enough space releases after scanning the number of
// elements specified by this parameter, we will remove items in LRU
// order.
int table_cache_remove_scan_count_limit ;
// size of one block in arena memory allocation.
// If <= 0, a proper value is automatically calculated (usually 1/10 of
// writer_buffer_size).
@ -491,24 +559,6 @@ struct Options {
// Default: 0
size_t arena_block_size ;
// Create an Options object with default values for all fields.
Options ( ) ;
void Dump ( Logger * log ) const ;
// Set appropriate parameters for bulk loading.
// The reason that this is a function that returns "this" instead of a
// constructor is to enable chaining of multiple similar calls in the future.
//
// 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.
Options * PrepareForBulkLoad ( ) ;
// Disable automatic compactions. Manual compactions can still
// be issued on this database.
bool disable_auto_compactions ;
// The following two fields affect how archived logs will be deleted.
// 1. If both set to 0, logs will be deleted asap and will not get into
// the archive.
@ -530,10 +580,6 @@ struct Options {
// large amounts of data (such as xfs's allocsize option).
size_t manifest_preallocation_size ;
// Purge duplicate/deleted keys when a memtable is flushed to storage.
// Default: true
bool purge_redundant_kvs_while_flush ;
// Data being read from file storage may be buffered in the OS
// Default: true
bool allow_os_buffer ;
@ -556,14 +602,6 @@ struct Options {
// Default: 3600 (1 hour)
unsigned int stats_dump_period_sec ;
// This is used to close a block before it reaches the configured
// 'block_size'. If the percentage of free space in the current block is less
// than this specified number and adding a new record to the block will
// exceed the configured block size, then this block will be closed and the
// new record will be written to the next block.
// Default is 10.
int block_size_deviation ;
// If set true, will hint the underlying file system that the file
// access pattern is random, when a sst file is opened.
// Default: true
@ -587,53 +625,31 @@ struct Options {
// Default: 0
uint64_t bytes_per_sync ;
// The compaction style. Default: kCompactionStyleLevel
CompactionStyle compaction_style ;
// The options needed to support Universal Style compactions
CompactionOptionsUniversal compaction_options_universal ;
// Use KeyMayExist API to filter deletes when this is true.
// If KeyMayExist returns false, i.e. the key definitely does not exist, then
// the delete is a noop. KeyMayExist only incurs in-memory look up.
// This optimization avoids writing the delete to storage when appropriate.
// Default: false
bool filter_deletes ;
// An iteration->Next() sequentially skips over keys with the same
// user-key unless this option is set. This number specifies the number
// of keys (with the same userkey) that will be sequentially
// skipped before a reseek is issued.
// Default: 8
uint64_t max_sequential_skip_in_iterations ;
// This is a factory that provides MemTableRep objects.
// Default: a factory that provides a skip-list-based implementation of
// MemTableRep.
std : : shared_ptr < MemTableRepFactory > memtable_factory ;
// Create DBOptions with default values for all fields
DBOptions ( ) ;
} ;
// This is a factory that provides TableFactory objects.
// Default: a factory that provides a default implementation of
// Table and TableBuilder.
std : : shared_ptr < TableFactory > table_factory ;
// Options to control the behavior of a database (passed to DB::Open)
struct Options : public DBOptions , public ColumnFamilyOptions {
// Create an Options object with default values for all fields.
Options ( ) :
DBOptions ( ) ,
ColumnFamilyOptions ( ) { }
// This option allows user to to collect their own interested statistics of
// the tables.
// Default: emtpy vector -- no user-defined statistics collection will be
// performed.
std : : vector < std : : shared_ptr < TablePropertiesCollector > >
table_properties_collectors ;
Options ( const DBOptions & db_options ,
const ColumnFamilyOptions & column_family_options )
: DBOptions ( db_options ) , ColumnFamilyOptions ( column_family_options ) { }
// Allows thread-safe inplace updates. Requires Updates iff
// * 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.
bool inplace_update_support ;
void Dump ( Logger * log ) const ;
// Number of locks used for inplace update
// Default: 10000, if inplace_update_support = true, else 0.
size_t inplace_update_num_locks ;
// Set appropriate parameters for bulk loading.
// The reason that this is a function that returns "this" instead of a
// constructor is to enable chaining of multiple similar calls in the future.
//
// 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.
Options * PrepareForBulkLoad ( ) ;
} ;
//