Skip to content

Commit b993275

Browse files
authored
Add allow_ingest_behind ffi call for DB Options (rust-rocksdb#808)
1 parent 41512c0 commit b993275

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.github/workflows/rust.yml

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ jobs:
104104
run: |
105105
cargo test --all
106106
cargo test --all --features multi-threaded-cf
107+
- name: Free disk space
108+
run: cargo clean
107109
- name: Run rocksdb tests (jemalloc)
108110
if: runner.os != 'Windows'
109111
run: cargo test --all --features jemalloc

src/db_options.rs

+18
Original file line numberDiff line numberDiff line change
@@ -3056,6 +3056,24 @@ impl Options {
30563056
ffi::rocksdb_options_set_blob_compaction_readahead_size(self.inner, val);
30573057
}
30583058
}
3059+
3060+
/// Set this option to true during creation of database if you want
3061+
/// to be able to ingest behind (call IngestExternalFile() skipping keys
3062+
/// that already exist, rather than overwriting matching keys).
3063+
/// Setting this option to true has the following effects:
3064+
/// 1) Disable some internal optimizations around SST file compression.
3065+
/// 2) Reserve the last level for ingested files only.
3066+
/// 3) Compaction will not include any file from the last level.
3067+
/// Note that only Universal Compaction supports allow_ingest_behind.
3068+
/// `num_levels` should be >= 3 if this option is turned on.
3069+
///
3070+
/// DEFAULT: false
3071+
/// Immutable.
3072+
pub fn set_allow_ingest_behind(&mut self, val: bool) {
3073+
unsafe {
3074+
ffi::rocksdb_options_set_allow_ingest_behind(self.inner, c_uchar::from(val));
3075+
}
3076+
}
30593077
}
30603078

30613079
impl Default for Options {

tests/test_comparator.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ pub fn rocks_old_compare(one: &[u8], two: &[u8]) -> Ordering {
77
one.cmp(two)
88
}
99

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

1616
let path = "_path_for_rocksdb_storage";

0 commit comments

Comments
 (0)