From b288f0131b752591a433b8990be50006d7b06689 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Thu, 20 Aug 2020 16:35:17 -0700 Subject: [PATCH] Add getters for the read options to the C API (#7289) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/7289 Reviewed By: akankshamahajan15 Differential Revision: D23252520 Pulled By: ajkr fbshipit-source-id: 85cea485a6dcaa1c67c32a83eb49a1b623966609 --- db/c.cc | 50 +++++++++++++++++++++++++++++++++++++++++++++ db/c_test.c | 43 ++++++++++++++++++++++++++++++++++++++ include/rocksdb/c.h | 23 +++++++++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/db/c.cc b/db/c.cc index 28c4051de1..94437d8cea 100644 --- a/db/c.cc +++ b/db/c.cc @@ -3612,11 +3612,20 @@ void rocksdb_readoptions_set_verify_checksums( opt->rep.verify_checksums = v; } +unsigned char rocksdb_readoptions_get_verify_checksums( + rocksdb_readoptions_t* opt) { + return opt->rep.verify_checksums; +} + void rocksdb_readoptions_set_fill_cache( rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.fill_cache = v; } +unsigned char rocksdb_readoptions_get_fill_cache(rocksdb_readoptions_t* opt) { + return opt->rep.fill_cache; +} + void rocksdb_readoptions_set_snapshot( rocksdb_readoptions_t* opt, const rocksdb_snapshot_t* snap) { @@ -3653,11 +3662,19 @@ void rocksdb_readoptions_set_read_tier( opt->rep.read_tier = static_cast(v); } +int rocksdb_readoptions_get_read_tier(rocksdb_readoptions_t* opt) { + return static_cast(opt->rep.read_tier); +} + void rocksdb_readoptions_set_tailing( rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.tailing = v; } +unsigned char rocksdb_readoptions_get_tailing(rocksdb_readoptions_t* opt) { + return opt->rep.tailing; +} + void rocksdb_readoptions_set_managed( rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.managed = v; @@ -3668,37 +3685,70 @@ void rocksdb_readoptions_set_readahead_size( opt->rep.readahead_size = v; } +size_t rocksdb_readoptions_get_readahead_size(rocksdb_readoptions_t* opt) { + return opt->rep.readahead_size; +} + void rocksdb_readoptions_set_prefix_same_as_start( rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.prefix_same_as_start = v; } +unsigned char rocksdb_readoptions_get_prefix_same_as_start( + rocksdb_readoptions_t* opt) { + return opt->rep.prefix_same_as_start; +} + void rocksdb_readoptions_set_pin_data(rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.pin_data = v; } +unsigned char rocksdb_readoptions_get_pin_data(rocksdb_readoptions_t* opt) { + return opt->rep.pin_data; +} + void rocksdb_readoptions_set_total_order_seek(rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.total_order_seek = v; } +unsigned char rocksdb_readoptions_get_total_order_seek( + rocksdb_readoptions_t* opt) { + return opt->rep.total_order_seek; +} + void rocksdb_readoptions_set_max_skippable_internal_keys( rocksdb_readoptions_t* opt, uint64_t v) { opt->rep.max_skippable_internal_keys = v; } +uint64_t rocksdb_readoptions_get_max_skippable_internal_keys( + rocksdb_readoptions_t* opt) { + return opt->rep.max_skippable_internal_keys; +} + void rocksdb_readoptions_set_background_purge_on_iterator_cleanup( rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.background_purge_on_iterator_cleanup = v; } +unsigned char rocksdb_readoptions_get_background_purge_on_iterator_cleanup( + rocksdb_readoptions_t* opt) { + return opt->rep.background_purge_on_iterator_cleanup; +} + void rocksdb_readoptions_set_ignore_range_deletions( rocksdb_readoptions_t* opt, unsigned char v) { opt->rep.ignore_range_deletions = v; } +unsigned char rocksdb_readoptions_get_ignore_range_deletions( + rocksdb_readoptions_t* opt) { + return opt->rep.ignore_range_deletions; +} + rocksdb_writeoptions_t* rocksdb_writeoptions_create() { return new rocksdb_writeoptions_t; } diff --git a/db/c_test.c b/db/c_test.c index 67aaee0b08..b0b1031c5f 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -2235,6 +2235,49 @@ int main(int argc, char** argv) { rocksdb_options_destroy(o); } + StartPhase("read_options"); + { + rocksdb_readoptions_t* ro; + ro = rocksdb_readoptions_create(); + + rocksdb_readoptions_set_verify_checksums(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_verify_checksums(ro)); + + rocksdb_readoptions_set_fill_cache(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_fill_cache(ro)); + + rocksdb_readoptions_set_read_tier(ro, 2); + CheckCondition(2 == rocksdb_readoptions_get_read_tier(ro)); + + rocksdb_readoptions_set_tailing(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_tailing(ro)); + + rocksdb_readoptions_set_readahead_size(ro, 100); + CheckCondition(100 == rocksdb_readoptions_get_readahead_size(ro)); + + rocksdb_readoptions_set_prefix_same_as_start(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_prefix_same_as_start(ro)); + + rocksdb_readoptions_set_pin_data(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_pin_data(ro)); + + rocksdb_readoptions_set_total_order_seek(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_total_order_seek(ro)); + + rocksdb_readoptions_set_max_skippable_internal_keys(ro, 200); + CheckCondition(200 == + rocksdb_readoptions_get_max_skippable_internal_keys(ro)); + + rocksdb_readoptions_set_background_purge_on_iterator_cleanup(ro, 1); + CheckCondition( + 1 == rocksdb_readoptions_get_background_purge_on_iterator_cleanup(ro)); + + rocksdb_readoptions_set_ignore_range_deletions(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_ignore_range_deletions(ro)); + + rocksdb_readoptions_destroy(ro); + } + StartPhase("iterate_upper_bound"); { // Create new empty database diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index ffefd67851..a3808d6be3 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1454,8 +1454,12 @@ extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_destroy( rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_verify_checksums( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_verify_checksums(rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_fill_cache( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_fill_cache( + rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_snapshot( rocksdb_readoptions_t*, const rocksdb_snapshot_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iterate_upper_bound( @@ -1464,25 +1468,44 @@ extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iterate_lower_bound( rocksdb_readoptions_t*, const char* key, size_t keylen); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_read_tier( rocksdb_readoptions_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_readoptions_get_read_tier( + rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_tailing( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_tailing( + rocksdb_readoptions_t*); // The functionality that this option controlled has been removed. extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_managed( rocksdb_readoptions_t*, unsigned char); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_readahead_size( rocksdb_readoptions_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_readoptions_get_readahead_size(rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_prefix_same_as_start( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_prefix_same_as_start(rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_pin_data( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_pin_data( + rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_total_order_seek( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_total_order_seek(rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_max_skippable_internal_keys( rocksdb_readoptions_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_readoptions_get_max_skippable_internal_keys(rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_background_purge_on_iterator_cleanup( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_background_purge_on_iterator_cleanup( + rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_ignore_range_deletions( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_ignore_range_deletions(rocksdb_readoptions_t*); /* Write options */