Skip to content

Commit

Permalink
Add allow_ingest_behind ffi call for DB Options (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuan0322 committed Aug 7, 2023
1 parent 41512c0 commit b993275
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ jobs:
run: |
cargo test --all
cargo test --all --features multi-threaded-cf
- name: Free disk space
run: cargo clean
- name: Run rocksdb tests (jemalloc)
if: runner.os != 'Windows'
run: cargo test --all --features jemalloc
18 changes: 18 additions & 0 deletions src/db_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,24 @@ impl Options {
ffi::rocksdb_options_set_blob_compaction_readahead_size(self.inner, val);
}
}

/// 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 has the following effects:
/// 1) Disable some internal optimizations around SST file compression.
/// 2) Reserve the last level for ingested files only.
/// 3) Compaction will not include any file from the last level.
/// Note that only Universal Compaction supports allow_ingest_behind.
/// `num_levels` should be >= 3 if this option is turned on.
///
/// DEFAULT: false
/// Immutable.
pub fn set_allow_ingest_behind(&mut self, val: bool) {
unsafe {
ffi::rocksdb_options_set_allow_ingest_behind(self.inner, c_uchar::from(val));
}
}
}

impl Default for Options {
Expand Down
6 changes: 3 additions & 3 deletions tests/test_comparator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ pub fn rocks_old_compare(one: &[u8], two: &[u8]) -> Ordering {
one.cmp(two)
}

type CompareFn = dyn Fn(&[u8], &[u8]) -> Ordering;

/// create database add some values, and iterate over these
pub fn write_to_db_with_comparator(
compare_fn: Box<dyn Fn(&[u8], &[u8]) -> Ordering>,
) -> Vec<String> {
pub fn write_to_db_with_comparator(compare_fn: Box<CompareFn>) -> Vec<String> {
let mut result_vec = Vec::new();

let path = "_path_for_rocksdb_storage";
Expand Down

0 comments on commit b993275

Please sign in to comment.