From 653ac1f9c6df604fe3c528c374c21c6be4de2d76 Mon Sep 17 00:00:00 2001 From: siddontang Date: Tue, 3 Jan 2017 18:21:55 -0800 Subject: [PATCH] C API: support total_order_mode Summary: Closes https://github.com/facebook/rocksdb/pull/1687 Differential Revision: D4349210 Pulled By: IslamAbdelRahman fbshipit-source-id: 32d0fbd --- db/c.cc | 5 +++++ db/c_test.c | 13 +++++++++++++ include/rocksdb/c.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/db/c.cc b/db/c.cc index 73f6857bb..a1f642d4e 100644 --- a/db/c.cc +++ b/db/c.cc @@ -2256,6 +2256,11 @@ void rocksdb_readoptions_set_pin_data(rocksdb_readoptions_t* opt, opt->rep.pin_data = v; } +void rocksdb_readoptions_set_total_order_seek(rocksdb_readoptions_t* opt, + unsigned char v) { + opt->rep.total_order_seek = v; +} + rocksdb_writeoptions_t* rocksdb_writeoptions_create() { return new rocksdb_writeoptions_t; } diff --git a/db/c_test.c b/db/c_test.c index c8d624593..e0bf9e112 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -989,6 +989,19 @@ int main(int argc, char** argv) { CheckNoError(err); rocksdb_iter_destroy(iter); + rocksdb_readoptions_set_total_order_seek(roptions, 1); + iter = rocksdb_create_iterator(db, roptions); + CheckCondition(!rocksdb_iter_valid(iter)); + + rocksdb_iter_seek(iter, "ba", 2); + rocksdb_iter_get_error(iter, &err); + CheckNoError(err); + CheckCondition(rocksdb_iter_valid(iter)); + CheckIter(iter, "bar1", "bar"); + + rocksdb_iter_destroy(iter); + rocksdb_readoptions_set_total_order_seek(roptions, 0); + rocksdb_close(db); rocksdb_destroy_db(options, dbname, &err); } diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 5452fcb42..ae2496d02 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -879,6 +879,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_readahead_size( rocksdb_readoptions_t*, size_t); extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_pin_data( rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_total_order_seek( + rocksdb_readoptions_t*, unsigned char); /* Write options */