Unverified Commit 4fbd3dc1 authored by Xintao's avatar Xintao Committed by GitHub

Add api to set compression option for bottommost level (#559)

Signed-off-by: 's avatarXintao <hunterlxt@live.com>
parent ee59a00c
...@@ -2070,8 +2070,9 @@ extern "C" { ...@@ -2070,8 +2070,9 @@ extern "C" {
); );
} }
extern "C" { extern "C" {
pub fn crocksdb_options_get_max_background_compactions(arg1: *const crocksdb_options_t) pub fn crocksdb_options_get_max_background_compactions(
-> libc::c_int; arg1: *const crocksdb_options_t,
) -> libc::c_int;
} }
extern "C" { extern "C" {
pub fn crocksdb_options_set_max_background_flushes( pub fn crocksdb_options_set_max_background_flushes(
...@@ -2080,8 +2081,9 @@ extern "C" { ...@@ -2080,8 +2081,9 @@ extern "C" {
); );
} }
extern "C" { extern "C" {
pub fn crocksdb_options_get_max_background_flushes(arg1: *const crocksdb_options_t) pub fn crocksdb_options_get_max_background_flushes(
-> libc::c_int; arg1: *const crocksdb_options_t,
) -> libc::c_int;
} }
extern "C" { extern "C" {
pub fn crocksdb_options_set_max_log_file_size(arg1: *mut crocksdb_options_t, arg2: usize); pub fn crocksdb_options_set_max_log_file_size(arg1: *mut crocksdb_options_t, arg2: usize);
......
...@@ -4,6 +4,7 @@ pub const __GNUC_VA_LIST: u32 = 1; ...@@ -4,6 +4,7 @@ pub const __GNUC_VA_LIST: u32 = 1;
pub const _STDINT_H: u32 = 1; pub const _STDINT_H: u32 = 1;
pub const _FEATURES_H: u32 = 1; pub const _FEATURES_H: u32 = 1;
pub const _DEFAULT_SOURCE: u32 = 1; pub const _DEFAULT_SOURCE: u32 = 1;
pub const __GLIBC_USE_ISOC2X: u32 = 0;
pub const __USE_ISOC11: u32 = 1; pub const __USE_ISOC11: u32 = 1;
pub const __USE_ISOC99: u32 = 1; pub const __USE_ISOC99: u32 = 1;
pub const __USE_ISOC95: u32 = 1; pub const __USE_ISOC95: u32 = 1;
...@@ -21,30 +22,36 @@ pub const __USE_MISC: u32 = 1; ...@@ -21,30 +22,36 @@ pub const __USE_MISC: u32 = 1;
pub const __USE_ATFILE: u32 = 1; pub const __USE_ATFILE: u32 = 1;
pub const __USE_FORTIFY_LEVEL: u32 = 0; pub const __USE_FORTIFY_LEVEL: u32 = 0;
pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0;
pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0;
pub const _STDC_PREDEF_H: u32 = 1; pub const _STDC_PREDEF_H: u32 = 1;
pub const __STDC_IEC_559__: u32 = 1; pub const __STDC_IEC_559__: u32 = 1;
pub const __STDC_IEC_559_COMPLEX__: u32 = 1; pub const __STDC_IEC_559_COMPLEX__: u32 = 1;
pub const __STDC_ISO_10646__: u32 = 201706; pub const __STDC_ISO_10646__: u32 = 201706;
pub const __STDC_NO_THREADS__: u32 = 1;
pub const __GNU_LIBRARY__: u32 = 6; pub const __GNU_LIBRARY__: u32 = 6;
pub const __GLIBC__: u32 = 2; pub const __GLIBC__: u32 = 2;
pub const __GLIBC_MINOR__: u32 = 27; pub const __GLIBC_MINOR__: u32 = 31;
pub const _SYS_CDEFS_H: u32 = 1; pub const _SYS_CDEFS_H: u32 = 1;
pub const __glibc_c99_flexarr_available: u32 = 1; pub const __glibc_c99_flexarr_available: u32 = 1;
pub const __WORDSIZE: u32 = 64; pub const __WORDSIZE: u32 = 64;
pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1;
pub const __SYSCALL_WORDSIZE: u32 = 64; pub const __SYSCALL_WORDSIZE: u32 = 64;
pub const __LONG_DOUBLE_USES_FLOAT128: u32 = 0;
pub const __HAVE_GENERIC_SELECTION: u32 = 1; pub const __HAVE_GENERIC_SELECTION: u32 = 1;
pub const __GLIBC_USE_LIB_EXT2: u32 = 0; pub const __GLIBC_USE_LIB_EXT2: u32 = 0;
pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0;
pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0;
pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0;
pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0;
pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0;
pub const _BITS_TYPES_H: u32 = 1; pub const _BITS_TYPES_H: u32 = 1;
pub const __TIMESIZE: u32 = 64;
pub const _BITS_TYPESIZES_H: u32 = 1; pub const _BITS_TYPESIZES_H: u32 = 1;
pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; pub const __OFF_T_MATCHES_OFF64_T: u32 = 1;
pub const __INO_T_MATCHES_INO64_T: u32 = 1; pub const __INO_T_MATCHES_INO64_T: u32 = 1;
pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1;
pub const __STATFS_MATCHES_STATFS64: u32 = 1;
pub const __FD_SETSIZE: u32 = 1024; pub const __FD_SETSIZE: u32 = 1024;
pub const _BITS_TIME64_H: u32 = 1;
pub const _BITS_WCHAR_H: u32 = 1; pub const _BITS_WCHAR_H: u32 = 1;
pub const _BITS_STDINT_INTN_H: u32 = 1; pub const _BITS_STDINT_INTN_H: u32 = 1;
pub const _BITS_STDINT_UINTN_H: u32 = 1; pub const _BITS_STDINT_UINTN_H: u32 = 1;
...@@ -145,6 +152,14 @@ pub type __int32_t = libc::c_int; ...@@ -145,6 +152,14 @@ pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint; pub type __uint32_t = libc::c_uint;
pub type __int64_t = libc::c_long; pub type __int64_t = libc::c_long;
pub type __uint64_t = libc::c_ulong; pub type __uint64_t = libc::c_ulong;
pub type __int_least8_t = __int8_t;
pub type __uint_least8_t = __uint8_t;
pub type __int_least16_t = __int16_t;
pub type __uint_least16_t = __uint16_t;
pub type __int_least32_t = __int32_t;
pub type __uint_least32_t = __uint32_t;
pub type __int_least64_t = __int64_t;
pub type __uint_least64_t = __uint64_t;
pub type __quad_t = libc::c_long; pub type __quad_t = libc::c_long;
pub type __u_quad_t = libc::c_ulong; pub type __u_quad_t = libc::c_ulong;
pub type __intmax_t = libc::c_long; pub type __intmax_t = libc::c_long;
...@@ -214,14 +229,14 @@ pub type __caddr_t = *mut libc::c_char; ...@@ -214,14 +229,14 @@ pub type __caddr_t = *mut libc::c_char;
pub type __intptr_t = libc::c_long; pub type __intptr_t = libc::c_long;
pub type __socklen_t = libc::c_uint; pub type __socklen_t = libc::c_uint;
pub type __sig_atomic_t = libc::c_int; pub type __sig_atomic_t = libc::c_int;
pub type int_least8_t = libc::c_schar; pub type int_least8_t = __int_least8_t;
pub type int_least16_t = libc::c_short; pub type int_least16_t = __int_least16_t;
pub type int_least32_t = libc::c_int; pub type int_least32_t = __int_least32_t;
pub type int_least64_t = libc::c_long; pub type int_least64_t = __int_least64_t;
pub type uint_least8_t = libc::c_uchar; pub type uint_least8_t = __uint_least8_t;
pub type uint_least16_t = libc::c_ushort; pub type uint_least16_t = __uint_least16_t;
pub type uint_least32_t = libc::c_uint; pub type uint_least32_t = __uint_least32_t;
pub type uint_least64_t = libc::c_ulong; pub type uint_least64_t = __uint_least64_t;
pub type int_fast8_t = libc::c_schar; pub type int_fast8_t = libc::c_schar;
pub type int_fast16_t = libc::c_long; pub type int_fast16_t = libc::c_long;
pub type int_fast32_t = libc::c_long; pub type int_fast32_t = libc::c_long;
...@@ -2120,6 +2135,16 @@ extern "C" { ...@@ -2120,6 +2135,16 @@ extern "C" {
extern "C" { extern "C" {
pub fn crocksdb_options_set_max_total_wal_size(opt: *mut crocksdb_options_t, n: u64); pub fn crocksdb_options_set_max_total_wal_size(opt: *mut crocksdb_options_t, n: u64);
} }
extern "C" {
pub fn crocksdb_options_set_bottommost_compression_options(
arg1: *mut crocksdb_options_t,
arg2: libc::c_int,
arg3: libc::c_int,
arg4: libc::c_int,
arg5: libc::c_int,
arg6: libc::c_int,
);
}
extern "C" { extern "C" {
pub fn crocksdb_options_set_compression_options( pub fn crocksdb_options_set_compression_options(
arg1: *mut crocksdb_options_t, arg1: *mut crocksdb_options_t,
...@@ -2333,8 +2358,9 @@ extern "C" { ...@@ -2333,8 +2358,9 @@ extern "C" {
); );
} }
extern "C" { extern "C" {
pub fn crocksdb_options_get_max_background_compactions(arg1: *const crocksdb_options_t) pub fn crocksdb_options_get_max_background_compactions(
-> libc::c_int; arg1: *const crocksdb_options_t,
) -> libc::c_int;
} }
extern "C" { extern "C" {
pub fn crocksdb_options_set_max_background_flushes( pub fn crocksdb_options_set_max_background_flushes(
...@@ -2343,8 +2369,9 @@ extern "C" { ...@@ -2343,8 +2369,9 @@ extern "C" {
); );
} }
extern "C" { extern "C" {
pub fn crocksdb_options_get_max_background_flushes(arg1: *const crocksdb_options_t) pub fn crocksdb_options_get_max_background_flushes(
-> libc::c_int; arg1: *const crocksdb_options_t,
) -> libc::c_int;
} }
extern "C" { extern "C" {
pub fn crocksdb_options_set_max_log_file_size(arg1: *mut crocksdb_options_t, arg2: usize); pub fn crocksdb_options_set_max_log_file_size(arg1: *mut crocksdb_options_t, arg2: usize);
......
...@@ -2619,6 +2619,18 @@ void crocksdb_options_set_compression_options(crocksdb_options_t* opt, ...@@ -2619,6 +2619,18 @@ void crocksdb_options_set_compression_options(crocksdb_options_t* opt,
opt->rep.compression_opts.zstd_max_train_bytes = zstd_max_train_bytes; opt->rep.compression_opts.zstd_max_train_bytes = zstd_max_train_bytes;
} }
void crocksdb_options_set_bottommost_compression_options(
crocksdb_options_t* opt, int w_bits, int level, int strategy,
int max_dict_bytes, int zstd_max_train_bytes) {
opt->rep.bottommost_compression_opts.window_bits = w_bits;
opt->rep.bottommost_compression_opts.level = level;
opt->rep.bottommost_compression_opts.strategy = strategy;
opt->rep.bottommost_compression_opts.max_dict_bytes = max_dict_bytes;
opt->rep.bottommost_compression_opts.zstd_max_train_bytes =
zstd_max_train_bytes;
opt->rep.bottommost_compression_opts.enabled = true;
}
void crocksdb_options_set_use_direct_reads(crocksdb_options_t* opt, void crocksdb_options_set_use_direct_reads(crocksdb_options_t* opt,
unsigned char v) { unsigned char v) {
opt->rep.use_direct_reads = v; opt->rep.use_direct_reads = v;
......
...@@ -966,6 +966,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_open_files( ...@@ -966,6 +966,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_open_files(
crocksdb_options_t*, int); crocksdb_options_t*, int);
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_total_wal_size( extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_total_wal_size(
crocksdb_options_t* opt, uint64_t n); crocksdb_options_t* opt, uint64_t n);
extern C_ROCKSDB_LIBRARY_API void
crocksdb_options_set_bottommost_compression_options(crocksdb_options_t*, int,
int, int, int, int);
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_compression_options( extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_compression_options(
crocksdb_options_t*, int, int, int, int, int); crocksdb_options_t*, int, int, int, int, int);
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_use_direct_reads( extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_use_direct_reads(
......
...@@ -698,6 +698,14 @@ extern "C" { ...@@ -698,6 +698,14 @@ extern "C" {
max_dict_bytes: c_int, max_dict_bytes: c_int,
zstd_max_train_bytes: c_int, zstd_max_train_bytes: c_int,
); );
pub fn crocksdb_options_set_bottommost_compression_options(
options: *mut Options,
window_bits: c_int,
level: c_int,
strategy: c_int,
max_dict_bytes: c_int,
zstd_max_train_bytes: c_int,
);
pub fn crocksdb_options_set_compression_per_level( pub fn crocksdb_options_set_compression_per_level(
options: *mut Options, options: *mut Options,
level_values: *const DBCompressionType, level_values: *const DBCompressionType,
......
...@@ -3362,8 +3362,10 @@ mod test { ...@@ -3362,8 +3362,10 @@ mod test {
let db_opts = db.get_db_options(); let db_opts = db.get_db_options();
assert_eq!(db_opts.get_max_background_jobs(), 8); assert_eq!(db_opts.get_max_background_jobs(), 8);
db.set_db_options(&[("max_background_compactions", "6")]).unwrap(); db.set_db_options(&[("max_background_compactions", "6")])
db.set_db_options(&[("max_background_flushes", "3")]).unwrap(); .unwrap();
db.set_db_options(&[("max_background_flushes", "3")])
.unwrap();
let db_opts = db.get_db_options(); let db_opts = db.get_db_options();
assert_eq!(db_opts.get_max_background_jobs(), 8); assert_eq!(db_opts.get_max_background_jobs(), 8);
assert_eq!(db_opts.get_max_background_compactions(), 6); assert_eq!(db_opts.get_max_background_compactions(), 6);
......
...@@ -1426,6 +1426,26 @@ impl ColumnFamilyOptions { ...@@ -1426,6 +1426,26 @@ impl ColumnFamilyOptions {
} }
} }
pub fn set_bottommost_level_compression_options(
&mut self,
window_bits: i32,
level: i32,
strategy: i32,
max_dict_bytes: i32,
zstd_max_train_bytes: i32,
) {
unsafe {
crocksdb_ffi::crocksdb_options_set_bottommost_compression_options(
self.inner,
window_bits,
level,
strategy,
max_dict_bytes,
zstd_max_train_bytes,
)
}
}
pub fn compression_per_level(&mut self, level_types: &[DBCompressionType]) { pub fn compression_per_level(&mut self, level_types: &[DBCompressionType]) {
unsafe { unsafe {
crocksdb_ffi::crocksdb_options_set_compression_per_level( crocksdb_ffi::crocksdb_options_set_compression_per_level(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment