Skip to content

Commit

Permalink
change c.h and c.cc for bindgen ffi (#401)
Browse files Browse the repository at this point in the history
* change c.h and c.cc for bindgen ffi

Signed-off-by: fredchenbj <cfworking@163.com>
  • Loading branch information
fredbjer authored and Connor1996 committed Dec 10, 2019
1 parent a3503b2 commit eb8d481
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 49 deletions.
44 changes: 22 additions & 22 deletions librocksdb_sys/crocksdb/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,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<ColumnFamilyDescriptor> column_families;
Expand Down Expand Up @@ -1139,7 +1139,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,
Expand Down Expand Up @@ -1916,11 +1916,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;
}

Expand Down Expand Up @@ -2895,11 +2895,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<ColumnFamilyDescriptor> tmp_cf_descs;
Status s = rocksdb::LoadLatestOptions(dbpath, env->rep, &db_options->rep,
&tmp_cf_descs, ignore_unknown_options);
Expand Down Expand Up @@ -2934,7 +2934,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) {
Expand Down Expand Up @@ -3437,7 +3437,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;
}

Expand Down Expand Up @@ -3785,7 +3785,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) {
Expand Down Expand Up @@ -3947,7 +3947,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;
}

Expand Down Expand Up @@ -4026,7 +4026,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,
Expand All @@ -4041,7 +4041,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,
Expand All @@ -4056,7 +4056,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<Slice> starts(num_ranges);
std::vector<Slice> limits(num_ranges);
std::vector<RangePtr> ranges(num_ranges);
Expand Down Expand Up @@ -5246,12 +5246,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);
Expand Down Expand Up @@ -5372,12 +5372,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;
}

Expand Down Expand Up @@ -5449,7 +5449,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,
Expand All @@ -5467,7 +5467,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,
Expand All @@ -5485,7 +5485,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<Slice> starts(num_ranges);
std::vector<Slice> limits(num_ranges);
std::vector<RangePtr> ranges(num_ranges);
Expand Down
55 changes: 28 additions & 27 deletions librocksdb_sys/crocksdb/crocksdb/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,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);

Expand Down Expand Up @@ -402,7 +402,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);

Expand Down Expand Up @@ -711,13 +711,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
Expand Down Expand Up @@ -757,7 +758,6 @@ crocksdb_compactionjobinfo_total_output_bytes(
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*);
Expand Down Expand Up @@ -940,10 +940,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(
Expand Down Expand Up @@ -1161,7 +1161,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);
Expand Down Expand Up @@ -1376,7 +1376,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(
Expand Down Expand Up @@ -1522,7 +1522,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);
Expand Down Expand Up @@ -1581,7 +1581,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);

Expand Down Expand Up @@ -1610,19 +1610,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
Expand Down Expand Up @@ -1764,17 +1764,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,
Expand All @@ -1797,7 +1796,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);
Expand Down Expand Up @@ -2092,7 +2091,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);
Expand Down Expand Up @@ -2145,19 +2144,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 */

Expand Down Expand Up @@ -2185,19 +2186,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" */
Expand Down

0 comments on commit eb8d481

Please sign in to comment.