Bump librocksdb-sys up to 6.11.4 (#466)

master
Oleksandr Anyshchenko 4 years ago committed by GitHub
parent 448f1c98b6
commit e8bb30aaa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 18
      librocksdb-sys/tests/ffi.rs
  3. 42
      src/merge_operator.rs

@ -3,6 +3,7 @@
## [Unreleased]
* Add `DB::cancel_all_background_work` method (stanislav-tkach)
* Bump `librocksdb-sys` up to 6.13.3 (aleksuss)
## 0.15.0 (2020-08-25)

@ -89,21 +89,25 @@ macro_rules! CheckCondition {
};
}
unsafe fn CheckEqual(expected: *const c_char, v: *const c_char, n: size_t) {
if expected.is_null() && v.is_null() {
// ok
unsafe fn CheckEqual(expected: *const c_char, actual: *const c_char, n: size_t) {
let is_equal = if expected.is_null() && actual.is_null() {
true
} else if !expected.is_null()
&& !v.is_null()
&& !actual.is_null()
&& n == strlen(expected)
&& memcmp(expected as *const c_void, v as *const c_void, n) == 0
&& memcmp(expected as *const c_void, actual as *const c_void, n) == 0
{
// ok
true
} else {
false
};
if !is_equal {
panic!(
"{}: expected '{}', got '{}'",
phase,
rstr(strndup(expected, n)),
rstr(strndup(v, 5))
rstr(strndup(actual, 5))
);
}
}

@ -114,15 +114,18 @@ pub unsafe extern "C" fn full_merge_callback(
existing_value_len as usize,
))
};
if let Some(result) = (cb.full_merge_fn)(key, oldval, operands) {
*new_value_length = result.len() as size_t;
*success = 1_u8;
Box::into_raw(result.into_boxed_slice()) as *mut c_char
} else {
*new_value_length = 0;
*success = 0_u8;
ptr::null_mut() as *mut c_char
}
(cb.full_merge_fn)(key, oldval, operands).map_or_else(
|| {
*new_value_length = 0;
*success = 0_u8;
ptr::null_mut() as *mut c_char
},
|result| {
*new_value_length = result.len() as size_t;
*success = 1_u8;
Box::into_raw(result.into_boxed_slice()) as *mut c_char
},
)
}
pub unsafe extern "C" fn partial_merge_callback(
@ -138,15 +141,18 @@ pub unsafe extern "C" fn partial_merge_callback(
let cb = &mut *(raw_cb as *mut MergeOperatorCallback);
let operands = &mut MergeOperands::new(operands_list, operands_list_len, num_operands);
let key = slice::from_raw_parts(raw_key as *const u8, key_len as usize);
if let Some(result) = (cb.partial_merge_fn)(key, None, operands) {
*new_value_length = result.len() as size_t;
*success = 1_u8;
Box::into_raw(result.into_boxed_slice()) as *mut c_char
} else {
*new_value_length = 0;
*success = 0_u8;
ptr::null_mut::<c_char>()
}
(cb.partial_merge_fn)(key, None, operands).map_or_else(
|| {
*new_value_length = 0;
*success = 0_u8;
ptr::null_mut::<c_char>()
},
|result| {
*new_value_length = result.len() as size_t;
*success = 1_u8;
Box::into_raw(result.into_boxed_slice()) as *mut c_char
},
)
}
pub struct MergeOperands {

Loading…
Cancel
Save