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. 30
      src/merge_operator.rs

@ -3,6 +3,7 @@
## [Unreleased] ## [Unreleased]
* Add `DB::cancel_all_background_work` method (stanislav-tkach) * Add `DB::cancel_all_background_work` method (stanislav-tkach)
* Bump `librocksdb-sys` up to 6.13.3 (aleksuss)
## 0.15.0 (2020-08-25) ## 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) { unsafe fn CheckEqual(expected: *const c_char, actual: *const c_char, n: size_t) {
if expected.is_null() && v.is_null() { let is_equal = if expected.is_null() && actual.is_null() {
// ok true
} else if !expected.is_null() } else if !expected.is_null()
&& !v.is_null() && !actual.is_null()
&& n == strlen(expected) && 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 { } else {
false
};
if !is_equal {
panic!( panic!(
"{}: expected '{}', got '{}'", "{}: expected '{}', got '{}'",
phase, phase,
rstr(strndup(expected, n)), 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, existing_value_len as usize,
)) ))
}; };
if let Some(result) = (cb.full_merge_fn)(key, oldval, operands) { (cb.full_merge_fn)(key, oldval, operands).map_or_else(
*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; *new_value_length = 0;
*success = 0_u8; *success = 0_u8;
ptr::null_mut() as *mut c_char 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( 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 cb = &mut *(raw_cb as *mut MergeOperatorCallback);
let operands = &mut MergeOperands::new(operands_list, operands_list_len, num_operands); 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); 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) { (cb.partial_merge_fn)(key, None, operands).map_or_else(
*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; *new_value_length = 0;
*success = 0_u8; *success = 0_u8;
ptr::null_mut::<c_char>() 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 { pub struct MergeOperands {

Loading…
Cancel
Save