From ff04fb154bd74fd0681baa83b478095207e2719d Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Wed, 4 Jan 2023 19:36:43 -0800 Subject: [PATCH] Add C API for ReadOptions::async_io (#11062) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/11062 Reviewed By: hx235 Differential Revision: D42297489 Pulled By: ajkr fbshipit-source-id: 03fe1477c1ae1f8af73dc77a6986fdc7025edf4f --- db/c.cc | 9 +++++++++ db/c_test.c | 3 +++ include/rocksdb/c.h | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/db/c.cc b/db/c.cc index d5ac613b4..9615791a8 100644 --- a/db/c.cc +++ b/db/c.cc @@ -4449,6 +4449,15 @@ rocksdb_readoptions_get_io_timeout(rocksdb_readoptions_t* opt) { return opt->rep.io_timeout.count(); } +void rocksdb_readoptions_set_async_io(rocksdb_readoptions_t* opt, + unsigned char v) { + opt->rep.async_io = v; +} + +unsigned char rocksdb_readoptions_get_async_io(rocksdb_readoptions_t* opt) { + return opt->rep.async_io; +} + void rocksdb_readoptions_set_timestamp(rocksdb_readoptions_t* opt, const char* ts, size_t tslen) { if (ts == nullptr) { diff --git a/db/c_test.c b/db/c_test.c index 249ab9023..b6877d46a 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -2572,6 +2572,9 @@ int main(int argc, char** argv) { rocksdb_readoptions_set_io_timeout(ro, 400); CheckCondition(400 == rocksdb_readoptions_get_io_timeout(ro)); + rocksdb_readoptions_set_async_io(ro, 1); + CheckCondition(1 == rocksdb_readoptions_get_async_io(ro)); + rocksdb_readoptions_destroy(ro); } diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 5f3e586f2..11e4d2686 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1894,6 +1894,10 @@ 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*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_async_io( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_async_io( + rocksdb_readoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_timestamp( rocksdb_readoptions_t*, const char* ts, size_t tslen); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iter_start_ts(