diff --git a/include/rocksdb/sst_file_manager.h b/include/rocksdb/sst_file_manager.h index 2d3c3be66..1474da955 100644 --- a/include/rocksdb/sst_file_manager.h +++ b/include/rocksdb/sst_file_manager.h @@ -75,6 +75,10 @@ class SstFileManager { // Update trash/DB size ratio where new files will be deleted immediately // thread-safe virtual void SetMaxTrashDBRatio(double ratio) = 0; + + // Return the total size of trash files + // thread-safe + virtual uint64_t GetTotalTrashSize() = 0; }; // Create a new SstFileManager that can be shared among multiple RocksDB diff --git a/util/sst_file_manager_impl.cc b/util/sst_file_manager_impl.cc index ea955e3fa..74164e06a 100644 --- a/util/sst_file_manager_impl.cc +++ b/util/sst_file_manager_impl.cc @@ -162,6 +162,10 @@ void SstFileManagerImpl::SetMaxTrashDBRatio(double r) { return delete_scheduler_.SetMaxTrashDBRatio(r); } +uint64_t SstFileManagerImpl::GetTotalTrashSize() { + return delete_scheduler_.GetTotalTrashSize(); +} + Status SstFileManagerImpl::ScheduleFileDeletion( const std::string& file_path, const std::string& path_to_sync) { return delete_scheduler_.DeleteFile(file_path, path_to_sync); diff --git a/util/sst_file_manager_impl.h b/util/sst_file_manager_impl.h index 73b9cf8b7..90815d44f 100644 --- a/util/sst_file_manager_impl.h +++ b/util/sst_file_manager_impl.h @@ -93,6 +93,9 @@ class SstFileManagerImpl : public SstFileManager { // Update trash/DB size ratio where new files will be deleted immediately virtual void SetMaxTrashDBRatio(double ratio) override; + // Return the total size of trash files + uint64_t GetTotalTrashSize() override; + // Mark file as trash and schedule it's deletion. virtual Status ScheduleFileDeletion(const std::string& file_path, const std::string& dir_to_sync);