提交 989e644e 编写于 作者: I Islam AbdelRahman 提交者: Facebook Github Bot

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
上级 1beef656
...@@ -1086,6 +1086,7 @@ Status CompactionJob::FinishCompactionOutputFile( ...@@ -1086,6 +1086,7 @@ Status CompactionJob::FinishCompactionOutputFile(
event_logger_, cfd->ioptions()->listeners, dbname_, cfd->GetName(), fname, event_logger_, cfd->ioptions()->listeners, dbname_, cfd->GetName(), fname,
job_id_, meta->fd, tp, TableFileCreationReason::kCompaction, s); job_id_, meta->fd, tp, TableFileCreationReason::kCompaction, s);
#ifndef ROCKSDB_LITE
// Report new file to SstFileManagerImpl // Report new file to SstFileManagerImpl
auto sfm = auto sfm =
static_cast<SstFileManagerImpl*>(db_options_.sst_file_manager.get()); static_cast<SstFileManagerImpl*>(db_options_.sst_file_manager.get());
...@@ -1103,6 +1104,7 @@ Status CompactionJob::FinishCompactionOutputFile( ...@@ -1103,6 +1104,7 @@ Status CompactionJob::FinishCompactionOutputFile(
} }
} }
} }
#endif
sub_compact->builder.reset(); sub_compact->builder.reset();
sub_compact->current_output_file_size = 0; sub_compact->current_output_file_size = 0;
......
...@@ -1928,7 +1928,6 @@ Status DBImpl::FlushMemTableToOutputFile( ...@@ -1928,7 +1928,6 @@ Status DBImpl::FlushMemTableToOutputFile(
// may temporarily unlock and lock the mutex. // may temporarily unlock and lock the mutex.
NotifyOnFlushCompleted(cfd, &file_meta, mutable_cf_options, NotifyOnFlushCompleted(cfd, &file_meta, mutable_cf_options,
job_context->job_id, flush_job.GetTableProperties()); job_context->job_id, flush_job.GetTableProperties());
#endif // ROCKSDB_LITE
auto sfm = static_cast<SstFileManagerImpl*>( auto sfm = static_cast<SstFileManagerImpl*>(
immutable_db_options_.sst_file_manager.get()); immutable_db_options_.sst_file_manager.get());
if (sfm) { if (sfm) {
...@@ -1942,6 +1941,7 @@ Status DBImpl::FlushMemTableToOutputFile( ...@@ -1942,6 +1941,7 @@ Status DBImpl::FlushMemTableToOutputFile(
"DBImpl::FlushMemTableToOutputFile:MaxAllowedSpaceReached"); "DBImpl::FlushMemTableToOutputFile:MaxAllowedSpaceReached");
} }
} }
#endif // ROCKSDB_LITE
} }
return s; return s;
} }
...@@ -6054,6 +6054,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname, ...@@ -6054,6 +6054,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
} }
impl->mutex_.Unlock(); impl->mutex_.Unlock();
#ifndef ROCKSDB_LITE
auto sfm = static_cast<SstFileManagerImpl*>( auto sfm = static_cast<SstFileManagerImpl*>(
impl->immutable_db_options_.sst_file_manager.get()); impl->immutable_db_options_.sst_file_manager.get());
if (s.ok() && sfm) { if (s.ok() && sfm) {
...@@ -6072,6 +6073,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname, ...@@ -6072,6 +6073,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
} }
} }
} }
#endif // !ROCKSDB_LITE
if (s.ok()) { if (s.ok()) {
Log(InfoLogLevel::INFO_LEVEL, impl->immutable_db_options_.info_log, Log(InfoLogLevel::INFO_LEVEL, impl->immutable_db_options_.info_log,
......
...@@ -221,8 +221,6 @@ TEST_F(DBSSTTest, DeleteObsoleteFilesPendingOutputs) { ...@@ -221,8 +221,6 @@ TEST_F(DBSSTTest, DeleteObsoleteFilesPendingOutputs) {
listener->VerifyMatchedCount(1); listener->VerifyMatchedCount(1);
} }
#endif // ROCKSDB_LITE
TEST_F(DBSSTTest, DBWithSstFileManager) { TEST_F(DBSSTTest, DBWithSstFileManager) {
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_)); std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_));
auto sfm = static_cast<SstFileManagerImpl*>(sst_file_manager.get()); auto sfm = static_cast<SstFileManagerImpl*>(sst_file_manager.get());
...@@ -287,7 +285,6 @@ TEST_F(DBSSTTest, DBWithSstFileManager) { ...@@ -287,7 +285,6 @@ TEST_F(DBSSTTest, DBWithSstFileManager) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
#ifndef ROCKSDB_LITE
TEST_F(DBSSTTest, RateLimitedDelete) { TEST_F(DBSSTTest, RateLimitedDelete) {
Destroy(last_options_); Destroy(last_options_);
rocksdb::SyncPoint::GetInstance()->LoadDependency({ rocksdb::SyncPoint::GetInstance()->LoadDependency({
...@@ -482,7 +479,6 @@ TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) { ...@@ -482,7 +479,6 @@ TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) {
// We have deleted the 4 sst files in the delete_scheduler // We have deleted the 4 sst files in the delete_scheduler
ASSERT_EQ(bg_delete_file, 4); ASSERT_EQ(bg_delete_file, 4);
} }
#endif // ROCKSDB_LITE
TEST_F(DBSSTTest, DBWithMaxSpaceAllowed) { TEST_F(DBSSTTest, DBWithMaxSpaceAllowed) {
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_)); std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_));
...@@ -580,7 +576,6 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) { ...@@ -580,7 +576,6 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
ASSERT_GT(reached_max_space_on_compaction, 0); ASSERT_GT(reached_max_space_on_compaction, 0);
} }
#ifndef ROCKSDB_LITE
TEST_F(DBSSTTest, OpenDBWithInfiniteMaxOpenFiles) { TEST_F(DBSSTTest, OpenDBWithInfiniteMaxOpenFiles) {
// Open DB with infinite max open files // Open DB with infinite max open files
// - First iteration use 1 thread to open files // - First iteration use 1 thread to open files
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
// LICENSE file in the root directory of this source tree. An additional grant // 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. // of patent rights can be found in the PATENTS file in the same directory.
#ifndef ROCKSDB_LITE
#include "util/delete_scheduler.h" #include "util/delete_scheduler.h"
#include <thread> #include <thread>
...@@ -211,3 +213,5 @@ void DeleteScheduler::WaitForEmptyTrash() { ...@@ -211,3 +213,5 @@ void DeleteScheduler::WaitForEmptyTrash() {
} }
} // namespace rocksdb } // namespace rocksdb
#endif // ROCKSDB_LITE
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#pragma once #pragma once
#ifndef ROCKSDB_LITE
#include <map> #include <map>
#include <queue> #include <queue>
#include <string> #include <string>
...@@ -88,3 +90,5 @@ class DeleteScheduler { ...@@ -88,3 +90,5 @@ class DeleteScheduler {
}; };
} // namespace rocksdb } // namespace rocksdb
#endif // ROCKSDB_LITE
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "util/testharness.h" #include "util/testharness.h"
#include "util/testutil.h" #include "util/testutil.h"
#ifndef ROCKSDB_LITE
namespace rocksdb { namespace rocksdb {
class DeleteSchedulerTest : public testing::Test { class DeleteSchedulerTest : public testing::Test {
...@@ -426,3 +428,10 @@ int main(int argc, char** argv) { ...@@ -426,3 +428,10 @@ int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); 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
...@@ -84,6 +84,7 @@ Status CreateFile(Env* env, const std::string& destination, ...@@ -84,6 +84,7 @@ Status CreateFile(Env* env, const std::string& destination,
Status DeleteSSTFile(const ImmutableDBOptions* db_options, Status DeleteSSTFile(const ImmutableDBOptions* db_options,
const std::string& fname, uint32_t path_id) { const std::string& fname, uint32_t path_id) {
// TODO(tec): support sst_file_manager for multiple path_ids // TODO(tec): support sst_file_manager for multiple path_ids
#ifndef ROCKSDB_LITE
auto sfm = auto sfm =
static_cast<SstFileManagerImpl*>(db_options->sst_file_manager.get()); static_cast<SstFileManagerImpl*>(db_options->sst_file_manager.get());
if (sfm && path_id == 0) { if (sfm && path_id == 0) {
...@@ -91,6 +92,10 @@ Status DeleteSSTFile(const ImmutableDBOptions* db_options, ...@@ -91,6 +92,10 @@ Status DeleteSSTFile(const ImmutableDBOptions* db_options,
} else { } else {
return db_options->env->DeleteFile(fname); return db_options->env->DeleteFile(fname);
} }
#else
// SstFileManager is not supported in ROCKSDB_LITE
return db_options->env->DeleteFile(fname);
#endif
} }
} // namespace rocksdb } // namespace rocksdb
...@@ -9,11 +9,13 @@ ...@@ -9,11 +9,13 @@
#include "port/port.h" #include "port/port.h"
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "rocksdb/sst_file_manager.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
#include "util/sync_point.h" #include "util/sync_point.h"
namespace rocksdb { namespace rocksdb {
#ifndef ROCKSDB_LITE
SstFileManagerImpl::SstFileManagerImpl(Env* env, std::shared_ptr<Logger> logger, SstFileManagerImpl::SstFileManagerImpl(Env* env, std::shared_ptr<Logger> logger,
const std::string& trash_dir, const std::string& trash_dir,
int64_t rate_bytes_per_sec) int64_t rate_bytes_per_sec)
...@@ -154,4 +156,20 @@ SstFileManager* NewSstFileManager(Env* env, std::shared_ptr<Logger> info_log, ...@@ -154,4 +156,20 @@ SstFileManager* NewSstFileManager(Env* env, std::shared_ptr<Logger> info_log,
return res; return res;
} }
#else
SstFileManager* NewSstFileManager(Env* env, std::shared_ptr<Logger> 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 } // namespace rocksdb
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#pragma once #pragma once
#ifndef ROCKSDB_LITE
#include <string> #include <string>
#include "port/port.h" #include "port/port.h"
...@@ -93,3 +95,5 @@ class SstFileManagerImpl : public SstFileManager { ...@@ -93,3 +95,5 @@ class SstFileManagerImpl : public SstFileManager {
}; };
} // namespace rocksdb } // namespace rocksdb
#endif // ROCKSDB_LITE
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册