Merge pull request #248 from ekmartin/ek/plain_table

Add support for plain table factories
master
Jordan Terrell 6 years ago committed by GitHub
commit 5b47c1017f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      src/db_options.rs
  2. 15
      src/lib.rs

@ -27,7 +27,7 @@ use merge_operator::{
use slice_transform::SliceTransform; use slice_transform::SliceTransform;
use { use {
BlockBasedIndexType, BlockBasedOptions, DBCompactionStyle, DBCompressionType, DBRecoveryMode, BlockBasedIndexType, BlockBasedOptions, DBCompactionStyle, DBCompressionType, DBRecoveryMode,
MemtableFactory, Options, WriteOptions, MemtableFactory, Options, PlainTableFactoryOptions, WriteOptions,
}; };
pub fn new_cache(capacity: size_t) -> *mut ffi::rocksdb_cache_t { pub fn new_cache(capacity: size_t) -> *mut ffi::rocksdb_cache_t {
@ -982,6 +982,33 @@ impl Options {
} }
} }
/// See https://github.com/facebook/rocksdb/wiki/PlainTable-Format.
///
/// ```
/// use rocksdb::{Options, PlainTableFactoryOptions};
///
/// let mut opts = Options::default();
/// let factory_opts = PlainTableFactoryOptions {
/// user_key_length: 0,
/// bloom_bits_per_key: 20,
/// hash_table_ratio: 0.75,
/// index_sparseness: 16,
/// };
///
/// opts.set_plain_table_factory(&factory_opts);
/// ```
pub fn set_plain_table_factory(&mut self, options: &PlainTableFactoryOptions) {
unsafe {
ffi::rocksdb_options_set_plain_table_factory(
self.inner,
options.user_key_length,
options.bloom_bits_per_key,
options.hash_table_ratio,
options.index_sparseness,
);
}
}
/// Measure IO stats in compactions and flushes, if `true`. /// Measure IO stats in compactions and flushes, if `true`.
/// ///
/// Default: `false` /// Default: `false`

@ -176,6 +176,21 @@ pub enum MemtableFactory {
}, },
} }
/// Used with DBOptions::set_plain_table_factory.
/// See https://github.com/facebook/rocksdb/wiki/PlainTable-Format.
///
/// Defaults:
/// user_key_length: 0 (variable length)
/// bloom_bits_per_key: 10
/// hash_table_ratio: 0.75
/// index_sparseness: 16
pub struct PlainTableFactoryOptions {
pub user_key_length: u32,
pub bloom_bits_per_key: i32,
pub hash_table_ratio: f64,
pub index_sparseness: usize,
}
/// Database-wide options around performance and behavior. /// Database-wide options around performance and behavior.
/// ///
/// Please read [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide), and most importantly, measure performance under realistic workloads with realistic hardware. /// Please read [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide), and most importantly, measure performance under realistic workloads with realistic hardware.

Loading…
Cancel
Save