Block ReadOnlyDB in ROCKSDB_LITE

Summary:
db_imp_readonly.o is one of the big obj file.  If it's not a necessary
feature, we should probably block it in ROCKSDB_LITE.

    1322704 Nov 24 16:55 db/db_impl_readonly.o

Test Plan:
make shared_lib -j32
make ROCKSDB_LITE shared_lib -j32

Reviewers: ljin, igor

Reviewed By: igor

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D29583
main
Yueh-Hsuan Chiang 10 years ago
parent e47f0fa9ed
commit 73d72ed5c7
  1. 20
      db/db_impl_readonly.cc
  2. 5
      db/db_impl_readonly.h
  3. 6
      include/rocksdb/db.h

@ -3,6 +3,7 @@
// 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.
#include "db/db_impl_readonly.h" #include "db/db_impl_readonly.h"
#include "utilities/compacted_db/compacted_db_impl.h" #include "utilities/compacted_db/compacted_db_impl.h"
#include "db/db_impl.h" #include "db/db_impl.h"
@ -13,6 +14,8 @@
namespace rocksdb { namespace rocksdb {
#ifndef ROCKSDB_LITE
DBImplReadOnly::DBImplReadOnly(const DBOptions& db_options, DBImplReadOnly::DBImplReadOnly(const DBOptions& db_options,
const std::string& dbname) const std::string& dbname)
: DBImpl(db_options, dbname) { : DBImpl(db_options, dbname) {
@ -97,12 +100,10 @@ Status DB::OpenForReadOnly(const Options& options, const std::string& dbname,
// Try to first open DB as fully compacted DB // Try to first open DB as fully compacted DB
Status s; Status s;
#ifndef ROCKSDB_LITE
s = CompactedDBImpl::Open(options, dbname, dbptr); s = CompactedDBImpl::Open(options, dbname, dbptr);
if (s.ok()) { if (s.ok()) {
return s; return s;
} }
#endif
DBOptions db_options(options); DBOptions db_options(options);
ColumnFamilyOptions cf_options(options); ColumnFamilyOptions cf_options(options);
@ -167,5 +168,20 @@ Status DB::OpenForReadOnly(
return s; return s;
} }
#else // !ROCKSDB_LITE
Status DB::OpenForReadOnly(const Options& options, const std::string& dbname,
DB** dbptr, bool error_if_log_file_exist) {
return Status::NotSupported("Not supported in ROCKSDB_LITE.");
}
Status DB::OpenForReadOnly(
const DBOptions& db_options, const std::string& dbname,
const std::vector<ColumnFamilyDescriptor>& column_families,
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr,
bool error_if_log_file_exist) {
return Status::NotSupported("Not supported in ROCKSDB_LITE.");
}
#endif // !ROCKSDB_LITE
} // namespace rocksdb } // namespace rocksdb

@ -4,6 +4,9 @@
// 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.
#pragma once #pragma once
#ifndef ROCKSDB_LITE
#include "db/db_impl.h" #include "db/db_impl.h"
#include <vector> #include <vector>
#include <string> #include <string>
@ -100,3 +103,5 @@ class DBImplReadOnly : public DBImpl {
void operator=(const DBImplReadOnly&); void operator=(const DBImplReadOnly&);
}; };
} }
#endif // !ROCKSDB_LITE

@ -101,6 +101,9 @@ class DB {
// that modify data, like put/delete, will return error. // that modify data, like put/delete, will return error.
// If the db is opened in read only mode, then no compactions // If the db is opened in read only mode, then no compactions
// will happen. // will happen.
//
// Not supported in ROCKSDB_LITE, in which case the function will
// return Status::NotSupported.
static Status OpenForReadOnly(const Options& options, static Status OpenForReadOnly(const Options& options,
const std::string& name, DB** dbptr, const std::string& name, DB** dbptr,
bool error_if_log_file_exist = false); bool error_if_log_file_exist = false);
@ -110,6 +113,9 @@ class DB {
// database that should be opened. However, you always need to specify default // database that should be opened. However, you always need to specify default
// column family. The default column family name is 'default' and it's stored // column family. The default column family name is 'default' and it's stored
// in rocksdb::kDefaultColumnFamilyName // in rocksdb::kDefaultColumnFamilyName
//
// Not supported in ROCKSDB_LITE, in which case the function will
// return Status::NotSupported.
static Status OpenForReadOnly( static Status OpenForReadOnly(
const DBOptions& db_options, const std::string& name, const DBOptions& db_options, const std::string& name,
const std::vector<ColumnFamilyDescriptor>& column_families, const std::vector<ColumnFamilyDescriptor>& column_families,

Loading…
Cancel
Save