From 3feee6db1739fd324e5b9acf1cb9ba32f8b60ce6 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Thu, 4 Feb 2021 16:59:18 -0800 Subject: [PATCH] Add get/set deadline and io_timeout C functions (read options) (#7914) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/7914 Reviewed By: jay-zhuang Differential Revision: D26184409 Pulled By: ajkr fbshipit-source-id: 8e30faac5223ec80c22e2b617af67775322065d8 --- db/c.cc | 19 +++++++++++++++++++ db/c_test.c | 6 ++++++ include/rocksdb/c.h | 8 ++++++++ 3 files changed, 33 insertions(+) diff --git a/db/c.cc b/db/c.cc index b93b42980..0741fec13 100644 --- a/db/c.cc +++ b/db/c.cc @@ -3936,6 +3936,25 @@ unsigned char rocksdb_readoptions_get_ignore_range_deletions( return opt->rep.ignore_range_deletions; } +void rocksdb_readoptions_set_deadline(rocksdb_readoptions_t* opt, + uint64_t microseconds) { + opt->rep.deadline = std::chrono::microseconds(microseconds); +} + +uint64_t rocksdb_readoptions_get_deadline(rocksdb_readoptions_t* opt) { + return opt->rep.deadline.count(); +} + +void rocksdb_readoptions_set_io_timeout(rocksdb_readoptions_t* opt, + uint64_t microseconds) { + opt->rep.io_timeout = std::chrono::microseconds(microseconds); +} + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_readoptions_get_io_timeout(rocksdb_readoptions_t* opt) { + return opt->rep.io_timeout.count(); +} + rocksdb_writeoptions_t* rocksdb_writeoptions_create() { return new rocksdb_writeoptions_t; } diff --git a/db/c_test.c b/db/c_test.c index df2c0e4d5..fd25280fe 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -2281,6 +2281,12 @@ int main(int argc, char** argv) { rocksdb_readoptions_set_ignore_range_deletions(ro, 1); CheckCondition(1 == rocksdb_readoptions_get_ignore_range_deletions(ro)); + rocksdb_readoptions_set_deadline(ro, 300); + CheckCondition(300 == rocksdb_readoptions_get_deadline(ro)); + + rocksdb_readoptions_set_io_timeout(ro, 400); + CheckCondition(400 == rocksdb_readoptions_get_io_timeout(ro)); + rocksdb_readoptions_destroy(ro); } diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index ed3382a7a..4d871b01d 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1617,6 +1617,14 @@ 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*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_deadline( + rocksdb_readoptions_t*, uint64_t microseconds); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_readoptions_get_deadline(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_io_timeout( + rocksdb_readoptions_t*, uint64_t microseconds); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_readoptions_get_io_timeout(rocksdb_readoptions_t*); /* Write options */