From 989e644ed8bbdddebdf8f7365431986a60e4049f Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Wed, 21 Dec 2016 17:35:00 -0800 Subject: [PATCH] Remove sst_file_manager option from LITE Summary: Remove sst_file_manager option from LITE Closes https://github.com/facebook/rocksdb/pull/1690 Differential Revision: D4341331 Pulled By: IslamAbdelRahman fbshipit-source-id: 9f9328d --- db/compaction_job.cc | 2 ++ db/db_impl.cc | 4 +++- db/db_sst_test.cc | 5 ----- util/delete_scheduler.cc | 4 ++++ util/delete_scheduler.h | 4 ++++ util/delete_scheduler_test.cc | 9 +++++++++ util/file_util.cc | 5 +++++ util/sst_file_manager_impl.cc | 18 ++++++++++++++++++ util/sst_file_manager_impl.h | 4 ++++ 9 files changed, 49 insertions(+), 6 deletions(-) diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 4e3a5ecbb..42f32936c 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -1086,6 +1086,7 @@ Status CompactionJob::FinishCompactionOutputFile( event_logger_, cfd->ioptions()->listeners, dbname_, cfd->GetName(), fname, job_id_, meta->fd, tp, TableFileCreationReason::kCompaction, s); +#ifndef ROCKSDB_LITE // Report new file to SstFileManagerImpl auto sfm = static_cast(db_options_.sst_file_manager.get()); @@ -1103,6 +1104,7 @@ Status CompactionJob::FinishCompactionOutputFile( } } } +#endif sub_compact->builder.reset(); sub_compact->current_output_file_size = 0; diff --git a/db/db_impl.cc b/db/db_impl.cc index b70ee3281..e18599a02 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1928,7 +1928,6 @@ Status DBImpl::FlushMemTableToOutputFile( // may temporarily unlock and lock the mutex. NotifyOnFlushCompleted(cfd, &file_meta, mutable_cf_options, job_context->job_id, flush_job.GetTableProperties()); -#endif // ROCKSDB_LITE auto sfm = static_cast( immutable_db_options_.sst_file_manager.get()); if (sfm) { @@ -1942,6 +1941,7 @@ Status DBImpl::FlushMemTableToOutputFile( "DBImpl::FlushMemTableToOutputFile:MaxAllowedSpaceReached"); } } +#endif // ROCKSDB_LITE } return s; } @@ -6054,6 +6054,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname, } impl->mutex_.Unlock(); +#ifndef ROCKSDB_LITE auto sfm = static_cast( impl->immutable_db_options_.sst_file_manager.get()); if (s.ok() && sfm) { @@ -6072,6 +6073,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname, } } } +#endif // !ROCKSDB_LITE if (s.ok()) { Log(InfoLogLevel::INFO_LEVEL, impl->immutable_db_options_.info_log, diff --git a/db/db_sst_test.cc b/db/db_sst_test.cc index 06d140f75..fd4304379 100644 --- a/db/db_sst_test.cc +++ b/db/db_sst_test.cc @@ -221,8 +221,6 @@ TEST_F(DBSSTTest, DeleteObsoleteFilesPendingOutputs) { listener->VerifyMatchedCount(1); } -#endif // ROCKSDB_LITE - TEST_F(DBSSTTest, DBWithSstFileManager) { std::shared_ptr sst_file_manager(NewSstFileManager(env_)); auto sfm = static_cast(sst_file_manager.get()); @@ -287,7 +285,6 @@ TEST_F(DBSSTTest, DBWithSstFileManager) { rocksdb::SyncPoint::GetInstance()->DisableProcessing(); } -#ifndef ROCKSDB_LITE TEST_F(DBSSTTest, RateLimitedDelete) { Destroy(last_options_); rocksdb::SyncPoint::GetInstance()->LoadDependency({ @@ -482,7 +479,6 @@ TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) { // We have deleted the 4 sst files in the delete_scheduler ASSERT_EQ(bg_delete_file, 4); } -#endif // ROCKSDB_LITE TEST_F(DBSSTTest, DBWithMaxSpaceAllowed) { std::shared_ptr sst_file_manager(NewSstFileManager(env_)); @@ -580,7 +576,6 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) { ASSERT_GT(reached_max_space_on_compaction, 0); } -#ifndef ROCKSDB_LITE TEST_F(DBSSTTest, OpenDBWithInfiniteMaxOpenFiles) { // Open DB with infinite max open files // - First iteration use 1 thread to open files diff --git a/util/delete_scheduler.cc b/util/delete_scheduler.cc index 3a83f124b..e4779ad05 100644 --- a/util/delete_scheduler.cc +++ b/util/delete_scheduler.cc @@ -3,6 +3,8 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. +#ifndef ROCKSDB_LITE + #include "util/delete_scheduler.h" #include @@ -211,3 +213,5 @@ void DeleteScheduler::WaitForEmptyTrash() { } } // namespace rocksdb + +#endif // ROCKSDB_LITE diff --git a/util/delete_scheduler.h b/util/delete_scheduler.h index 331507da4..6b3730330 100644 --- a/util/delete_scheduler.h +++ b/util/delete_scheduler.h @@ -5,6 +5,8 @@ #pragma once +#ifndef ROCKSDB_LITE + #include #include #include @@ -88,3 +90,5 @@ class DeleteScheduler { }; } // namespace rocksdb + +#endif // ROCKSDB_LITE diff --git a/util/delete_scheduler_test.cc b/util/delete_scheduler_test.cc index 845c7ef1d..b1b5fae8a 100644 --- a/util/delete_scheduler_test.cc +++ b/util/delete_scheduler_test.cc @@ -20,6 +20,8 @@ #include "util/testharness.h" #include "util/testutil.h" +#ifndef ROCKSDB_LITE + namespace rocksdb { class DeleteSchedulerTest : public testing::Test { @@ -426,3 +428,10 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } + +#else +int main(int argc, char** argv) { + printf("DeleteScheduler is not supported in ROCKSDB_LITE\n"); + return 0; +} +#endif // ROCKSDB_LITE diff --git a/util/file_util.cc b/util/file_util.cc index 29a84555a..42b3dc1f3 100644 --- a/util/file_util.cc +++ b/util/file_util.cc @@ -84,6 +84,7 @@ Status CreateFile(Env* env, const std::string& destination, Status DeleteSSTFile(const ImmutableDBOptions* db_options, const std::string& fname, uint32_t path_id) { // TODO(tec): support sst_file_manager for multiple path_ids +#ifndef ROCKSDB_LITE auto sfm = static_cast(db_options->sst_file_manager.get()); if (sfm && path_id == 0) { @@ -91,6 +92,10 @@ Status DeleteSSTFile(const ImmutableDBOptions* db_options, } else { return db_options->env->DeleteFile(fname); } +#else + // SstFileManager is not supported in ROCKSDB_LITE + return db_options->env->DeleteFile(fname); +#endif } } // namespace rocksdb diff --git a/util/sst_file_manager_impl.cc b/util/sst_file_manager_impl.cc index bbf240cad..cff9a7389 100644 --- a/util/sst_file_manager_impl.cc +++ b/util/sst_file_manager_impl.cc @@ -9,11 +9,13 @@ #include "port/port.h" #include "rocksdb/env.h" +#include "rocksdb/sst_file_manager.h" #include "util/mutexlock.h" #include "util/sync_point.h" namespace rocksdb { +#ifndef ROCKSDB_LITE SstFileManagerImpl::SstFileManagerImpl(Env* env, std::shared_ptr logger, const std::string& trash_dir, int64_t rate_bytes_per_sec) @@ -154,4 +156,20 @@ SstFileManager* NewSstFileManager(Env* env, std::shared_ptr info_log, return res; } +#else + +SstFileManager* NewSstFileManager(Env* env, std::shared_ptr info_log, + std::string trash_dir, + int64_t rate_bytes_per_sec, + bool delete_exisitng_trash, Status* status) { + if (status) { + *status = + Status::NotSupported("SstFileManager is not supported in ROCKSDB_LITE"); + } + return nullptr; +} + +#endif // ROCKSDB_LITE + } // namespace rocksdb + diff --git a/util/sst_file_manager_impl.h b/util/sst_file_manager_impl.h index ca9ddedba..543c9d95a 100644 --- a/util/sst_file_manager_impl.h +++ b/util/sst_file_manager_impl.h @@ -5,6 +5,8 @@ #pragma once +#ifndef ROCKSDB_LITE + #include #include "port/port.h" @@ -93,3 +95,5 @@ class SstFileManagerImpl : public SstFileManager { }; } // namespace rocksdb + +#endif // ROCKSDB_LITE