File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ using ROCKSDB_NAMESPACE::TransactionDB;
119119using ROCKSDB_NAMESPACE ::TransactionDBOptions;
120120using ROCKSDB_NAMESPACE ::TransactionLogIterator;
121121using ROCKSDB_NAMESPACE ::TransactionOptions;
122+ using ROCKSDB_NAMESPACE ::WaitForCompactOptions;
122123using ROCKSDB_NAMESPACE ::WALRecoveryMode;
123124using ROCKSDB_NAMESPACE ::WritableFile;
124125using ROCKSDB_NAMESPACE ::WriteBatch;
@@ -274,6 +275,9 @@ struct rocksdb_optimistictransactiondb_t {
274275struct rocksdb_optimistictransaction_options_t {
275276 OptimisticTransactionOptions rep;
276277};
278+ struct rocksdb_wait_for_compact_options_t {
279+ WaitForCompactOptions rep;
280+ };
277281
278282struct rocksdb_compactionfiltercontext_t {
279283 CompactionFilter::Context rep;
@@ -6555,5 +6559,10 @@ void rocksdb_disable_manual_compaction(rocksdb_t* db) {
65556559void rocksdb_enable_manual_compaction (rocksdb_t * db) {
65566560 db->rep ->EnableManualCompaction ();
65576561}
6562+ void rocksdb_wait_for_compact (
6563+ rocksdb_t * db,
6564+ rocksdb_wait_for_compact_options_t * wait_for_compact_options) {
6565+ db->rep ->WaitForCompact (wait_for_compact_options->rep );
6566+ }
65586567
65596568} // end extern "C"
Original file line number Diff line number Diff line change @@ -1061,7 +1061,7 @@ class DBImpl : public DB {
10611061 // with options to flush before waiting for compaction to finish and close db
10621062 // upon the completion of compaction
10631063 Status WaitForCompact (
1064- const WaitForCompactionsOptions& wait_for_compaction_options) ;
1064+ const WaitForCompactOptions& wait_for_compact_options) override ;
10651065
10661066#ifndef NDEBUG
10671067 // Compact any files in the named level that overlap [*begin, *end]
@@ -1108,7 +1108,7 @@ class DBImpl : public DB {
11081108 // with options to flush before waiting for compaction to finish and close db
11091109 // upon the completion of compaction
11101110 Status TEST_WaitForCompact (
1111- const WaitForCompactionsOptions& wait_for_compaction_options );
1111+ const WaitForCompactOptions& wait_for_compact_options );
11121112
11131113 // Wait for any background purge
11141114 Status TEST_WaitForPurge ();
Original file line number Diff line number Diff line change @@ -3970,14 +3970,8 @@ Status DBImpl::WaitForCompact(bool wait_unscheduled) {
39703970}
39713971
39723972Status DBImpl::WaitForCompact (
3973- const WaitForCompactionsOptions& wait_for_compaction_options) {
3974- if (wait_for_compaction_options.flush ) {
3975- MaybeScheduleFlushOrCompaction ();
3976- }
3977- InstrumentedMutexLock l (&mutex_);
3978- if (wait_for_compaction_options.close_db ) {
3979- }
3980- return error_handler_.GetBGError ();
3973+ const WaitForCompactOptions& /* wait_for_compact_options*/ ) {
3974+ return DBImpl::WaitForCompact ();
39813975}
39823976
39833977} // namespace ROCKSDB_NAMESPACE
Original file line number Diff line number Diff line change @@ -183,6 +183,13 @@ Status DBImpl::TEST_WaitForCompact(bool wait_unscheduled) {
183183 return WaitForCompact (wait_unscheduled);
184184}
185185
186+ Status DBImpl::TEST_WaitForCompact (
187+ const WaitForCompactOptions& wait_for_compact_options) {
188+ // Wait until the compaction completes with options to flush before compaction
189+ // and close db after compaction
190+ return WaitForCompact (wait_for_compact_options);
191+ }
192+
186193Status DBImpl::TEST_WaitForPurge () {
187194 InstrumentedMutexLock l (&mutex_);
188195 while (bg_purge_scheduled_ && error_handler_.GetBGError ().ok ()) {
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ struct Options;
5353struct ReadOptions ;
5454struct TableProperties ;
5555struct WriteOptions ;
56- struct WaitForCompactionsOptions ;
56+ struct WaitForCompactOptions ;
5757class Env ;
5858class EventListener ;
5959class FileSystem ;
@@ -1448,6 +1448,12 @@ class DB {
14481448 // DisableManualCompaction() has been called.
14491449 virtual void EnableManualCompaction () = 0;
14501450
1451+ // Wait for Compaction to finish
1452+ virtual Status WaitForCompact (
1453+ const WaitForCompactOptions& /* wait_for_compact_options */ ) {
1454+ return Status::NotSupported (" WaitForCompact Not implemented" );
1455+ }
1456+
14511457 // Number of levels used for this DB.
14521458 virtual int NumberLevels (ColumnFamilyHandle* column_family) = 0;
14531459 virtual int NumberLevels () { return NumberLevels (DefaultColumnFamily ()); }
Original file line number Diff line number Diff line change @@ -2080,14 +2080,6 @@ struct LiveFilesStorageInfoOptions {
20802080 uint64_t wal_size_for_flush = 0 ;
20812081};
20822082
2083- struct WaitForCompactionsOptions {
2084- // If true, flush before waiting for compactions to finish.
2085- // Must be set to true to ensure no immediate compactions after closing and
2086- // re-opening the DB
2087- bool flush = false ;
2088-
2089- // If true, will close the DB upon compactions finishing
2090- bool close_db = false ;
2091- };
2083+ struct WaitForCompactOptions {};
20922084
20932085} // namespace ROCKSDB_NAMESPACE
You can’t perform that action at this time.
0 commit comments