Merge pull request #184 from ekmartin/block_factory

Add index_type customization to BlockBasedOptions
master
Tyler Neely 6 years ago committed by GitHub
commit 8573a84ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/db_options.rs
  2. 14
      src/lib.rs

@ -19,7 +19,7 @@ use std::path::Path;
use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t};
use ffi;
use {BlockBasedOptions, DBCompactionStyle, DBCompressionType, DBRecoveryMode, MemtableFactory,
use {BlockBasedOptions, BlockBasedIndexType, DBCompactionStyle, DBCompressionType, DBRecoveryMode, MemtableFactory,
Options, WriteOptions};
use compaction_filter::{self, CompactionFilterCallback, CompactionFilterFn, filter_callback};
use comparator::{self, ComparatorCallback, CompareFn};
@ -96,6 +96,24 @@ impl BlockBasedOptions {
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 {

@ -136,6 +136,20 @@ pub struct BlockBasedOptions {
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,
}
/// Defines the underlying memtable implementation.
/// See https://github.com/facebook/rocksdb/wiki/MemTable for more information.
pub enum MemtableFactory {

Loading…
Cancel
Save