From 133b97586e666403dad82188fcfb1e8d93ea94aa Mon Sep 17 00:00:00 2001 From: fredchenbj Date: Mon, 9 Dec 2019 19:23:39 +0800 Subject: [PATCH 1/3] change c.h and c.cc for bindgen ffi Signed-off-by: fredchenbj --- librocksdb_sys/crocksdb/c.cc | 51 ++++++++++++------------ librocksdb_sys/crocksdb/crocksdb/c.h | 58 +++++++++++++++------------- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/librocksdb_sys/crocksdb/c.cc b/librocksdb_sys/crocksdb/c.cc index b9555df7b..8564d4989 100644 --- a/librocksdb_sys/crocksdb/c.cc +++ b/librocksdb_sys/crocksdb/c.cc @@ -266,6 +266,9 @@ struct crocksdb_sst_file_meta_data_t { struct crocksdb_compaction_options_t { CompactionOptions rep; }; +struct crocksdb_compaction_reason_t { + CompactionReason rep; +}; struct crocksdb_map_property_t { std::map rep; @@ -746,7 +749,7 @@ crocksdb_t* crocksdb_open_column_families_with_ttl( const char** column_family_names, const crocksdb_options_t** column_family_options, const int32_t* ttl_array, - bool read_only, + unsigned char read_only, crocksdb_column_family_handle_t** column_family_handles, char** errptr) { std::vector column_families; @@ -1139,7 +1142,7 @@ void crocksdb_destroy_map_property(crocksdb_map_property_t* info) { delete info; } -bool crocksdb_get_map_property_cf( +unsigned char crocksdb_get_map_property_cf( crocksdb_t* db, crocksdb_column_family_handle_t* column_family, const char* property, @@ -1916,11 +1919,11 @@ const crocksdb_table_properties_t* crocksdb_flushjobinfo_table_properties( &info->rep.table_properties); } -bool crocksdb_flushjobinfo_triggered_writes_slowdown(const crocksdb_flushjobinfo_t* info) { +unsigned char crocksdb_flushjobinfo_triggered_writes_slowdown(const crocksdb_flushjobinfo_t* info) { return info->rep.triggered_writes_slowdown; } -bool crocksdb_flushjobinfo_triggered_writes_stop(const crocksdb_flushjobinfo_t* info) { +unsigned char crocksdb_flushjobinfo_triggered_writes_stop(const crocksdb_flushjobinfo_t* info) { return info->rep.triggered_writes_stop; } @@ -2003,9 +2006,9 @@ uint64_t crocksdb_compactionjobinfo_total_output_bytes( return info->rep.stats.total_output_bytes; } -CompactionReason crocksdb_compactionjobinfo_compaction_reason( +const crocksdb_compaction_reason_t* crocksdb_compactionjobinfo_compaction_reason( const crocksdb_compactionjobinfo_t* info) { - return info->rep.compaction_reason; + return reinterpret_cast(&info->rep.compaction_reason); } /* ExternalFileIngestionInfo */ @@ -2895,11 +2898,11 @@ void crocksdb_options_set_vector_memtable_factory(crocksdb_options_t* opt, uint6 opt->rep.memtable_factory.reset(new VectorRepFactory(reserved_bytes)); } -bool crocksdb_load_latest_options(const char* dbpath, crocksdb_env_t* env, +unsigned char crocksdb_load_latest_options(const char* dbpath, crocksdb_env_t* env, crocksdb_options_t* db_options, crocksdb_column_family_descriptor*** cf_descs, size_t* cf_descs_len, - bool ignore_unknown_options, char** errptr) { + unsigned char ignore_unknown_options, char** errptr) { std::vector tmp_cf_descs; Status s = rocksdb::LoadLatestOptions(dbpath, env->rep, &db_options->rep, &tmp_cf_descs, ignore_unknown_options); @@ -2934,7 +2937,7 @@ crocksdb_ratelimiter_t* crocksdb_ratelimiter_create_with_auto_tuned( int64_t refill_period_us, int32_t fairness, crocksdb_ratelimiter_mode_t mode, - bool auto_tuned) { + unsigned char auto_tuned) { crocksdb_ratelimiter_t* rate_limiter = new crocksdb_ratelimiter_t; RateLimiter::Mode m = RateLimiter::Mode::kWritesOnly; switch (mode) { @@ -3437,7 +3440,7 @@ void crocksdb_lru_cache_options_set_num_shard_bits( } void crocksdb_lru_cache_options_set_strict_capacity_limit( - crocksdb_lru_cache_options_t* opt, bool strict_capacity_limit) { + crocksdb_lru_cache_options_t* opt, unsigned char strict_capacity_limit) { opt->rep.strict_capacity_limit = strict_capacity_limit; } @@ -3785,7 +3788,7 @@ void crocksdb_ingest_external_file_cf( SaveError(errptr, db->rep->IngestExternalFile(handle->rep, files, opt->rep)); } -bool crocksdb_ingest_external_file_optimized( +unsigned char crocksdb_ingest_external_file_optimized( crocksdb_t* db, crocksdb_column_family_handle_t* handle, const char* const* file_list, const size_t list_len, const crocksdb_ingestexternalfileoptions_t* opt, char** errptr) { @@ -3947,7 +3950,7 @@ void crocksdb_fifo_compaction_options_set_max_table_files_size( } void crocksdb_fifo_compaction_options_set_allow_compaction( - crocksdb_fifo_compaction_options_t* fifo_opts, bool allow_compaction) { + crocksdb_fifo_compaction_options_t* fifo_opts, unsigned char allow_compaction) { fifo_opts->rep.allow_compaction = allow_compaction; } @@ -4026,7 +4029,7 @@ void crocksdb_delete_files_in_range( crocksdb_t* db, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr) { + unsigned char include_end, char** errptr) { Slice a, b; SaveError( errptr, @@ -4041,7 +4044,7 @@ void crocksdb_delete_files_in_range_cf( crocksdb_t* db, crocksdb_column_family_handle_t* column_family, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr) { + unsigned char include_end, char** errptr) { Slice a, b; SaveError( errptr, @@ -4056,7 +4059,7 @@ void crocksdb_delete_files_in_ranges_cf( crocksdb_t* db, crocksdb_column_family_handle_t* cf, const char* const* start_keys, const size_t* start_keys_lens, const char* const* limit_keys, const size_t* limit_keys_lens, - size_t num_ranges, bool include_end, char** errptr) { + size_t num_ranges, unsigned char include_end, char** errptr) { std::vector starts(num_ranges); std::vector limits(num_ranges); std::vector ranges(num_ranges); @@ -5246,12 +5249,12 @@ void ctitandb_decode_blob_index(const char* value, size_t value_size, index->blob_size = bi.blob_handle.size; } -void ctitandb_encode_blob_index(const ctitandb_blob_index_t& index, +void ctitandb_encode_blob_index(const ctitandb_blob_index_t* index, char** value, size_t* value_size) { BlobIndex bi; - bi.file_number = index.file_number; - bi.blob_handle.offset = index.blob_offset; - bi.blob_handle.size = index.blob_size; + bi.file_number = index->file_number; + bi.blob_handle.offset = index->blob_offset; + bi.blob_handle.size = index->blob_size; std::string result; bi.EncodeTo(&result); *value = CopyString(result); @@ -5372,12 +5375,12 @@ void ctitandb_readoptions_destroy(ctitandb_readoptions_t* opts) { delete opts; } -bool ctitandb_readoptions_key_only(ctitandb_readoptions_t* opts) { +unsigned char ctitandb_readoptions_key_only(ctitandb_readoptions_t* opts) { return opts->rep.key_only; } void ctitandb_readoptions_set_key_only(ctitandb_readoptions_t* opts, - bool v) { + unsigned char v) { opts->rep.key_only = v; } @@ -5449,7 +5452,7 @@ void ctitandb_delete_files_in_range( crocksdb_t* db, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr) { + unsigned char include_end, char** errptr) { Slice a, b; RangePtr range( start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr, @@ -5467,7 +5470,7 @@ void ctitandb_delete_files_in_range_cf( crocksdb_t* db, crocksdb_column_family_handle_t* column_family, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr) { + unsigned char include_end, char** errptr) { Slice a, b; RangePtr range( start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr, @@ -5485,7 +5488,7 @@ void ctitandb_delete_files_in_ranges_cf( crocksdb_t* db, crocksdb_column_family_handle_t* cf, const char* const* start_keys, const size_t* start_keys_lens, const char* const* limit_keys, const size_t* limit_keys_lens, - size_t num_ranges, bool include_end, char** errptr) { + size_t num_ranges, unsigned char include_end, char** errptr) { std::vector starts(num_ranges); std::vector limits(num_ranges); std::vector ranges(num_ranges); diff --git a/librocksdb_sys/crocksdb/crocksdb/c.h b/librocksdb_sys/crocksdb/crocksdb/c.h index 6999b16a4..6d67e6e62 100644 --- a/librocksdb_sys/crocksdb/crocksdb/c.h +++ b/librocksdb_sys/crocksdb/crocksdb/c.h @@ -147,6 +147,7 @@ typedef struct crocksdb_iostats_context_t crocksdb_iostats_context_t; typedef struct crocksdb_writestallinfo_t crocksdb_writestallinfo_t; typedef struct crocksdb_writestallcondition_t crocksdb_writestallcondition_t; typedef struct crocksdb_map_property_t crocksdb_map_property_t; +typedef struct crocksdb_compaction_reason_t crocksdb_compaction_reason_t; typedef enum crocksdb_table_property_t { kDataSize = 1, @@ -254,7 +255,7 @@ extern C_ROCKSDB_LIBRARY_API crocksdb_t* crocksdb_open_column_families_with_ttl( const crocksdb_options_t* options, const char* name, int num_column_families, const char** column_family_names, const crocksdb_options_t** column_family_options, - const int32_t* ttl_array, bool read_only, + const int32_t* ttl_array, unsigned char read_only, crocksdb_column_family_handle_t** column_family_handles, char** errptr); @@ -402,7 +403,7 @@ extern C_ROCKSDB_LIBRARY_API crocksdb_map_property_t* crocksdb_create_map_proper extern C_ROCKSDB_LIBRARY_API void crocksdb_destroy_map_property(crocksdb_map_property_t* info); -extern C_ROCKSDB_LIBRARY_API bool crocksdb_get_map_property_cf( +extern C_ROCKSDB_LIBRARY_API unsigned char crocksdb_get_map_property_cf( crocksdb_t* db, crocksdb_column_family_handle_t* column_family, const char* property, crocksdb_map_property_t* data); @@ -711,13 +712,14 @@ extern C_ROCKSDB_LIBRARY_API const char* crocksdb_flushjobinfo_file_path( const crocksdb_flushjobinfo_t*, size_t*); extern C_ROCKSDB_LIBRARY_API const crocksdb_table_properties_t* crocksdb_flushjobinfo_table_properties(const crocksdb_flushjobinfo_t*); -extern C_ROCKSDB_LIBRARY_API bool +extern C_ROCKSDB_LIBRARY_API unsigned char crocksdb_flushjobinfo_triggered_writes_slowdown(const crocksdb_flushjobinfo_t*); -extern C_ROCKSDB_LIBRARY_API bool +extern C_ROCKSDB_LIBRARY_API unsigned char crocksdb_flushjobinfo_triggered_writes_stop(const crocksdb_flushjobinfo_t*); /* Compaction job info */ - +extern C_ROCKSDB_LIBRARY_API void crocksdb_compactionjobinfo_status(const crocksdb_compactionjobinfo_t* info, char** +errptr); extern C_ROCKSDB_LIBRARY_API const char* crocksdb_compactionjobinfo_cf_name( const crocksdb_compactionjobinfo_t*, size_t*); extern C_ROCKSDB_LIBRARY_API size_t @@ -755,9 +757,10 @@ crocksdb_compactionjobinfo_total_input_bytes( extern C_ROCKSDB_LIBRARY_API uint64_t crocksdb_compactionjobinfo_total_output_bytes( const crocksdb_compactionjobinfo_t* info); +extern C_ROCKSDB_LIBRARY_API const crocksdb_compaction_reason_t* +crocksdb_compactionjobinfo_compaction_reason(const crocksdb_compactionjobinfo_t* info); /* External file ingestion info */ - extern C_ROCKSDB_LIBRARY_API const char* crocksdb_externalfileingestioninfo_cf_name( const crocksdb_externalfileingestioninfo_t*, size_t*); @@ -940,10 +943,10 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_enable_statistics( crocksdb_options_t*, unsigned char); extern C_ROCKSDB_LIBRARY_API void crocksdb_options_reset_statistics( crocksdb_options_t*); -extern C_ROCKSDB_LIBRARY_API bool crocksdb_load_latest_options( +extern C_ROCKSDB_LIBRARY_API unsigned char crocksdb_load_latest_options( const char* dbpath, crocksdb_env_t* env, crocksdb_options_t* db_options, crocksdb_column_family_descriptor*** cf_descs, size_t* cf_descs_len, - bool ignore_unknown_options, char** errptr); + unsigned char ignore_unknown_options, char** errptr); /* returns a pointer to a malloc()-ed, null terminated string */ extern C_ROCKSDB_LIBRARY_API char* crocksdb_options_statistics_get_string( @@ -1161,7 +1164,7 @@ extern C_ROCKSDB_LIBRARY_API crocksdb_ratelimiter_t* crocksdb_ratelimiter_create int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness); extern C_ROCKSDB_LIBRARY_API crocksdb_ratelimiter_t* crocksdb_ratelimiter_create_with_auto_tuned( int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness, - crocksdb_ratelimiter_mode_t mode, bool auto_tuned); + crocksdb_ratelimiter_mode_t mode, unsigned char auto_tuned); extern C_ROCKSDB_LIBRARY_API void crocksdb_ratelimiter_destroy(crocksdb_ratelimiter_t*); extern C_ROCKSDB_LIBRARY_API void crocksdb_ratelimiter_set_bytes_per_second( crocksdb_ratelimiter_t *limiter, int64_t rate_bytes_per_sec); @@ -1376,7 +1379,7 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_lru_cache_options_set_capacity( extern C_ROCKSDB_LIBRARY_API void crocksdb_lru_cache_options_set_num_shard_bits( crocksdb_lru_cache_options_t*, int); extern C_ROCKSDB_LIBRARY_API void crocksdb_lru_cache_options_set_strict_capacity_limit( - crocksdb_lru_cache_options_t*, bool); + crocksdb_lru_cache_options_t*, unsigned char); extern C_ROCKSDB_LIBRARY_API void crocksdb_lru_cache_options_set_high_pri_pool_ratio( crocksdb_lru_cache_options_t*, double); extern C_ROCKSDB_LIBRARY_API void crocksdb_lru_cache_options_set_memory_allocator( @@ -1522,7 +1525,7 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_ingest_external_file_cf( crocksdb_t* db, crocksdb_column_family_handle_t* handle, const char* const* file_list, const size_t list_len, const crocksdb_ingestexternalfileoptions_t* opt, char** errptr); -extern C_ROCKSDB_LIBRARY_API bool crocksdb_ingest_external_file_optimized( +extern C_ROCKSDB_LIBRARY_API unsigned char crocksdb_ingest_external_file_optimized( crocksdb_t* db, crocksdb_column_family_handle_t* handle, const char* const* file_list, const size_t list_len, const crocksdb_ingestexternalfileoptions_t* opt, char** errptr); @@ -1581,7 +1584,7 @@ crocksdb_fifo_compaction_options_set_max_table_files_size( crocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size); extern C_ROCKSDB_LIBRARY_API void crocksdb_fifo_compaction_options_set_allow_compaction( - crocksdb_fifo_compaction_options_t* fifo_opts, bool allow_compaction); + crocksdb_fifo_compaction_options_t* fifo_opts, unsigned char allow_compaction); extern C_ROCKSDB_LIBRARY_API void crocksdb_fifo_compaction_options_destroy( crocksdb_fifo_compaction_options_t* fifo_opts); @@ -1610,19 +1613,19 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_delete_files_in_range( crocksdb_t* db, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr); + unsigned char include_end, char** errptr); extern C_ROCKSDB_LIBRARY_API void crocksdb_delete_files_in_range_cf( crocksdb_t* db, crocksdb_column_family_handle_t* column_family, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr); + unsigned char include_end, char** errptr); extern C_ROCKSDB_LIBRARY_API void crocksdb_delete_files_in_ranges_cf( crocksdb_t* db, crocksdb_column_family_handle_t* cf, const char* const* start_keys, const size_t* start_keys_lens, const char* const* limit_keys, const size_t* limit_keys_lens, - size_t num_ranges, bool include_end, char** errptr); + size_t num_ranges, unsigned char include_end, char** errptr); // referring to convention (3), this should be used by client // to free memory that was malloc()ed @@ -1764,17 +1767,16 @@ crocksdb_options_add_table_properties_collector_factory( crocksdb_options_t* opt, crocksdb_table_properties_collector_factory_t* f); /* Get Table Properties */ - extern C_ROCKSDB_LIBRARY_API crocksdb_table_properties_collection_t* -crocksdb_get_propeties_of_all_tables(crocksdb_t* db, char** errptr); +crocksdb_get_properties_of_all_tables(crocksdb_t* db, char** errptr); extern C_ROCKSDB_LIBRARY_API crocksdb_table_properties_collection_t* -crocksdb_get_propeties_of_all_tables_cf(crocksdb_t* db, +crocksdb_get_properties_of_all_tables_cf(crocksdb_t* db, crocksdb_column_family_handle_t* cf, char** errptr); extern C_ROCKSDB_LIBRARY_API crocksdb_table_properties_collection_t* -crocksdb_get_propeties_of_tables_in_range( +crocksdb_get_properties_of_tables_in_range( crocksdb_t* db, crocksdb_column_family_handle_t* cf, int num_ranges, const char* const* start_keys, const size_t* start_keys_lens, const char* const* limit_keys, const size_t* limit_keys_lens, @@ -1797,7 +1799,7 @@ extern C_ROCKSDB_LIBRARY_API const char * crocksdb_keyversions_key(const crocksdb_keyversions_t *kvs, int index); extern C_ROCKSDB_LIBRARY_API const char * -crocksdb_keyversions_key(const crocksdb_keyversions_t *kvs, int index); +crocksdb_keyversions_value(const crocksdb_keyversions_t *kvs, int index); extern C_ROCKSDB_LIBRARY_API uint64_t crocksdb_keyversions_seq(const crocksdb_keyversions_t *kvs, int index); @@ -2092,7 +2094,7 @@ extern C_ROCKSDB_LIBRARY_API void ctitandb_decode_blob_index( char** errptr); extern C_ROCKSDB_LIBRARY_API void ctitandb_encode_blob_index( - const ctitandb_blob_index_t& index, char** value, size_t* value_size); + const ctitandb_blob_index_t* index, char** value, size_t* value_size); extern C_ROCKSDB_LIBRARY_API void ctitandb_options_set_disable_background_gc( ctitandb_options_t* options, unsigned char disable); @@ -2145,19 +2147,21 @@ extern C_ROCKSDB_LIBRARY_API size_t ctitandb_options_get_blob_cache_capacity( extern C_ROCKSDB_LIBRARY_API void ctitandb_options_set_discardable_ratio( ctitandb_options_t* options, double ratio); -extern void ctitandb_options_set_sample_ratio(ctitandb_options_t* options, +extern void C_ROCKSDB_LIBRARY_API ctitandb_options_set_sample_ratio(ctitandb_options_t* options, double ratio); +extern void C_ROCKSDB_LIBRARY_API ctitandb_options_set_blob_run_mode(ctitandb_options_t* options, int mode); + /* TitanReadOptions */ extern C_ROCKSDB_LIBRARY_API ctitandb_readoptions_t* ctitandb_readoptions_create(); extern C_ROCKSDB_LIBRARY_API void ctitandb_readoptions_destroy(ctitandb_readoptions_t* opts); -extern C_ROCKSDB_LIBRARY_API bool ctitandb_readoptions_key_only(ctitandb_readoptions_t* opts); +extern C_ROCKSDB_LIBRARY_API unsigned char ctitandb_readoptions_key_only(ctitandb_readoptions_t* opts); extern C_ROCKSDB_LIBRARY_API void ctitandb_readoptions_set_key_only(ctitandb_readoptions_t* opts, - bool v); + unsigned char v); /* Titan Iterator */ @@ -2185,19 +2189,19 @@ extern C_ROCKSDB_LIBRARY_API void ctitandb_delete_files_in_range( crocksdb_t* db, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr); + unsigned char include_end, char** errptr); extern C_ROCKSDB_LIBRARY_API void ctitandb_delete_files_in_range_cf( crocksdb_t* db, crocksdb_column_family_handle_t* column_family, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, - bool include_end, char** errptr); + unsigned char include_end, char** errptr); extern C_ROCKSDB_LIBRARY_API void ctitandb_delete_files_in_ranges_cf( crocksdb_t* db, crocksdb_column_family_handle_t* cf, const char* const* start_keys, const size_t* start_keys_lens, const char* const* limit_keys, const size_t* limit_keys_lens, - size_t num_ranges, bool include_end, char** errptr); + size_t num_ranges, unsigned char include_end, char** errptr); #ifdef __cplusplus } /* end extern "C" */ From 64329903c708082246890186570f02daa40c67ef Mon Sep 17 00:00:00 2001 From: fredchenbj Date: Tue, 10 Dec 2019 12:03:31 +0800 Subject: [PATCH 2/3] fix ci error about test_event_listener_basic Signed-off-by: fredchenbj --- librocksdb_sys/src/lib.rs | 4 +++- src/event_listener.rs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/librocksdb_sys/src/lib.rs b/librocksdb_sys/src/lib.rs index 85b056e8c..d2c053dd4 100644 --- a/librocksdb_sys/src/lib.rs +++ b/librocksdb_sys/src/lib.rs @@ -151,6 +151,8 @@ pub struct DBWriteStallInfo(c_void); pub struct DBStatusPtr(c_void); #[repr(C)] pub struct DBMapProperty(c_void); +#[repr(C)] +pub struct DBCompactionReason(c_void); #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[repr(C)] @@ -1774,7 +1776,7 @@ extern "C" { pub fn crocksdb_compactionjobinfo_total_output_bytes(info: *const DBCompactionJobInfo) -> u64; pub fn crocksdb_compactionjobinfo_compaction_reason( info: *const DBCompactionJobInfo, - ) -> CompactionReason; + ) -> *const DBCompactionReason; pub fn crocksdb_externalfileingestioninfo_cf_name( info: *const DBIngestionInfo, diff --git a/src/event_listener.rs b/src/event_listener.rs index 0e336c9ca..d8dbd238f 100644 --- a/src/event_listener.rs +++ b/src/event_listener.rs @@ -126,7 +126,10 @@ impl CompactionJobInfo { } pub fn compaction_reason(&self) -> CompactionReason { - unsafe { crocksdb_ffi::crocksdb_compactionjobinfo_compaction_reason(&self.0) } + unsafe { + *(crocksdb_ffi::crocksdb_compactionjobinfo_compaction_reason(&self.0) + as *const CompactionReason) + } } } From d0c7595c1388cd8476ddb40842ff059d6bdf0fc0 Mon Sep 17 00:00:00 2001 From: fredchenbj Date: Tue, 10 Dec 2019 15:12:51 +0800 Subject: [PATCH 3/3] unchange code about CompactionReason Signed-off-by: fredchenbj --- librocksdb_sys/crocksdb/c.cc | 7 ++----- librocksdb_sys/crocksdb/crocksdb/c.h | 3 --- librocksdb_sys/src/lib.rs | 4 +--- src/event_listener.rs | 5 +---- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/librocksdb_sys/crocksdb/c.cc b/librocksdb_sys/crocksdb/c.cc index 8564d4989..c6a275224 100644 --- a/librocksdb_sys/crocksdb/c.cc +++ b/librocksdb_sys/crocksdb/c.cc @@ -266,9 +266,6 @@ struct crocksdb_sst_file_meta_data_t { struct crocksdb_compaction_options_t { CompactionOptions rep; }; -struct crocksdb_compaction_reason_t { - CompactionReason rep; -}; struct crocksdb_map_property_t { std::map rep; @@ -2006,9 +2003,9 @@ uint64_t crocksdb_compactionjobinfo_total_output_bytes( return info->rep.stats.total_output_bytes; } -const crocksdb_compaction_reason_t* crocksdb_compactionjobinfo_compaction_reason( +CompactionReason crocksdb_compactionjobinfo_compaction_reason( const crocksdb_compactionjobinfo_t* info) { - return reinterpret_cast(&info->rep.compaction_reason); + return info->rep.compaction_reason; } /* ExternalFileIngestionInfo */ diff --git a/librocksdb_sys/crocksdb/crocksdb/c.h b/librocksdb_sys/crocksdb/crocksdb/c.h index 6d67e6e62..95515051c 100644 --- a/librocksdb_sys/crocksdb/crocksdb/c.h +++ b/librocksdb_sys/crocksdb/crocksdb/c.h @@ -147,7 +147,6 @@ typedef struct crocksdb_iostats_context_t crocksdb_iostats_context_t; typedef struct crocksdb_writestallinfo_t crocksdb_writestallinfo_t; typedef struct crocksdb_writestallcondition_t crocksdb_writestallcondition_t; typedef struct crocksdb_map_property_t crocksdb_map_property_t; -typedef struct crocksdb_compaction_reason_t crocksdb_compaction_reason_t; typedef enum crocksdb_table_property_t { kDataSize = 1, @@ -757,8 +756,6 @@ crocksdb_compactionjobinfo_total_input_bytes( extern C_ROCKSDB_LIBRARY_API uint64_t crocksdb_compactionjobinfo_total_output_bytes( const crocksdb_compactionjobinfo_t* info); -extern C_ROCKSDB_LIBRARY_API const crocksdb_compaction_reason_t* -crocksdb_compactionjobinfo_compaction_reason(const crocksdb_compactionjobinfo_t* info); /* External file ingestion info */ extern C_ROCKSDB_LIBRARY_API const char* diff --git a/librocksdb_sys/src/lib.rs b/librocksdb_sys/src/lib.rs index d2c053dd4..85b056e8c 100644 --- a/librocksdb_sys/src/lib.rs +++ b/librocksdb_sys/src/lib.rs @@ -151,8 +151,6 @@ pub struct DBWriteStallInfo(c_void); pub struct DBStatusPtr(c_void); #[repr(C)] pub struct DBMapProperty(c_void); -#[repr(C)] -pub struct DBCompactionReason(c_void); #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[repr(C)] @@ -1776,7 +1774,7 @@ extern "C" { pub fn crocksdb_compactionjobinfo_total_output_bytes(info: *const DBCompactionJobInfo) -> u64; pub fn crocksdb_compactionjobinfo_compaction_reason( info: *const DBCompactionJobInfo, - ) -> *const DBCompactionReason; + ) -> CompactionReason; pub fn crocksdb_externalfileingestioninfo_cf_name( info: *const DBIngestionInfo, diff --git a/src/event_listener.rs b/src/event_listener.rs index d8dbd238f..0e336c9ca 100644 --- a/src/event_listener.rs +++ b/src/event_listener.rs @@ -126,10 +126,7 @@ impl CompactionJobInfo { } pub fn compaction_reason(&self) -> CompactionReason { - unsafe { - *(crocksdb_ffi::crocksdb_compactionjobinfo_compaction_reason(&self.0) - as *const CompactionReason) - } + unsafe { crocksdb_ffi::crocksdb_compactionjobinfo_compaction_reason(&self.0) } } }