Add index_type customization to BlockBasedOptions

master
Martin Ek 7 years ago
parent 701669d076
commit aaf2270609
  1. 20
      src/db_options.rs
  2. 14
      src/lib.rs

@ -18,7 +18,7 @@ use std::mem;
use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t}; use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t};
use ffi; use ffi;
use {BlockBasedOptions, DBCompactionStyle, DBCompressionType, DBRecoveryMode, use {BlockBasedOptions, BlockBasedIndexType, DBCompactionStyle, DBCompressionType, DBRecoveryMode,
Options, WriteOptions}; Options, WriteOptions};
use compaction_filter::{self, CompactionFilterCallback, CompactionFilterFn, filter_callback}; use compaction_filter::{self, CompactionFilterCallback, CompactionFilterFn, filter_callback};
use comparator::{self, ComparatorCallback, CompareFn}; use comparator::{self, ComparatorCallback, CompareFn};
@ -89,6 +89,24 @@ impl BlockBasedOptions {
ffi::rocksdb_block_based_options_set_cache_index_and_filter_blocks(self.inner, v as u8); ffi::rocksdb_block_based_options_set_cache_index_and_filter_blocks(self.inner, v as u8);
} }
} }
/// Defines the index type to be used for SS-table lookups.
///
/// # Example
///
/// ```
/// use rocksdb::{BlockBasedOptions, BlockBasedIndexType, Options};
///
/// let mut opts = Options::default();
/// let mut block_opts = BlockBasedOptions::default();
/// block_opts.set_index_type(BlockBasedIndexType::HashSearch);
/// ```
pub fn set_index_type(&mut self, index_type: BlockBasedIndexType) {
let index = index_type as i32;
unsafe {
ffi::rocksdb_block_based_options_set_index_type(self.inner, index);
}
}
} }
impl Default for BlockBasedOptions { impl Default for BlockBasedOptions {

@ -136,6 +136,20 @@ pub struct BlockBasedOptions {
inner: *mut ffi::rocksdb_block_based_table_options_t, inner: *mut ffi::rocksdb_block_based_table_options_t,
} }
/// Used by BlockBasedOptions::set_index_type.
pub enum BlockBasedIndexType {
/// A space efficient index block that is optimized for
/// binary-search-based index.
BinarySearch,
/// The hash index, if enabled, will perform a hash lookup if
/// a prefix extractor has been provided through Options::set_prefix_extractor.
HashSearch,
/// A two-level index implementation. Both levels are binary search indexes.
TwoLevelIndexSearch,
}
/// 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