Expose DisableManualCompaction and EnableManualCompaction to C api (#10052)

Summary:
Add `rocksdb_disable_manual_compaction` and `rocksdb_enable_manual_compaction`.

Note that `rocksdb_enable_manual_compaction` should be used with care and must not be called more times than `rocksdb_disable_manual_compaction` has been called.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10052

Reviewed By: ajkr

Differential Revision: D36665496

Pulled By: jay-zhuang

fbshipit-source-id: a4ae6e34694066feb21302ca1a5c365fb9de0ec7
main
Jie Liang Ang 2 years ago committed by Facebook GitHub Bot
parent 28ea1fb44a
commit 4cf2f6723a
  1. 8
      db/c.cc
  2. 10
      db/c_test.c
  3. 5
      include/rocksdb/c.h

@ -5855,6 +5855,14 @@ void rocksdb_cancel_all_background_work(rocksdb_t* db, unsigned char wait) {
CancelAllBackgroundWork(db->rep, wait);
}
void rocksdb_disable_manual_compaction(rocksdb_t* db) {
db->rep->DisableManualCompaction();
}
void rocksdb_enable_manual_compaction(rocksdb_t* db) {
db->rep->EnableManualCompaction();
}
} // end extern "C"
#endif // !ROCKSDB_LITE

@ -293,6 +293,16 @@ static rocksdb_t* CheckCompaction(rocksdb_t* db, rocksdb_options_t* options,
CheckNoError(err);
CheckGet(db, roptions, "baz", "bazvalue");
// Disable compaction
rocksdb_disable_manual_compaction(db);
rocksdb_compact_range(db, NULL, 0, NULL, 0);
// should not filter anything when disabled
CheckGet(db, roptions, "foo", "foovalue");
CheckGet(db, roptions, "bar", "barvalue");
CheckGet(db, roptions, "baz", "bazvalue");
// Reenable compaction
rocksdb_enable_manual_compaction(db);
// Force compaction
rocksdb_compact_range(db, NULL, 0, NULL, 0);
// should have filtered bar, but not foo

@ -2464,6 +2464,11 @@ rocksdb_options_set_memtable_whole_key_filtering(rocksdb_options_t*,
extern ROCKSDB_LIBRARY_API void rocksdb_cancel_all_background_work(
rocksdb_t* db, unsigned char wait);
extern ROCKSDB_LIBRARY_API void rocksdb_disable_manual_compaction(
rocksdb_t* db);
extern ROCKSDB_LIBRARY_API void rocksdb_enable_manual_compaction(rocksdb_t* db);
#ifdef __cplusplus
} /* end extern "C" */
#endif

Loading…
Cancel
Save