Change namespace from leveldb to rocksdb

Summary:
Change namespace from leveldb to rocksdb. This allows a single
application to link in open-source leveldb code as well as
rocksdb code into the same process.

Test Plan: compile rocksdb

Reviewers: emayanke

Reviewed By: emayanke

CC: leveldb

Differential Revision: https://reviews.facebook.net/D13287
main
Dhruba Borthakur 11 years ago
parent b3ed08129b
commit a143ef9b38
  1. 4
      db/builder.cc
  2. 4
      db/builder.h
  3. 44
      db/c.cc
  4. 8
      db/corruption_test.cc
  5. 86
      db/db_bench.cc
  6. 2
      db/db_filesnapshot.cc
  7. 4
      db/db_impl.cc
  8. 4
      db/db_impl.h
  9. 2
      db/db_impl_readonly.cc
  10. 2
      db/db_impl_readonly.h
  11. 4
      db/db_iter.cc
  12. 4
      db/db_iter.h
  13. 4
      db/db_statistics.h
  14. 2
      db/db_stats_logger.cc
  15. 26
      db/db_test.cc
  16. 4
      db/dbformat.cc
  17. 4
      db/dbformat.h
  18. 6
      db/dbformat_test.cc
  19. 6
      db/deletefile_test.cc
  20. 4
      db/filename.cc
  21. 4
      db/filename.h
  22. 6
      db/filename_test.cc
  23. 4
      db/log_format.h
  24. 4
      db/log_reader.cc
  25. 4
      db/log_reader.h
  26. 6
      db/log_test.cc
  27. 4
      db/log_writer.cc
  28. 4
      db/log_writer.h
  29. 4
      db/memtable.cc
  30. 4
      db/memtable.h
  31. 4
      db/memtablelist.cc
  32. 4
      db/memtablelist.h
  33. 4
      db/merge_helper.cc
  34. 4
      db/merge_helper.h
  35. 4
      db/merge_operator.cc
  36. 2
      db/merge_test.cc
  37. 12
      db/perf_context_test.cc
  38. 4
      db/prefix_filter_iterator.h
  39. 4
      db/repair.cc
  40. 4
      db/skiplist.h
  41. 6
      db/skiplist_test.cc
  42. 4
      db/snapshot.h
  43. 4
      db/table_cache.cc
  44. 4
      db/table_cache.h
  45. 4
      db/transaction_log_impl.cc
  46. 4
      db/transaction_log_impl.h
  47. 4
      db/version_edit.cc
  48. 4
      db/version_edit.h
  49. 6
      db/version_edit_test.cc
  50. 4
      db/version_set.cc
  51. 4
      db/version_set.h
  52. 2
      db/version_set_reduce_num_levels.cc
  53. 6
      db/version_set_test.cc
  54. 4
      db/write_batch.cc
  55. 4
      db/write_batch_internal.h
  56. 6
      db/write_batch_test.cc
  57. 12
      doc/bench/db_bench_sqlite3.cc
  58. 10
      doc/bench/db_bench_tree_db.cc
  59. 104
      doc/index.html
  60. 6
      hdfs/env_hdfs.h
  61. 4
      helpers/memenv/memenv.cc
  62. 4
      helpers/memenv/memenv.h
  63. 6
      helpers/memenv/memenv_test.cc
  64. 6
      include/rocksdb/arena.h
  65. 6
      include/rocksdb/cache.h
  66. 6
      include/rocksdb/compaction_filter.h
  67. 6
      include/rocksdb/comparator.h
  68. 6
      include/rocksdb/db.h
  69. 6
      include/rocksdb/env.h
  70. 3
      include/rocksdb/filter_policy.h
  71. 6
      include/rocksdb/iterator.h
  72. 10
      include/rocksdb/ldb_tool.h
  73. 4
      include/rocksdb/memtablerep.h
  74. 6
      include/rocksdb/merge_operator.h
  75. 6
      include/rocksdb/options.h
  76. 3
      include/rocksdb/perf_context.h
  77. 9
      include/rocksdb/rocksdb_to_leveldb.h
  78. 6
      include/rocksdb/slice.h
  79. 4
      include/rocksdb/slice_transform.h
  80. 6
      include/rocksdb/statistics.h
  81. 6
      include/rocksdb/status.h
  82. 6
      include/rocksdb/table_builder.h
  83. 6
      include/rocksdb/transaction_log.h
  84. 7
      include/rocksdb/types.h
  85. 6
      include/rocksdb/universal_compaction.h
  86. 6
      include/rocksdb/write_batch.h
  87. 4
      include/utilities/stackable_db.h
  88. 4
      include/utilities/utility_db.h
  89. 6
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeCache.java
  90. 4
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeComparator.java
  91. 2
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeCompressionType.java
  92. 28
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeDB.java
  93. 10
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeIterator.java
  94. 2
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeLogger.java
  95. 16
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeOptions.java
  96. 6
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeRange.java
  97. 6
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeReadOptions.java
  98. 8
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeSlice.java
  99. 2
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeSnapshot.java
  100. 4
      java/leveldbjni/leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeStatus.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -14,7 +14,7 @@
#include "rocksdb/iterator.h" #include "rocksdb/iterator.h"
#include "util/stop_watch.h" #include "util/stop_watch.h"
namespace leveldb { namespace rocksdb {
Status BuildTable(const std::string& dbname, Status BuildTable(const std::string& dbname,
Env* env, Env* env,
@ -204,4 +204,4 @@ Status BuildTable(const std::string& dbname,
return s; return s;
} }
} // namespace leveldb } // namespace rocksdb

@ -9,7 +9,7 @@
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "rocksdb/types.h" #include "rocksdb/types.h"
namespace leveldb { namespace rocksdb {
struct Options; struct Options;
struct FileMetaData; struct FileMetaData;
@ -36,6 +36,6 @@ extern Status BuildTable(const std::string& dbname,
const SequenceNumber newest_snapshot, const SequenceNumber newest_snapshot,
const SequenceNumber earliest_seqno_in_memtable); const SequenceNumber earliest_seqno_in_memtable);
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_BUILDER_H_ #endif // STORAGE_LEVELDB_DB_BUILDER_H_

@ -16,28 +16,28 @@
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "rocksdb/write_batch.h" #include "rocksdb/write_batch.h"
using leveldb::Cache; using rocksdb::Cache;
using leveldb::Comparator; using rocksdb::Comparator;
using leveldb::CompressionType; using rocksdb::CompressionType;
using leveldb::DB; using rocksdb::DB;
using leveldb::Env; using rocksdb::Env;
using leveldb::FileLock; using rocksdb::FileLock;
using leveldb::FilterPolicy; using rocksdb::FilterPolicy;
using leveldb::Iterator; using rocksdb::Iterator;
using leveldb::Logger; using rocksdb::Logger;
using leveldb::NewBloomFilterPolicy; using rocksdb::NewBloomFilterPolicy;
using leveldb::NewLRUCache; using rocksdb::NewLRUCache;
using leveldb::Options; using rocksdb::Options;
using leveldb::RandomAccessFile; using rocksdb::RandomAccessFile;
using leveldb::Range; using rocksdb::Range;
using leveldb::ReadOptions; using rocksdb::ReadOptions;
using leveldb::SequentialFile; using rocksdb::SequentialFile;
using leveldb::Slice; using rocksdb::Slice;
using leveldb::Snapshot; using rocksdb::Snapshot;
using leveldb::Status; using rocksdb::Status;
using leveldb::WritableFile; using rocksdb::WritableFile;
using leveldb::WriteBatch; using rocksdb::WriteBatch;
using leveldb::WriteOptions; using rocksdb::WriteOptions;
using std::shared_ptr; using std::shared_ptr;

@ -20,7 +20,7 @@
#include "util/testharness.h" #include "util/testharness.h"
#include "util/testutil.h" #include "util/testutil.h"
namespace leveldb { namespace rocksdb {
static const int kValueSize = 1000; static const int kValueSize = 1000;
@ -68,7 +68,7 @@ class CorruptionTest {
void RepairDB() { void RepairDB() {
delete db_; delete db_;
db_ = nullptr; db_ = nullptr;
ASSERT_OK(::leveldb::RepairDB(dbname_, options_)); ASSERT_OK(::rocksdb::RepairDB(dbname_, options_));
} }
void Build(int n) { void Build(int n) {
@ -354,8 +354,8 @@ TEST(CorruptionTest, UnrelatedKeys) {
ASSERT_EQ(Value(1000, &tmp2).ToString(), v); ASSERT_EQ(Value(1000, &tmp2).ToString(), v);
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -153,7 +153,7 @@ static int FLAGS_min_write_buffer_number_to_merge = 0;
static int FLAGS_max_background_compactions = 0; static int FLAGS_max_background_compactions = 0;
// style of compaction: level-based vs universal // style of compaction: level-based vs universal
static leveldb::CompactionStyle FLAGS_compaction_style = leveldb::kCompactionStyleLevel; static rocksdb::CompactionStyle FLAGS_compaction_style = rocksdb::kCompactionStyleLevel;
// Percentage flexibility while comparing file size // Percentage flexibility while comparing file size
// (for universal compaction only). // (for universal compaction only).
@ -201,7 +201,7 @@ static bool FLAGS_verify_checksum = false;
// Database statistics // Database statistics
static bool FLAGS_statistics = false; static bool FLAGS_statistics = false;
static class std::shared_ptr<leveldb::Statistics> dbstats; static class std::shared_ptr<rocksdb::Statistics> dbstats;
// Number of write operations to do. If negative, do FLAGS_num reads. // Number of write operations to do. If negative, do FLAGS_num reads.
static long FLAGS_writes = -1; static long FLAGS_writes = -1;
@ -279,8 +279,8 @@ static int FLAGS_disable_seek_compaction = false;
static uint64_t FLAGS_delete_obsolete_files_period_micros = 0; static uint64_t FLAGS_delete_obsolete_files_period_micros = 0;
// Algorithm used to compress the database // Algorithm used to compress the database
static enum leveldb::CompressionType FLAGS_compression_type = static enum rocksdb::CompressionType FLAGS_compression_type =
leveldb::kSnappyCompression; rocksdb::kSnappyCompression;
// If non-negative, compression starts from this level. Levels with number // If non-negative, compression starts from this level. Levels with number
// < FLAGS_min_level_to_compress are not compressed. // < FLAGS_min_level_to_compress are not compressed.
@ -290,7 +290,7 @@ static int FLAGS_min_level_to_compress = -1;
static int FLAGS_table_cache_numshardbits = 4; static int FLAGS_table_cache_numshardbits = 4;
// posix or hdfs environment // posix or hdfs environment
static leveldb::Env* FLAGS_env = leveldb::Env::Default(); static rocksdb::Env* FLAGS_env = rocksdb::Env::Default();
// Stats are reported every N operations when this is greater // Stats are reported every N operations when this is greater
// than zero. When 0 the interval grows over time. // than zero. When 0 the interval grows over time.
@ -339,11 +339,11 @@ static bool FLAGS_use_mmap_writes;
// Advise random access on table file open // Advise random access on table file open
static bool FLAGS_advise_random_on_open = static bool FLAGS_advise_random_on_open =
leveldb::Options().advise_random_on_open; rocksdb::Options().advise_random_on_open;
// Access pattern advice when a file is compacted // Access pattern advice when a file is compacted
static auto FLAGS_compaction_fadvice = static auto FLAGS_compaction_fadvice =
leveldb::Options().access_hint_on_compaction_start; rocksdb::Options().access_hint_on_compaction_start;
// Use multiget to access a series of keys instead of get // Use multiget to access a series of keys instead of get
static bool FLAGS_use_multiget = false; static bool FLAGS_use_multiget = false;
@ -358,13 +358,13 @@ static bool FLAGS_warn_missing_keys = true;
// Use adaptive mutex // Use adaptive mutex
static auto FLAGS_use_adaptive_mutex = static auto FLAGS_use_adaptive_mutex =
leveldb::Options().use_adaptive_mutex; rocksdb::Options().use_adaptive_mutex;
// Allows OS to incrementally sync files to disk while they are being // Allows OS to incrementally sync files to disk while they are being
// written, in the background. Issue one request for every bytes_per_sync // written, in the background. Issue one request for every bytes_per_sync
// written. 0 turns it off. // written. 0 turns it off.
static auto FLAGS_bytes_per_sync = static auto FLAGS_bytes_per_sync =
leveldb::Options().bytes_per_sync; rocksdb::Options().bytes_per_sync;
// On true, deletes use bloom-filter and drop the delete if key not present // On true, deletes use bloom-filter and drop the delete if key not present
static bool FLAGS_filter_deletes = false; static bool FLAGS_filter_deletes = false;
@ -387,9 +387,9 @@ static enum RepFactory FLAGS_rep_factory;
static std::string FLAGS_merge_operator = ""; static std::string FLAGS_merge_operator = "";
static auto FLAGS_purge_log_after_memtable_flush = static auto FLAGS_purge_log_after_memtable_flush =
leveldb::Options().purge_log_after_memtable_flush; rocksdb::Options().purge_log_after_memtable_flush;
namespace leveldb { namespace rocksdb {
// Helper for quickly generating random data. // Helper for quickly generating random data.
class RandomGenerator { class RandomGenerator {
@ -691,16 +691,16 @@ class Benchmark {
fprintf(stdout, "Write rate limit: %d\n", FLAGS_writes_per_second); fprintf(stdout, "Write rate limit: %d\n", FLAGS_writes_per_second);
switch (FLAGS_compression_type) { switch (FLAGS_compression_type) {
case leveldb::kNoCompression: case rocksdb::kNoCompression:
fprintf(stdout, "Compression: none\n"); fprintf(stdout, "Compression: none\n");
break; break;
case leveldb::kSnappyCompression: case rocksdb::kSnappyCompression:
fprintf(stdout, "Compression: snappy\n"); fprintf(stdout, "Compression: snappy\n");
break; break;
case leveldb::kZlibCompression: case rocksdb::kZlibCompression:
fprintf(stdout, "Compression: zlib\n"); fprintf(stdout, "Compression: zlib\n");
break; break;
case leveldb::kBZip2Compression: case rocksdb::kBZip2Compression:
fprintf(stdout, "Compression: bzip2\n"); fprintf(stdout, "Compression: bzip2\n");
break; break;
} }
@ -735,7 +735,7 @@ class Benchmark {
"WARNING: Assertions are enabled; benchmarks unnecessarily slow\n"); "WARNING: Assertions are enabled; benchmarks unnecessarily slow\n");
#endif #endif
if (FLAGS_compression_type != leveldb::kNoCompression) { if (FLAGS_compression_type != rocksdb::kNoCompression) {
// The test string should not be too small. // The test string should not be too small.
const int len = FLAGS_block_size; const int len = FLAGS_block_size;
char* text = (char*) malloc(len+1); char* text = (char*) malloc(len+1);
@ -2303,24 +2303,24 @@ class Benchmark {
} }
}; };
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
leveldb::InstallStackTraceHandler(); rocksdb::InstallStackTraceHandler();
FLAGS_write_buffer_size = leveldb::Options().write_buffer_size; FLAGS_write_buffer_size = rocksdb::Options().write_buffer_size;
FLAGS_max_write_buffer_number = leveldb::Options().max_write_buffer_number; FLAGS_max_write_buffer_number = rocksdb::Options().max_write_buffer_number;
FLAGS_min_write_buffer_number_to_merge = FLAGS_min_write_buffer_number_to_merge =
leveldb::Options().min_write_buffer_number_to_merge; rocksdb::Options().min_write_buffer_number_to_merge;
FLAGS_open_files = leveldb::Options().max_open_files; FLAGS_open_files = rocksdb::Options().max_open_files;
FLAGS_max_background_compactions = FLAGS_max_background_compactions =
leveldb::Options().max_background_compactions; rocksdb::Options().max_background_compactions;
FLAGS_compaction_style = leveldb::Options().compaction_style; FLAGS_compaction_style = rocksdb::Options().compaction_style;
// Compression test code above refers to FLAGS_block_size // Compression test code above refers to FLAGS_block_size
FLAGS_block_size = leveldb::Options().block_size; FLAGS_block_size = rocksdb::Options().block_size;
FLAGS_use_os_buffer = leveldb::EnvOptions().use_os_buffer; FLAGS_use_os_buffer = rocksdb::EnvOptions().use_os_buffer;
FLAGS_use_mmap_reads = leveldb::EnvOptions().use_mmap_reads; FLAGS_use_mmap_reads = rocksdb::EnvOptions().use_mmap_reads;
FLAGS_use_mmap_writes = leveldb::EnvOptions().use_mmap_writes; FLAGS_use_mmap_writes = rocksdb::EnvOptions().use_mmap_writes;
std::string default_db_path; std::string default_db_path;
@ -2333,7 +2333,7 @@ int main(int argc, char** argv) {
char buf[2048]; char buf[2048];
char str[512]; char str[512];
if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) { if (rocksdb::Slice(argv[i]).starts_with("--benchmarks=")) {
FLAGS_benchmarks = argv[i] + strlen("--benchmarks="); FLAGS_benchmarks = argv[i] + strlen("--benchmarks=");
} else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) { } else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) {
FLAGS_compression_ratio = d; FLAGS_compression_ratio = d;
@ -2384,7 +2384,7 @@ int main(int argc, char** argv) {
== 1) { == 1) {
FLAGS_max_background_compactions = n; FLAGS_max_background_compactions = n;
} else if (sscanf(argv[i], "--compaction_style=%d%c", &n, &junk) == 1) { } else if (sscanf(argv[i], "--compaction_style=%d%c", &n, &junk) == 1) {
FLAGS_compaction_style = (leveldb::CompactionStyle)n; FLAGS_compaction_style = (rocksdb::CompactionStyle)n;
} else if (sscanf(argv[i], "--cache_size=%ld%c", &l, &junk) == 1) { } else if (sscanf(argv[i], "--cache_size=%ld%c", &l, &junk) == 1) {
FLAGS_cache_size = l; FLAGS_cache_size = l;
} else if (sscanf(argv[i], "--block_size=%d%c", &n, &junk) == 1) { } else if (sscanf(argv[i], "--block_size=%d%c", &n, &junk) == 1) {
@ -2424,7 +2424,7 @@ int main(int argc, char** argv) {
} else if (sscanf(argv[i], "--statistics=%d%c", &n, &junk) == 1 && } else if (sscanf(argv[i], "--statistics=%d%c", &n, &junk) == 1 &&
(n == 0 || n == 1)) { (n == 0 || n == 1)) {
if (n == 1) { if (n == 1) {
dbstats = leveldb::CreateDBStatistics(); dbstats = rocksdb::CreateDBStatistics();
FLAGS_statistics = true; FLAGS_statistics = true;
} }
} else if (sscanf(argv[i], "--writes=%lld%c", &ll, &junk) == 1) { } else if (sscanf(argv[i], "--writes=%lld%c", &ll, &junk) == 1) {
@ -2456,7 +2456,7 @@ int main(int argc, char** argv) {
(n == 0 || n == 1)) { (n == 0 || n == 1)) {
FLAGS_get_approx = n; FLAGS_get_approx = n;
} else if (sscanf(argv[i], "--hdfs=%s", buf) == 1) { } else if (sscanf(argv[i], "--hdfs=%s", buf) == 1) {
FLAGS_env = new leveldb::HdfsEnv(buf); FLAGS_env = new rocksdb::HdfsEnv(buf);
} else if (sscanf(argv[i], "--num_levels=%d%c", } else if (sscanf(argv[i], "--num_levels=%d%c",
&n, &junk) == 1) { &n, &junk) == 1) {
FLAGS_num_levels = n; FLAGS_num_levels = n;
@ -2478,7 +2478,7 @@ int main(int argc, char** argv) {
} else if (sscanf(argv[i], } else if (sscanf(argv[i],
"--max_bytes_for_level_multiplier_additional=%s%c", "--max_bytes_for_level_multiplier_additional=%s%c",
str, &junk) == 1) { str, &junk) == 1) {
std::vector<std::string> fanout = leveldb::stringSplit(str, ','); std::vector<std::string> fanout = rocksdb::stringSplit(str, ',');
for (unsigned int j= 0; j < fanout.size(); j++) { for (unsigned int j= 0; j < fanout.size(); j++) {
FLAGS_max_bytes_for_level_multiplier_additional.push_back( FLAGS_max_bytes_for_level_multiplier_additional.push_back(
std::stoi(fanout[j])); std::stoi(fanout[j]));
@ -2492,13 +2492,13 @@ int main(int argc, char** argv) {
} else if (strncmp(argv[i], "--compression_type=", 19) == 0) { } else if (strncmp(argv[i], "--compression_type=", 19) == 0) {
const char* ctype = argv[i] + 19; const char* ctype = argv[i] + 19;
if (!strcasecmp(ctype, "none")) if (!strcasecmp(ctype, "none"))
FLAGS_compression_type = leveldb::kNoCompression; FLAGS_compression_type = rocksdb::kNoCompression;
else if (!strcasecmp(ctype, "snappy")) else if (!strcasecmp(ctype, "snappy"))
FLAGS_compression_type = leveldb::kSnappyCompression; FLAGS_compression_type = rocksdb::kSnappyCompression;
else if (!strcasecmp(ctype, "zlib")) else if (!strcasecmp(ctype, "zlib"))
FLAGS_compression_type = leveldb::kZlibCompression; FLAGS_compression_type = rocksdb::kZlibCompression;
else if (!strcasecmp(ctype, "bzip2")) else if (!strcasecmp(ctype, "bzip2"))
FLAGS_compression_type = leveldb::kBZip2Compression; FLAGS_compression_type = rocksdb::kBZip2Compression;
else { else {
fprintf(stdout, "Cannot parse %s\n", argv[i]); fprintf(stdout, "Cannot parse %s\n", argv[i]);
} }
@ -2561,13 +2561,13 @@ int main(int argc, char** argv) {
FLAGS_advise_random_on_open = n; FLAGS_advise_random_on_open = n;
} else if (sscanf(argv[i], "--compaction_fadvice=%s", buf) == 1) { } else if (sscanf(argv[i], "--compaction_fadvice=%s", buf) == 1) {
if (!strcasecmp(buf, "NONE")) if (!strcasecmp(buf, "NONE"))
FLAGS_compaction_fadvice = leveldb::Options::NONE; FLAGS_compaction_fadvice = rocksdb::Options::NONE;
else if (!strcasecmp(buf, "NORMAL")) else if (!strcasecmp(buf, "NORMAL"))
FLAGS_compaction_fadvice = leveldb::Options::NORMAL; FLAGS_compaction_fadvice = rocksdb::Options::NORMAL;
else if (!strcasecmp(buf, "SEQUENTIAL")) else if (!strcasecmp(buf, "SEQUENTIAL"))
FLAGS_compaction_fadvice = leveldb::Options::SEQUENTIAL; FLAGS_compaction_fadvice = rocksdb::Options::SEQUENTIAL;
else if (!strcasecmp(buf, "WILLNEED")) else if (!strcasecmp(buf, "WILLNEED"))
FLAGS_compaction_fadvice = leveldb::Options::WILLNEED; FLAGS_compaction_fadvice = rocksdb::Options::WILLNEED;
else { else {
fprintf(stdout, "Unknown compaction fadvice:%s\n", buf); fprintf(stdout, "Unknown compaction fadvice:%s\n", buf);
} }
@ -2615,12 +2615,12 @@ int main(int argc, char** argv) {
// Choose a location for the test database if none given with --db=<path> // Choose a location for the test database if none given with --db=<path>
if (FLAGS_db == nullptr) { if (FLAGS_db == nullptr) {
leveldb::Env::Default()->GetTestDirectory(&default_db_path); rocksdb::Env::Default()->GetTestDirectory(&default_db_path);
default_db_path += "/dbbench"; default_db_path += "/dbbench";
FLAGS_db = default_db_path.c_str(); FLAGS_db = default_db_path.c_str();
} }
leveldb::Benchmark benchmark; rocksdb::Benchmark benchmark;
benchmark.Run(); benchmark.Run();
return 0; return 0;
} }

@ -13,7 +13,7 @@
#include "port/port.h" #include "port/port.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace leveldb { namespace rocksdb {
Status DBImpl::DisableFileDeletions() { Status DBImpl::DisableFileDeletions() {
MutexLock l(&mutex_); MutexLock l(&mutex_);

@ -47,7 +47,7 @@
#include "util/mutexlock.h" #include "util/mutexlock.h"
#include "util/stop_watch.h" #include "util/stop_watch.h"
namespace leveldb { namespace rocksdb {
void dumpLeveldbBuildVersion(Logger * log); void dumpLeveldbBuildVersion(Logger * log);
@ -3294,4 +3294,4 @@ void dumpLeveldbBuildVersion(Logger * log) {
leveldb_build_compile_time, leveldb_build_compile_date); leveldb_build_compile_time, leveldb_build_compile_date);
} }
} // namespace leveldb } // namespace rocksdb

@ -24,7 +24,7 @@
#include "scribe/scribe_logger.h" #include "scribe/scribe_logger.h"
#endif #endif
namespace leveldb { namespace rocksdb {
class MemTable; class MemTable;
class TableCache; class TableCache;
@ -444,6 +444,6 @@ extern Options SanitizeOptions(const std::string& db,
const InternalFilterPolicy* ipolicy, const InternalFilterPolicy* ipolicy,
const Options& src); const Options& src);
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_DB_IMPL_H_ #endif // STORAGE_LEVELDB_DB_DB_IMPL_H_

@ -34,7 +34,7 @@
#include "util/logging.h" #include "util/logging.h"
#include "util/build_version.h" #include "util/build_version.h"
namespace leveldb { namespace rocksdb {
DBImplReadOnly::DBImplReadOnly(const Options& options, DBImplReadOnly::DBImplReadOnly(const Options& options,
const std::string& dbname) const std::string& dbname)

@ -21,7 +21,7 @@
#include "scribe/scribe_logger.h" #include "scribe/scribe_logger.h"
#endif #endif
namespace leveldb { namespace rocksdb {
class DBImplReadOnly : public DBImpl { class DBImplReadOnly : public DBImpl {
public: public:

@ -17,7 +17,7 @@
#include "util/mutexlock.h" #include "util/mutexlock.h"
#include "util/perf_context_imp.h" #include "util/perf_context_imp.h"
namespace leveldb { namespace rocksdb {
#if 0 #if 0
static void DumpInternalIter(Iterator* iter) { static void DumpInternalIter(Iterator* iter) {
@ -471,4 +471,4 @@ Iterator* NewDBIterator(
internal_iter, sequence); internal_iter, sequence);
} }
} // namespace leveldb } // namespace rocksdb

@ -9,7 +9,7 @@
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "db/dbformat.h" #include "db/dbformat.h"
namespace leveldb { namespace rocksdb {
// Return a new iterator that converts internal keys (yielded by // Return a new iterator that converts internal keys (yielded by
// "*internal_iter") that were live at the specified "sequence" number // "*internal_iter") that were live at the specified "sequence" number
@ -22,6 +22,6 @@ extern Iterator* NewDBIterator(
Iterator* internal_iter, Iterator* internal_iter,
const SequenceNumber& sequence); const SequenceNumber& sequence);
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_DB_ITER_H_ #endif // STORAGE_LEVELDB_DB_DB_ITER_H_

@ -16,7 +16,7 @@
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace leveldb { namespace rocksdb {
class DBStatistics: public Statistics { class DBStatistics: public Statistics {
public: public:
@ -59,6 +59,6 @@ std::shared_ptr<Statistics> CreateDBStatistics() {
return std::make_shared<DBStatistics>(); return std::make_shared<DBStatistics>();
} }
} // namespace leveldb } // namespace rocksdb
#endif // LEVELDB_STORAGE_DB_DB_STATISTICS_H_ #endif // LEVELDB_STORAGE_DB_DB_STATISTICS_H_

@ -12,7 +12,7 @@
#include "port/port.h" #include "port/port.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
namespace leveldb { namespace rocksdb {
void DBImpl::MaybeScheduleLogDBDeployStats() { void DBImpl::MaybeScheduleLogDBDeployStats() {

@ -23,7 +23,7 @@
#include "util/testutil.h" #include "util/testutil.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
namespace leveldb { namespace rocksdb {
static bool SnappyCompressionSupported(const CompressionOptions& options) { static bool SnappyCompressionSupported(const CompressionOptions& options) {
std::string out; std::string out;
@ -831,7 +831,7 @@ TEST(DBTest, KeyMayExist) {
std::string value; std::string value;
Options options = CurrentOptions(); Options options = CurrentOptions();
options.filter_policy = NewBloomFilterPolicy(20); options.filter_policy = NewBloomFilterPolicy(20);
options.statistics = leveldb::CreateDBStatistics(); options.statistics = rocksdb::CreateDBStatistics();
Reopen(&options); Reopen(&options);
ASSERT_TRUE(!db_->KeyMayExist(ropts, "a", &value)); ASSERT_TRUE(!db_->KeyMayExist(ropts, "a", &value));
@ -892,7 +892,7 @@ TEST(DBTest, NonBlockingIteration) {
do { do {
ReadOptions non_blocking_opts, regular_opts; ReadOptions non_blocking_opts, regular_opts;
Options options = CurrentOptions(); Options options = CurrentOptions();
options.statistics = leveldb::CreateDBStatistics(); options.statistics = rocksdb::CreateDBStatistics();
non_blocking_opts.read_tier = kBlockCacheTier; non_blocking_opts.read_tier = kBlockCacheTier;
Reopen(&options); Reopen(&options);
@ -1140,7 +1140,7 @@ TEST(DBTest, IterReseek) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.max_sequential_skip_in_iterations = 3; options.max_sequential_skip_in_iterations = 3;
options.create_if_missing = true; options.create_if_missing = true;
options.statistics = leveldb::CreateDBStatistics(); options.statistics = rocksdb::CreateDBStatistics();
DestroyAndReopen(&options); DestroyAndReopen(&options);
// insert two keys with same userkey and verify that // insert two keys with same userkey and verify that
@ -3858,7 +3858,7 @@ class ModelDB: public DB {
return -1; return -1;
} }
virtual Status Flush(const leveldb::FlushOptions& options) { virtual Status Flush(const rocksdb::FlushOptions& options) {
Status ret; Status ret;
return ret; return ret;
} }
@ -3885,8 +3885,8 @@ class ModelDB: public DB {
virtual SequenceNumber GetLatestSequenceNumber() { virtual SequenceNumber GetLatestSequenceNumber() {
return 0; return 0;
} }
virtual Status GetUpdatesSince(leveldb::SequenceNumber, virtual Status GetUpdatesSince(rocksdb::SequenceNumber,
unique_ptr<leveldb::TransactionLogIterator>*) { unique_ptr<rocksdb::TransactionLogIterator>*) {
return Status::NotSupported("Not supported in Model DB"); return Status::NotSupported("Not supported in Model DB");
} }
@ -4303,16 +4303,16 @@ void BM_LogAndApply(int iters, int num_base_files) {
buf, iters, us, ((float)us) / iters); buf, iters, us, ((float)us) / iters);
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
if (argc > 1 && std::string(argv[1]) == "--benchmark") { if (argc > 1 && std::string(argv[1]) == "--benchmark") {
leveldb::BM_LogAndApply(1000, 1); rocksdb::BM_LogAndApply(1000, 1);
leveldb::BM_LogAndApply(1000, 100); rocksdb::BM_LogAndApply(1000, 100);
leveldb::BM_LogAndApply(1000, 10000); rocksdb::BM_LogAndApply(1000, 10000);
leveldb::BM_LogAndApply(100, 100000); rocksdb::BM_LogAndApply(100, 100000);
return 0; return 0;
} }
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -8,7 +8,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/perf_context_imp.h" #include "util/perf_context_imp.h"
namespace leveldb { namespace rocksdb {
static uint64_t PackSequenceAndType(uint64_t seq, ValueType t) { static uint64_t PackSequenceAndType(uint64_t seq, ValueType t) {
assert(seq <= kMaxSequenceNumber); assert(seq <= kMaxSequenceNumber);
@ -139,4 +139,4 @@ LookupKey::LookupKey(const Slice& user_key, SequenceNumber s) {
end_ = dst; end_ = dst;
} }
} // namespace leveldb } // namespace rocksdb

@ -15,7 +15,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/logging.h" #include "util/logging.h"
namespace leveldb { namespace rocksdb {
class InternalKey; class InternalKey;
@ -223,6 +223,6 @@ inline LookupKey::~LookupKey() {
if (start_ != space_) delete[] start_; if (start_ != space_) delete[] start_;
} }
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_FORMAT_H_ #endif // STORAGE_LEVELDB_DB_FORMAT_H_

@ -6,7 +6,7 @@
#include "util/logging.h" #include "util/logging.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace leveldb { namespace rocksdb {
static std::string IKey(const std::string& user_key, static std::string IKey(const std::string& user_key,
uint64_t seq, uint64_t seq,
@ -105,8 +105,8 @@ TEST(FormatTest, InternalKeyShortestSuccessor) {
ShortSuccessor(IKey("\xff\xff", 100, kTypeValue))); ShortSuccessor(IKey("\xff\xff", 100, kTypeValue)));
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -16,7 +16,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <map> #include <map>
namespace leveldb { namespace rocksdb {
class DeleteFileTest { class DeleteFileTest {
public: public:
@ -180,9 +180,9 @@ TEST(DeleteFileTest, DeleteFileWithIterator) {
delete it; delete it;
CloseDB(); CloseDB();
} }
} //namespace leveldb } //namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -10,7 +10,7 @@
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "util/logging.h" #include "util/logging.h"
namespace leveldb { namespace rocksdb {
// Given a path, flatten the path name by replacing all chars not in // Given a path, flatten the path name by replacing all chars not in
// {[0-9,a-z,A-Z,-,_,.]} with _. And append '\0' at the end. // {[0-9,a-z,A-Z,-,_,.]} with _. And append '\0' at the end.
@ -218,4 +218,4 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
return s; return s;
} }
} // namespace leveldb } // namespace rocksdb

@ -13,7 +13,7 @@
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "port/port.h" #include "port/port.h"
namespace leveldb { namespace rocksdb {
class Env; class Env;
@ -92,6 +92,6 @@ extern Status SetCurrentFile(Env* env, const std::string& dbname,
uint64_t descriptor_number); uint64_t descriptor_number);
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_FILENAME_H_ #endif // STORAGE_LEVELDB_DB_FILENAME_H_

@ -9,7 +9,7 @@
#include "util/logging.h" #include "util/logging.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace leveldb { namespace rocksdb {
class FileNameTest { }; class FileNameTest { };
@ -128,8 +128,8 @@ TEST(FileNameTest, Construction) {
ASSERT_EQ(kMetaDatabase, type); ASSERT_EQ(kMetaDatabase, type);
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -8,7 +8,7 @@
#ifndef STORAGE_LEVELDB_DB_LOG_FORMAT_H_ #ifndef STORAGE_LEVELDB_DB_LOG_FORMAT_H_
#define STORAGE_LEVELDB_DB_LOG_FORMAT_H_ #define STORAGE_LEVELDB_DB_LOG_FORMAT_H_
namespace leveldb { namespace rocksdb {
namespace log { namespace log {
enum RecordType { enum RecordType {
@ -30,6 +30,6 @@ static const unsigned int kBlockSize = 32768;
static const int kHeaderSize = 4 + 1 + 2; static const int kHeaderSize = 4 + 1 + 2;
} // namespace log } // namespace log
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_LOG_FORMAT_H_ #endif // STORAGE_LEVELDB_DB_LOG_FORMAT_H_

@ -9,7 +9,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/crc32c.h" #include "util/crc32c.h"
namespace leveldb { namespace rocksdb {
namespace log { namespace log {
Reader::Reporter::~Reporter() { Reader::Reporter::~Reporter() {
@ -256,4 +256,4 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result) {
} }
} // namespace log } // namespace log
} // namespace leveldb } // namespace rocksdb

@ -12,7 +12,7 @@
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace leveldb { namespace rocksdb {
class SequentialFile; class SequentialFile;
using std::unique_ptr; using std::unique_ptr;
@ -118,6 +118,6 @@ class Reader {
}; };
} // namespace log } // namespace log
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_LOG_READER_H_ #endif // STORAGE_LEVELDB_DB_LOG_READER_H_

@ -10,7 +10,7 @@
#include "util/random.h" #include "util/random.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace leveldb { namespace rocksdb {
namespace log { namespace log {
// Construct a string of the specified length made out of the supplied // Construct a string of the specified length made out of the supplied
@ -516,8 +516,8 @@ TEST(LogTest, ReadPastEnd) {
} }
} // namespace log } // namespace log
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -9,7 +9,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/crc32c.h" #include "util/crc32c.h"
namespace leveldb { namespace rocksdb {
namespace log { namespace log {
Writer::Writer(unique_ptr<WritableFile>&& dest) Writer::Writer(unique_ptr<WritableFile>&& dest)
@ -100,4 +100,4 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) {
} }
} // namespace log } // namespace log
} // namespace leveldb } // namespace rocksdb

@ -11,7 +11,7 @@
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace leveldb { namespace rocksdb {
class WritableFile; class WritableFile;
@ -49,6 +49,6 @@ class Writer {
}; };
} // namespace log } // namespace log
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_ #endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_

@ -14,7 +14,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/murmurhash.h" #include "util/murmurhash.h"
namespace leveldb { namespace rocksdb {
MemTable::MemTable(const InternalKeyComparator& cmp, MemTable::MemTable(const InternalKeyComparator& cmp,
std::shared_ptr<MemTableRepFactory> table_factory, std::shared_ptr<MemTableRepFactory> table_factory,
@ -238,4 +238,4 @@ bool MemTable::Get(const LookupKey& key, std::string* value, Status* s,
return false; return false;
} }
} // namespace leveldb } // namespace rocksdb

@ -15,7 +15,7 @@
#include "rocksdb/memtablerep.h" #include "rocksdb/memtablerep.h"
#include "util/arena_impl.h" #include "util/arena_impl.h"
namespace leveldb { namespace rocksdb {
class Mutex; class Mutex;
class MemTableIterator; class MemTableIterator;
@ -146,6 +146,6 @@ class MemTable {
void operator=(const MemTable&); void operator=(const MemTable&);
}; };
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_MEMTABLE_H_ #endif // STORAGE_LEVELDB_DB_MEMTABLE_H_

@ -10,7 +10,7 @@
#include "rocksdb/iterator.h" #include "rocksdb/iterator.h"
#include "util/coding.h" #include "util/coding.h"
namespace leveldb { namespace rocksdb {
class InternalKeyComparator; class InternalKeyComparator;
class Mutex; class Mutex;
@ -210,4 +210,4 @@ void MemTableList::GetMemTables(std::vector<MemTable*>* output) {
} }
} }
} // namespace leveldb } // namespace rocksdb

@ -11,7 +11,7 @@
#include "db/skiplist.h" #include "db/skiplist.h"
#include "memtable.h" #include "memtable.h"
namespace leveldb { namespace rocksdb {
class InternalKeyComparator; class InternalKeyComparator;
class Mutex; class Mutex;
@ -99,6 +99,6 @@ class MemTableList {
}; };
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_MEMTABLELIST_H_ #endif // STORAGE_LEVELDB_DB_MEMTABLELIST_H_

@ -6,7 +6,7 @@
#include <string> #include <string>
#include <stdio.h> #include <stdio.h>
namespace leveldb { namespace rocksdb {
// PRE: iter points to the first merge type entry // PRE: iter points to the first merge type entry
// POST: iter points to the first entry beyond the merge process (or the end) // POST: iter points to the first entry beyond the merge process (or the end)
@ -189,4 +189,4 @@ void MergeHelper::MergeUntil(Iterator* iter, SequenceNumber stop_before,
} }
} }
} // namespace leveldb } // namespace rocksdb

@ -7,7 +7,7 @@
#include <string> #include <string>
#include <deque> #include <deque>
namespace leveldb { namespace rocksdb {
class Comparator; class Comparator;
class Iterator; class Iterator;
@ -93,6 +93,6 @@ class MergeHelper {
bool success_; bool success_;
}; };
} // namespace leveldb } // namespace rocksdb
#endif #endif

@ -7,7 +7,7 @@
#include "rocksdb/merge_operator.h" #include "rocksdb/merge_operator.h"
namespace leveldb { namespace rocksdb {
// Given a "real" merge from the library, call the user's // Given a "real" merge from the library, call the user's
// associative merge function one-by-one on each of the operands. // associative merge function one-by-one on each of the operands.
@ -48,4 +48,4 @@ bool AssociativeMergeOperator::PartialMerge(
return Merge(key, &left_operand, right_operand, new_value, logger); return Merge(key, &left_operand, right_operand, new_value, logger);
} }
} // namespace leveldb } // namespace rocksdb

@ -14,7 +14,7 @@
#include "utilities/utility_db.h" #include "utilities/utility_db.h"
using namespace std; using namespace std;
using namespace leveldb; using namespace rocksdb;
std::shared_ptr<DB> OpenDb(const string& dbname, const bool ttl = false) { std::shared_ptr<DB> OpenDb(const string& dbname, const bool ttl = false) {

@ -18,9 +18,9 @@ int FLAGS_max_write_buffer_number = 8;
int FLAGS_min_write_buffer_number_to_merge = 7; int FLAGS_min_write_buffer_number_to_merge = 7;
// Path to the database on file system // Path to the database on file system
const std::string kDbName = leveldb::test::TmpDir() + "/perf_context_test"; const std::string kDbName = rocksdb::test::TmpDir() + "/perf_context_test";
void SeekToFirst(leveldb::Iterator* iter) { void SeekToFirst(rocksdb::Iterator* iter) {
// std::cout << "Press a key to continue:"; // std::cout << "Press a key to continue:";
// std::string s; // std::string s;
// std::cin >> s; // std::cin >> s;
@ -30,7 +30,7 @@ void SeekToFirst(leveldb::Iterator* iter) {
// std::cin >> s2; // std::cin >> s2;
} }
namespace leveldb { namespace rocksdb {
std::shared_ptr<DB> OpenDb() { std::shared_ptr<DB> OpenDb() {
DB* db; DB* db;
@ -42,9 +42,9 @@ std::shared_ptr<DB> OpenDb() {
FLAGS_min_write_buffer_number_to_merge; FLAGS_min_write_buffer_number_to_merge;
if (FLAGS_use_set_based_memetable) { if (FLAGS_use_set_based_memetable) {
auto prefix_extractor = leveldb::NewFixedPrefixTransform(0); auto prefix_extractor = rocksdb::NewFixedPrefixTransform(0);
options.memtable_factory = options.memtable_factory =
std::make_shared<leveldb::PrefixHashRepFactory>(prefix_extractor); std::make_shared<rocksdb::PrefixHashRepFactory>(prefix_extractor);
} }
Status s = DB::Open(options, kDbName, &db); Status s = DB::Open(options, kDbName, &db);
@ -315,6 +315,6 @@ int main(int argc, char** argv) {
std::cout << kDbName << "\n"; std::cout << kDbName << "\n";
leveldb::test::RunAllTests(); rocksdb::test::RunAllTests();
return 0; return 0;
} }

@ -14,7 +14,7 @@
#include "rocksdb/iterator.h" #include "rocksdb/iterator.h"
namespace leveldb { namespace rocksdb {
class PrefixFilterIterator : public Iterator { class PrefixFilterIterator : public Iterator {
private: private:
@ -71,6 +71,6 @@ class PrefixFilterIterator : public Iterator {
} }
}; };
} // namespace leveldb } // namespace rocksdb
#endif #endif

@ -38,7 +38,7 @@
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/env.h" #include "rocksdb/env.h"
namespace leveldb { namespace rocksdb {
namespace { namespace {
@ -383,4 +383,4 @@ Status RepairDB(const std::string& dbname, const Options& options) {
return repairer.Run(); return repairer.Run();
} }
} // namespace leveldb } // namespace rocksdb

@ -33,7 +33,7 @@
#include "port/port.h" #include "port/port.h"
#include "util/random.h" #include "util/random.h"
namespace leveldb { namespace rocksdb {
template<typename Key, class Comparator> template<typename Key, class Comparator>
class SkipList { class SkipList {
@ -400,6 +400,6 @@ bool SkipList<Key,Comparator>::Contains(const Key& key) const {
} }
} }
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_SKIPLIST_H_ #endif // STORAGE_LEVELDB_DB_SKIPLIST_H_

@ -10,7 +10,7 @@
#include "util/random.h" #include "util/random.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace leveldb { namespace rocksdb {
typedef uint64_t Key; typedef uint64_t Key;
@ -371,8 +371,8 @@ TEST(SkipTest, Concurrent3) { RunConcurrent(3); }
TEST(SkipTest, Concurrent4) { RunConcurrent(4); } TEST(SkipTest, Concurrent4) { RunConcurrent(4); }
TEST(SkipTest, Concurrent5) { RunConcurrent(5); } TEST(SkipTest, Concurrent5) { RunConcurrent(5); }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -7,7 +7,7 @@
#include "rocksdb/db.h" #include "rocksdb/db.h"
namespace leveldb { namespace rocksdb {
class SnapshotList; class SnapshotList;
@ -80,6 +80,6 @@ class SnapshotList {
SnapshotImpl list_; SnapshotImpl list_;
}; };
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_SNAPSHOT_H_ #endif // STORAGE_LEVELDB_DB_SNAPSHOT_H_

@ -11,7 +11,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/stop_watch.h" #include "util/stop_watch.h"
namespace leveldb { namespace rocksdb {
static void DeleteEntry(const Slice& key, void* value) { static void DeleteEntry(const Slice& key, void* value) {
Table* table = reinterpret_cast<Table*>(value); Table* table = reinterpret_cast<Table*>(value);
@ -160,4 +160,4 @@ void TableCache::Evict(uint64_t file_number) {
cache_->Erase(Slice(buf, sizeof(buf))); cache_->Erase(Slice(buf, sizeof(buf)));
} }
} // namespace leveldb } // namespace rocksdb

@ -15,7 +15,7 @@
#include "port/port.h" #include "port/port.h"
#include "table/table.h" #include "table/table.h"
namespace leveldb { namespace rocksdb {
class Env; class Env;
@ -72,6 +72,6 @@ class TableCache {
const bool no_io = false); const bool no_io = false);
}; };
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_ #endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_

@ -1,7 +1,7 @@
#include "db/transaction_log_impl.h" #include "db/transaction_log_impl.h"
#include "db/write_batch_internal.h" #include "db/write_batch_internal.h"
namespace leveldb { namespace rocksdb {
TransactionLogIteratorImpl::TransactionLogIteratorImpl( TransactionLogIteratorImpl::TransactionLogIteratorImpl(
const std::string& dbname, const std::string& dbname,
@ -168,4 +168,4 @@ Status TransactionLogIteratorImpl::OpenLogReader(const LogFile* logFile) {
); );
return Status::OK(); return Status::OK();
} }
} // namespace leveldb } // namespace rocksdb

@ -11,7 +11,7 @@
#include "db/log_reader.h" #include "db/log_reader.h"
#include "db/filename.h" #include "db/filename.h"
namespace leveldb { namespace rocksdb {
struct LogReporter : public log::Reader::Reporter { struct LogReporter : public log::Reader::Reporter {
Env* env; Env* env;
@ -99,5 +99,5 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_INCLUDE_WRITES_ITERATOR_IMPL_H_ #endif // STORAGE_LEVELDB_INCLUDE_WRITES_ITERATOR_IMPL_H_

@ -7,7 +7,7 @@
#include "db/version_set.h" #include "db/version_set.h"
#include "util/coding.h" #include "util/coding.h"
namespace leveldb { namespace rocksdb {
// Tag numbers for serialized VersionEdit. These numbers are written to // Tag numbers for serialized VersionEdit. These numbers are written to
// disk and should not be changed. // disk and should not be changed.
@ -293,4 +293,4 @@ std::string VersionEdit::DebugString(bool hex_key) const {
return r; return r;
} }
} // namespace leveldb } // namespace rocksdb

@ -10,7 +10,7 @@
#include <vector> #include <vector>
#include "db/dbformat.h" #include "db/dbformat.h"
namespace leveldb { namespace rocksdb {
class VersionSet; class VersionSet;
@ -122,6 +122,6 @@ class VersionEdit {
std::vector< std::pair<int, FileMetaData> > new_files_; std::vector< std::pair<int, FileMetaData> > new_files_;
}; };
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_VERSION_EDIT_H_ #endif // STORAGE_LEVELDB_DB_VERSION_EDIT_H_

@ -5,7 +5,7 @@
#include "db/version_edit.h" #include "db/version_edit.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace leveldb { namespace rocksdb {
static void TestEncodeDecode(const VersionEdit& edit) { static void TestEncodeDecode(const VersionEdit& edit) {
std::string encoded, encoded2; std::string encoded, encoded2;
@ -41,8 +41,8 @@ TEST(VersionEditTest, EncodeDecode) {
TestEncodeDecode(edit); TestEncodeDecode(edit);
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -21,7 +21,7 @@
#include "util/logging.h" #include "util/logging.h"
#include "util/stop_watch.h" #include "util/stop_watch.h"
namespace leveldb { namespace rocksdb {
static uint64_t TotalFileSize(const std::vector<FileMetaData*>& files) { static uint64_t TotalFileSize(const std::vector<FileMetaData*>& files) {
uint64_t sum = 0; uint64_t sum = 0;
@ -3055,4 +3055,4 @@ void Compaction::Summary(char* output, int len) {
level_low_summary, level_up_summary); level_low_summary, level_up_summary);
} }
} // namespace leveldb } // namespace rocksdb

@ -25,7 +25,7 @@
#include "port/port.h" #include "port/port.h"
#include "db/table_cache.h" #include "db/table_cache.h"
namespace leveldb { namespace rocksdb {
namespace log { class Writer; } namespace log { class Writer; }
@ -627,6 +627,6 @@ class Compaction {
void ResetNextCompactionIndex(); void ResetNextCompactionIndex();
}; };
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_VERSION_SET_H_ #endif // STORAGE_LEVELDB_DB_VERSION_SET_H_

@ -10,7 +10,7 @@
#include "db/log_writer.h" #include "db/log_writer.h"
#include "util/logging.h" #include "util/logging.h"
namespace leveldb { namespace rocksdb {
Status VersionSet::ReduceNumberOfLevels(int new_levels, port::Mutex* mu) { Status VersionSet::ReduceNumberOfLevels(int new_levels, port::Mutex* mu) {

@ -7,7 +7,7 @@
#include "util/testharness.h" #include "util/testharness.h"
#include "util/testutil.h" #include "util/testutil.h"
namespace leveldb { namespace rocksdb {
class FindFileTest { class FindFileTest {
public: public:
@ -172,8 +172,8 @@ TEST(FindFileTest, OverlappingFiles) {
ASSERT_TRUE(Overlaps("600", "700")); ASSERT_TRUE(Overlaps("600", "700"));
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -26,7 +26,7 @@
#include "util/coding.h" #include "util/coding.h"
#include <stdexcept> #include <stdexcept>
namespace leveldb { namespace rocksdb {
// WriteBatch header has an 8-byte sequence number followed by a 4-byte count. // WriteBatch header has an 8-byte sequence number followed by a 4-byte count.
static const size_t kHeader = 12; static const size_t kHeader = 12;
@ -227,4 +227,4 @@ void WriteBatchInternal::Append(WriteBatch* dst, const WriteBatch* src) {
dst->rep_.append(src->rep_.data() + kHeader, src->rep_.size() - kHeader); dst->rep_.append(src->rep_.data() + kHeader, src->rep_.size() - kHeader);
} }
} // namespace leveldb } // namespace rocksdb

@ -10,7 +10,7 @@
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/options.h" #include "rocksdb/options.h"
namespace leveldb { namespace rocksdb {
class MemTable; class MemTable;
@ -51,7 +51,7 @@ class WriteBatchInternal {
static void Append(WriteBatch* dst, const WriteBatch* src); static void Append(WriteBatch* dst, const WriteBatch* src);
}; };
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_

@ -12,7 +12,7 @@
#include "util/logging.h" #include "util/logging.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace leveldb { namespace rocksdb {
static std::string PrintContents(WriteBatch* b) { static std::string PrintContents(WriteBatch* b) {
InternalKeyComparator cmp(BytewiseComparator()); InternalKeyComparator cmp(BytewiseComparator());
@ -221,8 +221,8 @@ TEST(WriteBatchTest, Continue) {
handler.seen); handler.seen);
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -111,7 +111,7 @@ static void WalCheckpoint(sqlite3* db_) {
} }
} }
namespace leveldb { namespace rocksdb {
// Helper for quickly generating random data. // Helper for quickly generating random data.
namespace { namespace {
@ -664,7 +664,7 @@ class Benchmark {
}; };
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
std::string default_db_path; std::string default_db_path;
@ -672,7 +672,7 @@ int main(int argc, char** argv) {
double d; double d;
int n; int n;
char junk; char junk;
if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) { if (rocksdb::Slice(argv[i]).starts_with("--benchmarks=")) {
FLAGS_benchmarks = argv[i] + strlen("--benchmarks="); FLAGS_benchmarks = argv[i] + strlen("--benchmarks=");
} else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 && } else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 &&
(n == 0 || n == 1)) { (n == 0 || n == 1)) {
@ -688,7 +688,7 @@ int main(int argc, char** argv) {
FLAGS_reads = n; FLAGS_reads = n;
} else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) { } else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) {
FLAGS_value_size = n; FLAGS_value_size = n;
} else if (leveldb::Slice(argv[i]) == leveldb::Slice("--no_transaction")) { } else if (rocksdb::Slice(argv[i]) == rocksdb::Slice("--no_transaction")) {
FLAGS_transaction = false; FLAGS_transaction = false;
} else if (sscanf(argv[i], "--page_size=%d%c", &n, &junk) == 1) { } else if (sscanf(argv[i], "--page_size=%d%c", &n, &junk) == 1) {
FLAGS_page_size = n; FLAGS_page_size = n;
@ -707,12 +707,12 @@ int main(int argc, char** argv) {
// Choose a location for the test database if none given with --db=<path> // Choose a location for the test database if none given with --db=<path>
if (FLAGS_db == NULL) { if (FLAGS_db == NULL) {
leveldb::Env::Default()->GetTestDirectory(&default_db_path); rocksdb::Env::Default()->GetTestDirectory(&default_db_path);
default_db_path += "/dbbench"; default_db_path += "/dbbench";
FLAGS_db = default_db_path.c_str(); FLAGS_db = default_db_path.c_str();
} }
leveldb::Benchmark benchmark; rocksdb::Benchmark benchmark;
benchmark.Run(); benchmark.Run();
return 0; return 0;
} }

@ -80,7 +80,7 @@ static void DBSynchronize(kyotocabinet::TreeDB* db_)
} }
} }
namespace leveldb { namespace rocksdb {
// Helper for quickly generating random data. // Helper for quickly generating random data.
namespace { namespace {
@ -479,7 +479,7 @@ class Benchmark {
} }
}; };
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
std::string default_db_path; std::string default_db_path;
@ -487,7 +487,7 @@ int main(int argc, char** argv) {
double d; double d;
int n; int n;
char junk; char junk;
if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) { if (rocksdb::Slice(argv[i]).starts_with("--benchmarks=")) {
FLAGS_benchmarks = argv[i] + strlen("--benchmarks="); FLAGS_benchmarks = argv[i] + strlen("--benchmarks=");
} else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) { } else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) {
FLAGS_compression_ratio = d; FLAGS_compression_ratio = d;
@ -517,12 +517,12 @@ int main(int argc, char** argv) {
// Choose a location for the test database if none given with --db=<path> // Choose a location for the test database if none given with --db=<path>
if (FLAGS_db == NULL) { if (FLAGS_db == NULL) {
leveldb::Env::Default()->GetTestDirectory(&default_db_path); rocksdb::Env::Default()->GetTestDirectory(&default_db_path);
default_db_path += "/dbbench"; default_db_path += "/dbbench";
FLAGS_db = default_db_path.c_str(); FLAGS_db = default_db_path.c_str();
} }
leveldb::Benchmark benchmark; rocksdb::Benchmark benchmark;
benchmark.Run(); benchmark.Run();
return 0; return 0;
} }

@ -25,27 +25,27 @@ creating it if necessary:
#include &lt;assert&gt; #include &lt;assert&gt;
#include "leveldb/db.h" #include "leveldb/db.h"
leveldb::DB* db; rocksdb::DB* db;
leveldb::Options options; rocksdb::Options options;
options.create_if_missing = true; options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &amp;db); rocksdb::Status status = rocksdb::DB::Open(options, "/tmp/testdb", &amp;db);
assert(status.ok()); assert(status.ok());
... ...
</pre> </pre>
If you want to raise an error if the database already exists, add If you want to raise an error if the database already exists, add
the following line before the <code>leveldb::DB::Open</code> call: the following line before the <code>rocksdb::DB::Open</code> call:
<pre> <pre>
options.error_if_exists = true; options.error_if_exists = true;
</pre> </pre>
<h1>Status</h1> <h1>Status</h1>
<p> <p>
You may have noticed the <code>leveldb::Status</code> type above. Values of this You may have noticed the <code>rocksdb::Status</code> type above. Values of this
type are returned by most functions in <code>leveldb</code> that may encounter an type are returned by most functions in <code>leveldb</code> that may encounter an
error. You can check if such a result is ok, and also print an error. You can check if such a result is ok, and also print an
associated error message: associated error message:
<p> <p>
<pre> <pre>
leveldb::Status s = ...; rocksdb::Status s = ...;
if (!s.ok()) cerr &lt;&lt; s.ToString() &lt;&lt; endl; if (!s.ok()) cerr &lt;&lt; s.ToString() &lt;&lt; endl;
</pre> </pre>
<h1>Closing A Database</h1> <h1>Closing A Database</h1>
@ -65,9 +65,9 @@ modify/query the database. For example, the following code
moves the value stored under key1 to key2. moves the value stored under key1 to key2.
<pre> <pre>
std::string value; std::string value;
leveldb::Status s = db-&gt;Get(leveldb::ReadOptions(), key1, &amp;value); rocksdb::Status s = db-&gt;Get(rocksdb::ReadOptions(), key1, &amp;value);
if (s.ok()) s = db-&gt;Put(leveldb::WriteOptions(), key2, value); if (s.ok()) s = db-&gt;Put(rocksdb::WriteOptions(), key2, value);
if (s.ok()) s = db-&gt;Delete(leveldb::WriteOptions(), key1); if (s.ok()) s = db-&gt;Delete(rocksdb::WriteOptions(), key1);
</pre> </pre>
<h1>Atomic Updates</h1> <h1>Atomic Updates</h1>
@ -81,12 +81,12 @@ atomically apply a set of updates:
#include "leveldb/write_batch.h" #include "leveldb/write_batch.h"
... ...
std::string value; std::string value;
leveldb::Status s = db-&gt;Get(leveldb::ReadOptions(), key1, &amp;value); rocksdb::Status s = db-&gt;Get(rocksdb::ReadOptions(), key1, &amp;value);
if (s.ok()) { if (s.ok()) {
leveldb::WriteBatch batch; rocksdb::WriteBatch batch;
batch.Delete(key1); batch.Delete(key1);
batch.Put(key2, value); batch.Put(key2, value);
s = db-&gt;Write(leveldb::WriteOptions(), &amp;batch); s = db-&gt;Write(rocksdb::WriteOptions(), &amp;batch);
} }
</pre> </pre>
The <code>WriteBatch</code> holds a sequence of edits to be made to the database, The <code>WriteBatch</code> holds a sequence of edits to be made to the database,
@ -109,7 +109,7 @@ persistent storage. (On Posix systems, this is implemented by calling
either <code>fsync(...)</code> or <code>fdatasync(...)</code> or either <code>fsync(...)</code> or <code>fdatasync(...)</code> or
<code>msync(..., MS_SYNC)</code> before the write operation returns.) <code>msync(..., MS_SYNC)</code> before the write operation returns.)
<pre> <pre>
leveldb::WriteOptions write_options; rocksdb::WriteOptions write_options;
write_options.sync = true; write_options.sync = true;
db-&gt;Put(write_options, ...); db-&gt;Put(write_options, ...);
</pre> </pre>
@ -144,7 +144,7 @@ the batch.
A database may only be opened by one process at a time. A database may only be opened by one process at a time.
The <code>leveldb</code> implementation acquires a lock from the The <code>leveldb</code> implementation acquires a lock from the
operating system to prevent misuse. Within a single process, the operating system to prevent misuse. Within a single process, the
same <code>leveldb::DB</code> object may be safely shared by multiple same <code>rocksdb::DB</code> object may be safely shared by multiple
concurrent threads. I.e., different threads may write into or fetch concurrent threads. I.e., different threads may write into or fetch
iterators or call <code>Get</code> on the same database without any iterators or call <code>Get</code> on the same database without any
external synchronization (the leveldb implementation will external synchronization (the leveldb implementation will
@ -160,7 +160,7 @@ The following example demonstrates how to print all key,value pairs
in a database. in a database.
<p> <p>
<pre> <pre>
leveldb::Iterator* it = db-&gt;NewIterator(leveldb::ReadOptions()); rocksdb::Iterator* it = db-&gt;NewIterator(rocksdb::ReadOptions());
for (it-&gt;SeekToFirst(); it-&gt;Valid(); it-&gt;Next()) { for (it-&gt;SeekToFirst(); it-&gt;Valid(); it-&gt;Next()) {
cout &lt;&lt; it-&gt;key().ToString() &lt;&lt; ": " &lt;&lt; it-&gt;value().ToString() &lt;&lt; endl; cout &lt;&lt; it-&gt;key().ToString() &lt;&lt; ": " &lt;&lt; it-&gt;value().ToString() &lt;&lt; endl;
} }
@ -196,10 +196,10 @@ implicit snapshot of the current state.
Snapshots are created by the DB::GetSnapshot() method: Snapshots are created by the DB::GetSnapshot() method:
<p> <p>
<pre> <pre>
leveldb::ReadOptions options; rocksdb::ReadOptions options;
options.snapshot = db-&gt;GetSnapshot(); options.snapshot = db-&gt;GetSnapshot();
... apply some updates to db ... ... apply some updates to db ...
leveldb::Iterator* iter = db-&gt;NewIterator(options); rocksdb::Iterator* iter = db-&gt;NewIterator(options);
... read using iter to view the state when the snapshot was created ... ... read using iter to view the state when the snapshot was created ...
delete iter; delete iter;
db-&gt;ReleaseSnapshot(options.snapshot); db-&gt;ReleaseSnapshot(options.snapshot);
@ -211,7 +211,7 @@ support reading as of that snapshot.
<h1>Slice</h1> <h1>Slice</h1>
<p> <p>
The return value of the <code>it->key()</code> and <code>it->value()</code> calls above The return value of the <code>it->key()</code> and <code>it->value()</code> calls above
are instances of the <code>leveldb::Slice</code> type. <code>Slice</code> is a simple are instances of the <code>rocksdb::Slice</code> type. <code>Slice</code> is a simple
structure that contains a length and a pointer to an external byte structure that contains a length and a pointer to an external byte
array. Returning a <code>Slice</code> is a cheaper alternative to returning a array. Returning a <code>Slice</code> is a cheaper alternative to returning a
<code>std::string</code> since we do not need to copy potentially large keys and <code>std::string</code> since we do not need to copy potentially large keys and
@ -223,10 +223,10 @@ C++ strings and null-terminated C-style strings can be easily converted
to a Slice: to a Slice:
<p> <p>
<pre> <pre>
leveldb::Slice s1 = "hello"; rocksdb::Slice s1 = "hello";
std::string str("world"); std::string str("world");
leveldb::Slice s2 = str; rocksdb::Slice s2 = str;
</pre> </pre>
A Slice can be easily converted back to a C++ string: A Slice can be easily converted back to a C++ string:
<pre> <pre>
@ -238,7 +238,7 @@ the external byte array into which the Slice points remains live while
the Slice is in use. For example, the following is buggy: the Slice is in use. For example, the following is buggy:
<p> <p>
<pre> <pre>
leveldb::Slice slice; rocksdb::Slice slice;
if (...) { if (...) {
std::string str = ...; std::string str = ...;
slice = str; slice = str;
@ -255,16 +255,16 @@ which orders bytes lexicographically. You can however supply a custom
comparator when opening a database. For example, suppose each comparator when opening a database. For example, suppose each
database key consists of two numbers and we should sort by the first database key consists of two numbers and we should sort by the first
number, breaking ties by the second number. First, define a proper number, breaking ties by the second number. First, define a proper
subclass of <code>leveldb::Comparator</code> that expresses these rules: subclass of <code>rocksdb::Comparator</code> that expresses these rules:
<p> <p>
<pre> <pre>
class TwoPartComparator : public leveldb::Comparator { class TwoPartComparator : public rocksdb::Comparator {
public: public:
// Three-way comparison function: // Three-way comparison function:
// if a &lt; b: negative result // if a &lt; b: negative result
// if a &gt; b: positive result // if a &gt; b: positive result
// else: zero result // else: zero result
int Compare(const leveldb::Slice&amp; a, const leveldb::Slice&amp; b) const { int Compare(const rocksdb::Slice&amp; a, const rocksdb::Slice&amp; b) const {
int a1, a2, b1, b2; int a1, a2, b1, b2;
ParseKey(a, &amp;a1, &amp;a2); ParseKey(a, &amp;a1, &amp;a2);
ParseKey(b, &amp;b1, &amp;b2); ParseKey(b, &amp;b1, &amp;b2);
@ -277,7 +277,7 @@ subclass of <code>leveldb::Comparator</code> that expresses these rules:
// Ignore the following methods for now: // Ignore the following methods for now:
const char* Name() const { return "TwoPartComparator"; } const char* Name() const { return "TwoPartComparator"; }
void FindShortestSeparator(std::string*, const leveldb::Slice&amp;) const { } void FindShortestSeparator(std::string*, const rocksdb::Slice&amp;) const { }
void FindShortSuccessor(std::string*) const { } void FindShortSuccessor(std::string*) const { }
}; };
</pre> </pre>
@ -285,18 +285,18 @@ Now create a database using this custom comparator:
<p> <p>
<pre> <pre>
TwoPartComparator cmp; TwoPartComparator cmp;
leveldb::DB* db; rocksdb::DB* db;
leveldb::Options options; rocksdb::Options options;
options.create_if_missing = true; options.create_if_missing = true;
options.comparator = &amp;cmp; options.comparator = &amp;cmp;
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &amp;db); rocksdb::Status status = rocksdb::DB::Open(options, "/tmp/testdb", &amp;db);
... ...
</pre> </pre>
<h2>Backwards compatibility</h2> <h2>Backwards compatibility</h2>
<p> <p>
The result of the comparator's <code>Name</code> method is attached to the The result of the comparator's <code>Name</code> method is attached to the
database when it is created, and is checked on every subsequent database when it is created, and is checked on every subsequent
database open. If the name changes, the <code>leveldb::DB::Open</code> call will database open. If the name changes, the <code>rocksdb::DB::Open</code> call will
fail. Therefore, change the name if and only if the new key format fail. Therefore, change the name if and only if the new key format
and comparison function are incompatible with existing databases, and and comparison function are incompatible with existing databases, and
it is ok to discard the contents of all existing databases. it is ok to discard the contents of all existing databases.
@ -339,9 +339,9 @@ compression entirely, but should only do so if benchmarks show a
performance improvement: performance improvement:
<p> <p>
<pre> <pre>
leveldb::Options options; rocksdb::Options options;
options.compression = leveldb::kNoCompression; options.compression = rocksdb::kNoCompression;
... leveldb::DB::Open(options, name, ...) .... ... rocksdb::DB::Open(options, name, ...) ....
</pre> </pre>
<h2>Cache</h2> <h2>Cache</h2>
<p> <p>
@ -353,10 +353,10 @@ uncompressed block contents.
<pre> <pre>
#include "leveldb/cache.h" #include "leveldb/cache.h"
leveldb::Options options; rocksdb::Options options;
options.cache = leveldb::NewLRUCache(100 * 1048576); // 100MB cache options.cache = rocksdb::NewLRUCache(100 * 1048576); // 100MB cache
leveldb::DB* db; rocksdb::DB* db;
leveldb::DB::Open(options, name, &db); rocksdb::DB::Open(options, name, &db);
... use the db ... ... use the db ...
delete db delete db
delete options.cache; delete options.cache;
@ -373,9 +373,9 @@ displacing most of the cached contents. A per-iterator option can be
used to achieve this: used to achieve this:
<p> <p>
<pre> <pre>
leveldb::ReadOptions options; rocksdb::ReadOptions options;
options.fill_cache = false; options.fill_cache = false;
leveldb::Iterator* it = db-&gt;NewIterator(options); rocksdb::Iterator* it = db-&gt;NewIterator(options);
for (it-&gt;SeekToFirst(); it-&gt;Valid(); it-&gt;Next()) { for (it-&gt;SeekToFirst(); it-&gt;Valid(); it-&gt;Next()) {
... ...
} }
@ -407,10 +407,10 @@ a single <code>Get()</code> call may involve multiple reads from disk.
The optional <code>FilterPolicy</code> mechanism can be used to reduce The optional <code>FilterPolicy</code> mechanism can be used to reduce
the number of disk reads substantially. the number of disk reads substantially.
<pre> <pre>
leveldb::Options options; rocksdb::Options options;
options.filter_policy = NewBloomFilter(10); options.filter_policy = NewBloomFilter(10);
leveldb::DB* db; rocksdb::DB* db;
leveldb::DB::Open(options, "/tmp/testdb", &amp;db); rocksdb::DB::Open(options, "/tmp/testdb", &amp;db);
... use the database ... ... use the database ...
delete db; delete db;
delete options.filter_policy; delete options.filter_policy;
@ -434,7 +434,7 @@ consider a comparator that ignores trailing spaces when comparing keys.
Instead, the application should provide a custom filter policy that Instead, the application should provide a custom filter policy that
also ignores trailing spaces. For example: also ignores trailing spaces. For example:
<pre> <pre>
class CustomFilterPolicy : public leveldb::FilterPolicy { class CustomFilterPolicy : public rocksdb::FilterPolicy {
private: private:
FilterPolicy* builtin_policy_; FilterPolicy* builtin_policy_;
public: public:
@ -484,7 +484,7 @@ checksums are verified:
parts of its persistent storage have been corrupted. parts of its persistent storage have been corrupted.
<p> <p>
If a database is corrupted (perhaps it cannot be opened when If a database is corrupted (perhaps it cannot be opened when
paranoid checking is turned on), the <code>leveldb::RepairDB</code> function paranoid checking is turned on), the <code>rocksdb::RepairDB</code> function
may be used to recover as much of the data as possible may be used to recover as much of the data as possible
<p> <p>
</ul> </ul>
@ -494,11 +494,11 @@ The <code>GetApproximateSizes</code> method can used to get the approximate
number of bytes of file system space used by one or more key ranges. number of bytes of file system space used by one or more key ranges.
<p> <p>
<pre> <pre>
leveldb::Range ranges[2]; rocksdb::Range ranges[2];
ranges[0] = leveldb::Range("a", "c"); ranges[0] = rocksdb::Range("a", "c");
ranges[1] = leveldb::Range("x", "z"); ranges[1] = rocksdb::Range("x", "z");
uint64_t sizes[2]; uint64_t sizes[2];
leveldb::Status s = db-&gt;GetApproximateSizes(ranges, 2, sizes); rocksdb::Status s = db-&gt;GetApproximateSizes(ranges, 2, sizes);
</pre> </pre>
The preceding call will set <code>sizes[0]</code> to the approximate number of The preceding call will set <code>sizes[0]</code> to the approximate number of
bytes of file system space used by the key range <code>[a..c)</code> and bytes of file system space used by the key range <code>[a..c)</code> and
@ -508,21 +508,21 @@ bytes of file system space used by the key range <code>[a..c)</code> and
<h1>Environment</h1> <h1>Environment</h1>
<p> <p>
All file operations (and other operating system calls) issued by the All file operations (and other operating system calls) issued by the
<code>leveldb</code> implementation are routed through a <code>leveldb::Env</code> object. <code>leveldb</code> implementation are routed through a <code>rocksdb::Env</code> object.
Sophisticated clients may wish to provide their own <code>Env</code> Sophisticated clients may wish to provide their own <code>Env</code>
implementation to get better control. For example, an application may implementation to get better control. For example, an application may
introduce artificial delays in the file IO paths to limit the impact introduce artificial delays in the file IO paths to limit the impact
of <code>leveldb</code> on other activities in the system. of <code>leveldb</code> on other activities in the system.
<p> <p>
<pre> <pre>
class SlowEnv : public leveldb::Env { class SlowEnv : public rocksdb::Env {
.. implementation of the Env interface ... .. implementation of the Env interface ...
}; };
SlowEnv env; SlowEnv env;
leveldb::Options options; rocksdb::Options options;
options.env = &amp;env; options.env = &amp;env;
Status s = leveldb::DB::Open(options, ...); Status s = rocksdb::DB::Open(options, ...);
</pre> </pre>
<h1>Porting</h1> <h1>Porting</h1>
<p> <p>
@ -531,7 +531,7 @@ specific implementations of the types/methods/functions exported by
<code>leveldb/port/port.h</code>. See <code>leveldb/port/port_example.h</code> for more <code>leveldb/port/port.h</code>. See <code>leveldb/port/port_example.h</code> for more
details. details.
<p> <p>
In addition, the new platform may need a new default <code>leveldb::Env</code> In addition, the new platform may need a new default <code>rocksdb::Env</code>
implementation. See <code>leveldb/util/env_posix.h</code> for an example. implementation. See <code>leveldb/util/env_posix.h</code> for an example.
<h1>Other Information</h1> <h1>Other Information</h1>

@ -31,7 +31,7 @@
#ifdef USE_HDFS #ifdef USE_HDFS
#include "hdfs/hdfs.h" #include "hdfs/hdfs.h"
namespace leveldb { namespace rocksdb {
static const std::string kProto = "hdfs://"; static const std::string kProto = "hdfs://";
static const std::string pathsep = "/"; static const std::string pathsep = "/";
@ -214,12 +214,12 @@ class HdfsEnv : public Env {
} }
}; };
} // namespace leveldb } // namespace rocksdb
#else // USE_HDFS #else // USE_HDFS
namespace leveldb { namespace rocksdb {
static const Status notsup; static const Status notsup;

@ -13,7 +13,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace leveldb { namespace rocksdb {
namespace { namespace {
@ -383,4 +383,4 @@ Env* NewMemEnv(Env* base_env) {
return new InMemoryEnv(base_env); return new InMemoryEnv(base_env);
} }
} // namespace leveldb } // namespace rocksdb

@ -4,7 +4,7 @@
#ifndef STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_ #ifndef STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_
#define STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_ #define STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_
namespace leveldb { namespace rocksdb {
class Env; class Env;
@ -14,6 +14,6 @@ class Env;
// *base_env must remain live while the result is in use. // *base_env must remain live while the result is in use.
Env* NewMemEnv(Env* base_env); Env* NewMemEnv(Env* base_env);
} // namespace leveldb } // namespace rocksdb
#endif // STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_ #endif // STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_

@ -12,7 +12,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace leveldb { namespace rocksdb {
class MemEnvTest { class MemEnvTest {
public: public:
@ -226,8 +226,8 @@ TEST(MemEnvTest, DBTest) {
delete db; delete db;
} }
} // namespace leveldb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {
return leveldb::test::RunAllTests(); return rocksdb::test::RunAllTests();
} }

@ -11,7 +11,7 @@
#include <limits> #include <limits>
#include <memory> #include <memory>
namespace leveldb { namespace rocksdb {
class Arena { class Arena {
public: public:
@ -36,6 +36,8 @@ class Arena {
void operator=(const Arena&); void operator=(const Arena&);
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_ARENA_H_ #endif // STORAGE_ROCKSDB_INCLUDE_ARENA_H_

@ -22,7 +22,7 @@
#include <stdint.h> #include <stdint.h>
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
namespace leveldb { namespace rocksdb {
using std::shared_ptr; using std::shared_ptr;
@ -101,6 +101,8 @@ class Cache {
void operator=(const Cache&); void operator=(const Cache&);
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_UTIL_CACHE_H_ #endif // STORAGE_ROCKSDB_UTIL_CACHE_H_

@ -7,7 +7,7 @@
#include <string> #include <string>
namespace leveldb { namespace rocksdb {
class Slice; class Slice;
@ -66,6 +66,8 @@ class DefaultCompactionFilterFactory : public CompactionFilterFactory {
} }
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_COMPACTION_FILTER_H_ #endif // STORAGE_ROCKSDB_INCLUDE_COMPACTION_FILTER_H_

@ -7,7 +7,7 @@
#include <string> #include <string>
namespace leveldb { namespace rocksdb {
class Slice; class Slice;
@ -58,6 +58,8 @@ class Comparator {
// must not be deleted. // must not be deleted.
extern const Comparator* BytewiseComparator(); extern const Comparator* BytewiseComparator();
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_COMPARATOR_H_ #endif // STORAGE_ROCKSDB_INCLUDE_COMPARATOR_H_

@ -14,7 +14,7 @@
#include "rocksdb/types.h" #include "rocksdb/types.h"
#include "rocksdb/transaction_log.h" #include "rocksdb/transaction_log.h"
namespace leveldb { namespace rocksdb {
using std::unique_ptr; using std::unique_ptr;
@ -306,6 +306,8 @@ Status DestroyDB(const std::string& name, const Options& options);
// on a database that contains important information. // on a database that contains important information.
Status RepairDB(const std::string& dbname, const Options& options); Status RepairDB(const std::string& dbname, const Options& options);
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_DB_H_ #endif // STORAGE_ROCKSDB_INCLUDE_DB_H_

@ -20,7 +20,7 @@
#include <stdint.h> #include <stdint.h>
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace leveldb { namespace rocksdb {
class FileLock; class FileLock;
class Logger; class Logger;
@ -563,6 +563,8 @@ class EnvWrapper : public Env {
Env* target_; Env* target_;
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_ENV_H_ #endif // STORAGE_ROCKSDB_INCLUDE_ENV_H_

@ -18,7 +18,7 @@
#include <string> #include <string>
namespace leveldb { namespace rocksdb {
class Slice; class Slice;
@ -66,5 +66,6 @@ class FilterPolicy {
extern const FilterPolicy* NewBloomFilterPolicy(int bits_per_key); extern const FilterPolicy* NewBloomFilterPolicy(int bits_per_key);
} }
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_FILTER_POLICY_H_ #endif // STORAGE_ROCKSDB_INCLUDE_FILTER_POLICY_H_

@ -18,7 +18,7 @@
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace leveldb { namespace rocksdb {
class Iterator { class Iterator {
public: public:
@ -97,6 +97,8 @@ extern Iterator* NewEmptyIterator();
// Return an empty iterator with the specified status. // Return an empty iterator with the specified status.
extern Iterator* NewErrorIterator(const Status& status); extern Iterator* NewErrorIterator(const Status& status);
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_ITERATOR_H_ #endif // STORAGE_ROCKSDB_INCLUDE_ITERATOR_H_

@ -3,12 +3,18 @@
#define STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H #define STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H
#include "rocksdb/options.h" #include "rocksdb/options.h"
namespace leveldb { namespace rocksdb {
class LDBTool { class LDBTool {
public: public:
void Run(int argc, char** argv, Options = Options()); void Run(int argc, char** argv, Options = Options());
}; };
} // namespace leveldb namespace leveldb = rocksdb;
} // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H #endif // STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H

@ -44,7 +44,7 @@
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
#include "rocksdb/slice_transform.h" #include "rocksdb/slice_transform.h"
namespace leveldb { namespace rocksdb {
class MemTableRep { class MemTableRep {
public: public:
@ -256,4 +256,6 @@ public:
} }
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_DB_MEMTABLEREP_H_ #endif // STORAGE_ROCKSDB_DB_MEMTABLEREP_H_

@ -9,7 +9,7 @@
#include <deque> #include <deque>
#include "rocksdb/slice.h" // TODO: Remove this when migration is done; #include "rocksdb/slice.h" // TODO: Remove this when migration is done;
namespace leveldb { namespace rocksdb {
class Slice; class Slice;
class Logger; class Logger;
@ -142,6 +142,8 @@ class AssociativeMergeOperator : public MergeOperator {
Logger* logger) const override; Logger* logger) const override;
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_MERGE_OPERATOR_H_ #endif // STORAGE_ROCKSDB_INCLUDE_MERGE_OPERATOR_H_

@ -16,7 +16,7 @@
#include "rocksdb/memtablerep.h" #include "rocksdb/memtablerep.h"
#include "rocksdb/slice_transform.h" #include "rocksdb/slice_transform.h"
namespace leveldb { namespace rocksdb {
class Cache; class Cache;
class Comparator; class Comparator;
@ -673,6 +673,8 @@ struct FlushOptions {
} }
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_OPTIONS_H_ #endif // STORAGE_ROCKSDB_INCLUDE_OPTIONS_H_

@ -3,7 +3,7 @@
#include <stdint.h> #include <stdint.h>
namespace leveldb { namespace rocksdb {
enum PerfLevel { enum PerfLevel {
kDisable = 0, // disable perf stats kDisable = 0, // disable perf stats
@ -36,5 +36,6 @@ extern __thread PerfContext perf_context;
} }
#include "rocksdb/rocksdb_to_leveldb.h"
#endif #endif

@ -0,0 +1,9 @@
// Copyright (c) 2013 Facebook.
#pragma once
//
// This is for backward compatibility with applications that use the
// 'leveldb' namespace. This file will be deleted in a future release.
//
namespace leveldb = rocksdb;

@ -20,7 +20,7 @@
#include <string.h> #include <string.h>
#include <string> #include <string>
namespace leveldb { namespace rocksdb {
class Slice { class Slice {
public: public:
@ -117,6 +117,8 @@ inline int Slice::compare(const Slice& b) const {
return r; return r;
} }
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_SLICE_H_ #endif // STORAGE_ROCKSDB_INCLUDE_SLICE_H_

@ -13,7 +13,7 @@
#include <string> #include <string>
namespace leveldb { namespace rocksdb {
class Slice; class Slice;
@ -40,4 +40,6 @@ extern const SliceTransform* NewNoopTransform();
} }
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_SLICE_TRANSFORM_H_ #endif // STORAGE_ROCKSDB_INCLUDE_SLICE_TRANSFORM_H_

@ -13,7 +13,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
namespace leveldb { namespace rocksdb {
/** /**
* Keep adding ticker's here. * Keep adding ticker's here.
@ -258,6 +258,8 @@ inline void SetTickerCount(std::shared_ptr<Statistics> statistics,
} }
} }
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_STATISTICS_H_ #endif // STORAGE_ROCKSDB_INCLUDE_STATISTICS_H_

@ -16,7 +16,7 @@
#include <string> #include <string>
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
namespace leveldb { namespace rocksdb {
class Status { class Status {
public: public:
@ -121,6 +121,8 @@ inline void Status::operator=(const Status& s) {
} }
} }
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_STATUS_H_ #endif // STORAGE_ROCKSDB_INCLUDE_STATUS_H_

@ -17,7 +17,7 @@
#include "rocksdb/options.h" #include "rocksdb/options.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace leveldb { namespace rocksdb {
class BlockBuilder; class BlockBuilder;
class BlockHandle; class BlockHandle;
@ -90,6 +90,8 @@ class TableBuilder {
void operator=(const TableBuilder&); void operator=(const TableBuilder&);
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_TABLE_BUILDER_H_ #endif // STORAGE_ROCKSDB_INCLUDE_TABLE_BUILDER_H_

@ -6,7 +6,7 @@
#include "rocksdb/types.h" #include "rocksdb/types.h"
#include "rocksdb/write_batch.h" #include "rocksdb/write_batch.h"
namespace leveldb { namespace rocksdb {
class LogFile; class LogFile;
typedef std::vector<std::unique_ptr<LogFile>> VectorLogPtr; typedef std::vector<std::unique_ptr<LogFile>> VectorLogPtr;
@ -76,6 +76,8 @@ class TransactionLogIterator {
// ONLY use if Valid() is true and status() is OK. // ONLY use if Valid() is true and status() is OK.
virtual BatchResult GetBatch() = 0; virtual BatchResult GetBatch() = 0;
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_TRANSACTION_LOG_ITERATOR_H_ #endif // STORAGE_ROCKSDB_INCLUDE_TRANSACTION_LOG_ITERATOR_H_

@ -3,12 +3,15 @@
#include <stdint.h> #include <stdint.h>
namespace leveldb { namespace rocksdb {
// Define all public custom types here. // Define all public custom types here.
// Represents a sequence number in a WAL file. // Represents a sequence number in a WAL file.
typedef uint64_t SequenceNumber; typedef uint64_t SequenceNumber;
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_TYPES_H_ #endif // STORAGE_ROCKSDB_INCLUDE_TYPES_H_

@ -14,7 +14,7 @@
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
#include "rocksdb/statistics.h" #include "rocksdb/statistics.h"
namespace leveldb { namespace rocksdb {
// //
// Algorithm used to make a compaction request stop picking new files // Algorithm used to make a compaction request stop picking new files
@ -65,6 +65,8 @@ class CompactionOptionsUniversal {
} }
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_UNIVERSAL_COMPACTION_OPTIONS_H #endif // STORAGE_ROCKSDB_UNIVERSAL_COMPACTION_OPTIONS_H

@ -24,7 +24,7 @@
#include <string> #include <string>
#include "rocksdb/status.h" #include "rocksdb/status.h"
namespace leveldb { namespace rocksdb {
class Slice; class Slice;
@ -94,6 +94,8 @@ class WriteBatch {
// Intentionally copyable // Intentionally copyable
}; };
} // namespace leveldb } // namespace rocksdb
#include "rocksdb/rocksdb_to_leveldb.h"
#endif // STORAGE_ROCKSDB_INCLUDE_WRITE_BATCH_H_ #endif // STORAGE_ROCKSDB_INCLUDE_WRITE_BATCH_H_

@ -7,7 +7,7 @@
#include "rocksdb/db.h" #include "rocksdb/db.h"
namespace leveldb { namespace rocksdb {
// This class contains APIs to stack rocksdb wrappers.Eg. Stack TTL over base d // This class contains APIs to stack rocksdb wrappers.Eg. Stack TTL over base d
class StackableDB : public DB { class StackableDB : public DB {
@ -160,6 +160,6 @@ class StackableDB : public DB {
StackableDB* sdb_; StackableDB* sdb_;
}; };
} // namespace leveldb } // namespace rocksdb
#endif // LEVELDB_INCLUDE_UTILITIES_STACKABLE_DB_H_ #endif // LEVELDB_INCLUDE_UTILITIES_STACKABLE_DB_H_

@ -7,7 +7,7 @@
#include "stackable_db.h" #include "stackable_db.h"
namespace leveldb { namespace rocksdb {
// This class contains APIs to open leveldb with specific support eg. TTL // This class contains APIs to open leveldb with specific support eg. TTL
class UtilityDB { class UtilityDB {
@ -49,6 +49,6 @@ class UtilityDB {
bool read_only = false); bool read_only = false);
}; };
} // namespace leveldb } // namespace rocksdb
#endif // LEVELDB_INCLUDE_UTILITIES_UTILITY_DB_H_ #endif // LEVELDB_INCLUDE_UTILITIES_UTILITY_DB_H_

@ -39,19 +39,19 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.CPP;
import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE; import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE;
/** /**
* Provides a java interface to the C++ leveldb::Cache class. * Provides a java interface to the C++ rocksdb::Cache class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */
public class NativeCache extends NativeObject { public class NativeCache extends NativeObject {
@JniClass(name="leveldb::Cache", flags={CPP}) @JniClass(name="rocksdb::Cache", flags={CPP})
private static class CacheJNI { private static class CacheJNI {
static { static {
NativeDB.LIBRARY.load(); NativeDB.LIBRARY.load();
} }
@JniMethod(cast="leveldb::Cache *", accessor="leveldb::NewLRUCache") @JniMethod(cast="rocksdb::Cache *", accessor="rocksdb::NewLRUCache")
public static final native long NewLRUCache( public static final native long NewLRUCache(
@JniArg(cast="size_t") long capacity); @JniArg(cast="size_t") long capacity);

@ -40,7 +40,7 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.*;
/** /**
* <p> * <p>
* Provides a java interface to the C++ leveldb::Comparator class. * Provides a java interface to the C++ rocksdb::Comparator class.
* </p> * </p>
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@ -85,7 +85,7 @@ public abstract class NativeComparator extends NativeObject {
@JniField(flags={CONSTANT}, accessor="sizeof(struct JNIComparator)") @JniField(flags={CONSTANT}, accessor="sizeof(struct JNIComparator)")
static int SIZEOF; static int SIZEOF;
@JniField(flags={CONSTANT}, cast="const Comparator*", accessor="leveldb::BytewiseComparator()") @JniField(flags={CONSTANT}, cast="const Comparator*", accessor="rocksdb::BytewiseComparator()")
private static long BYTEWISE_COMPARATOR; private static long BYTEWISE_COMPARATOR;
} }

@ -32,7 +32,7 @@
package org.fusesource.leveldbjni.internal; package org.fusesource.leveldbjni.internal;
/** /**
* Provides a java interface to the C++ leveldb::CompressionType enum. * Provides a java interface to the C++ rocksdb::CompressionType enum.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */

@ -52,7 +52,7 @@ public class NativeDB extends NativeObject {
public static final Library LIBRARY = new Library("leveldbjni", NativeDB.class); public static final Library LIBRARY = new Library("leveldbjni", NativeDB.class);
@JniClass(name="leveldb::DB", flags={CPP}) @JniClass(name="rocksdb::DB", flags={CPP})
static class DBJNI { static class DBJNI {
static { static {
NativeDB.LIBRARY.load(); NativeDB.LIBRARY.load();
@ -79,13 +79,13 @@ public class NativeDB extends NativeObject {
long self long self
); );
@JniMethod(copy="leveldb::Status", accessor = "leveldb::DB::Open") @JniMethod(copy="rocksdb::Status", accessor = "rocksdb::DB::Open")
static final native long Open( static final native long Open(
@JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options, @JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options,
@JniArg(cast="const char*") String path, @JniArg(cast="const char*") String path,
@JniArg(cast="leveldb::DB**") long[] self); @JniArg(cast="rocksdb::DB**") long[] self);
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD}) @JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
static final native long Put( static final native long Put(
long self, long self,
@JniArg(flags={BY_VALUE, NO_OUT}) NativeWriteOptions options, @JniArg(flags={BY_VALUE, NO_OUT}) NativeWriteOptions options,
@ -93,21 +93,21 @@ public class NativeDB extends NativeObject {
@JniArg(flags={BY_VALUE, NO_OUT}) NativeSlice value @JniArg(flags={BY_VALUE, NO_OUT}) NativeSlice value
); );
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD}) @JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
static final native long Delete( static final native long Delete(
long self, long self,
@JniArg(flags={BY_VALUE, NO_OUT}) NativeWriteOptions options, @JniArg(flags={BY_VALUE, NO_OUT}) NativeWriteOptions options,
@JniArg(flags={BY_VALUE, NO_OUT}) NativeSlice key @JniArg(flags={BY_VALUE, NO_OUT}) NativeSlice key
); );
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD}) @JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
static final native long Write( static final native long Write(
long self, long self,
@JniArg(flags={BY_VALUE}) NativeWriteOptions options, @JniArg(flags={BY_VALUE}) NativeWriteOptions options,
@JniArg(cast="leveldb::WriteBatch *") long updates @JniArg(cast="rocksdb::WriteBatch *") long updates
); );
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD}) @JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
static final native long Get( static final native long Get(
long self, long self,
@JniArg(flags={NO_OUT, BY_VALUE}) NativeReadOptions options, @JniArg(flags={NO_OUT, BY_VALUE}) NativeReadOptions options,
@ -115,26 +115,26 @@ public class NativeDB extends NativeObject {
@JniArg(cast="std::string *") long value @JniArg(cast="std::string *") long value
); );
@JniMethod(cast="leveldb::Iterator *", flags={CPP_METHOD}) @JniMethod(cast="rocksdb::Iterator *", flags={CPP_METHOD})
static final native long NewIterator( static final native long NewIterator(
long self, long self,
@JniArg(flags={NO_OUT, BY_VALUE}) NativeReadOptions options @JniArg(flags={NO_OUT, BY_VALUE}) NativeReadOptions options
); );
@JniMethod(cast="leveldb::Snapshot *", flags={CPP_METHOD}) @JniMethod(cast="rocksdb::Snapshot *", flags={CPP_METHOD})
static final native long GetSnapshot( static final native long GetSnapshot(
long self); long self);
@JniMethod(flags={CPP_METHOD}) @JniMethod(flags={CPP_METHOD})
static final native void ReleaseSnapshot( static final native void ReleaseSnapshot(
long self, long self,
@JniArg(cast="const leveldb::Snapshot *") long snapshot @JniArg(cast="const rocksdb::Snapshot *") long snapshot
); );
@JniMethod(flags={CPP_METHOD}) @JniMethod(flags={CPP_METHOD})
static final native void GetApproximateSizes( static final native void GetApproximateSizes(
long self, long self,
@JniArg(cast="const leveldb::Range *") long range, @JniArg(cast="const rocksdb::Range *") long range,
int n, int n,
@JniArg(cast="uint64_t*") long[] sizes @JniArg(cast="uint64_t*") long[] sizes
); );
@ -146,12 +146,12 @@ public class NativeDB extends NativeObject {
@JniArg(cast="std::string *") long value @JniArg(cast="std::string *") long value
); );
@JniMethod(copy="leveldb::Status", accessor = "leveldb::DestroyDB") @JniMethod(copy="rocksdb::Status", accessor = "rocksdb::DestroyDB")
static final native long DestroyDB( static final native long DestroyDB(
@JniArg(cast="const char*") String path, @JniArg(cast="const char*") String path,
@JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options); @JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options);
@JniMethod(copy="leveldb::Status", accessor = "leveldb::RepairDB") @JniMethod(copy="rocksdb::Status", accessor = "rocksdb::RepairDB")
static final native long RepairDB( static final native long RepairDB(
@JniArg(cast="const char*") String path, @JniArg(cast="const char*") String path,
@JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options); @JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options);

@ -38,13 +38,13 @@ import static org.fusesource.hawtjni.runtime.ArgFlag.*;
import static org.fusesource.hawtjni.runtime.ClassFlag.*; import static org.fusesource.hawtjni.runtime.ClassFlag.*;
/** /**
* Provides a java interface to the C++ leveldb::Iterator class. * Provides a java interface to the C++ rocksdb::Iterator class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */
public class NativeIterator extends NativeObject { public class NativeIterator extends NativeObject {
@JniClass(name="leveldb::Iterator", flags={CPP}) @JniClass(name="rocksdb::Iterator", flags={CPP})
private static class IteratorJNI { private static class IteratorJNI {
static { static {
NativeDB.LIBRARY.load(); NativeDB.LIBRARY.load();
@ -86,17 +86,17 @@ public class NativeIterator extends NativeObject {
long self long self
); );
@JniMethod(copy="leveldb::Slice", flags={CPP_METHOD}) @JniMethod(copy="rocksdb::Slice", flags={CPP_METHOD})
static final native long key( static final native long key(
long self long self
); );
@JniMethod(copy="leveldb::Slice", flags={CPP_METHOD}) @JniMethod(copy="rocksdb::Slice", flags={CPP_METHOD})
static final native long value( static final native long value(
long self long self
); );
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD}) @JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
static final native long status( static final native long status(
long self long self
); );

@ -46,7 +46,7 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.*;
/** /**
* <p> * <p>
* Provides a java interface to the C++ leveldb::Logger class. * Provides a java interface to the C++ rocksdb::Logger class.
* </p> * </p>
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>

@ -42,11 +42,11 @@ import static org.fusesource.hawtjni.runtime.FieldFlag.FIELD_SKIP;
import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER; import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER;
/** /**
* Provides a java interface to the C++ leveldb::Options class. * Provides a java interface to the C++ rocksdb::Options class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */
@JniClass(name="leveldb::Options", flags={STRUCT, CPP}) @JniClass(name="rocksdb::Options", flags={STRUCT, CPP})
public class NativeOptions { public class NativeOptions {
static { static {
@ -57,7 +57,7 @@ public class NativeOptions {
@JniMethod(flags={CONSTANT_INITIALIZER}) @JniMethod(flags={CONSTANT_INITIALIZER})
private static final native void init(); private static final native void init();
@JniField(flags={CONSTANT}, cast="Env*", accessor="leveldb::Env::Default()") @JniField(flags={CONSTANT}, cast="Env*", accessor="rocksdb::Env::Default()")
private static long DEFAULT_ENV; private static long DEFAULT_ENV;
private boolean create_if_missing = false; private boolean create_if_missing = false;
@ -83,7 +83,7 @@ public class NativeOptions {
@JniField(flags={FIELD_SKIP}) @JniField(flags={FIELD_SKIP})
private NativeComparator comparatorObject = NativeComparator.BYTEWISE_COMPARATOR; private NativeComparator comparatorObject = NativeComparator.BYTEWISE_COMPARATOR;
@JniField(cast="const leveldb::Comparator*") @JniField(cast="const rocksdb::Comparator*")
private long comparator = comparatorObject.pointer(); private long comparator = comparatorObject.pointer();
@JniField(cast="uint64_t") @JniField(cast="uint64_t")
@ -110,17 +110,17 @@ public class NativeOptions {
@JniField(flags={FIELD_SKIP}) @JniField(flags={FIELD_SKIP})
private NativeLogger infoLogObject = null; private NativeLogger infoLogObject = null;
@JniField(cast="leveldb::Logger*") @JniField(cast="rocksdb::Logger*")
private long info_log = 0; private long info_log = 0;
@JniField(cast="leveldb::Env*") @JniField(cast="rocksdb::Env*")
private long env = DEFAULT_ENV; private long env = DEFAULT_ENV;
@JniField(cast="leveldb::Cache*") @JniField(cast="rocksdb::Cache*")
private long block_cache = 0; private long block_cache = 0;
@JniField(flags={FIELD_SKIP}) @JniField(flags={FIELD_SKIP})
private NativeCache cache; private NativeCache cache;
@JniField(cast="leveldb::CompressionType") @JniField(cast="rocksdb::CompressionType")
private int compression = NativeCompressionType.kSnappyCompression.value; private int compression = NativeCompressionType.kSnappyCompression.value;
public NativeOptions createIfMissing(boolean value) { public NativeOptions createIfMissing(boolean value) {

@ -41,13 +41,13 @@ import static org.fusesource.hawtjni.runtime.FieldFlag.FIELD_SKIP;
import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER; import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER;
/** /**
* Provides a java interface to the C++ leveldb::ReadOptions class. * Provides a java interface to the C++ rocksdb::ReadOptions class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */
public class NativeRange { public class NativeRange {
@JniClass(name="leveldb::Range", flags={STRUCT, CPP}) @JniClass(name="rocksdb::Range", flags={STRUCT, CPP})
static public class RangeJNI { static public class RangeJNI {
static { static {
@ -69,7 +69,7 @@ public class NativeRange {
@JniMethod(flags={CONSTANT_INITIALIZER}) @JniMethod(flags={CONSTANT_INITIALIZER})
private static final native void init(); private static final native void init();
@JniField(flags={CONSTANT}, accessor="sizeof(struct leveldb::Range)") @JniField(flags={CONSTANT}, accessor="sizeof(struct rocksdb::Range)")
static int SIZEOF; static int SIZEOF;
@JniField @JniField

@ -38,11 +38,11 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.CPP;
import static org.fusesource.hawtjni.runtime.ClassFlag.STRUCT; import static org.fusesource.hawtjni.runtime.ClassFlag.STRUCT;
/** /**
* Provides a java interface to the C++ leveldb::ReadOptions class. * Provides a java interface to the C++ rocksdb::ReadOptions class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */
@JniClass(name="leveldb::ReadOptions", flags={STRUCT, CPP}) @JniClass(name="rocksdb::ReadOptions", flags={STRUCT, CPP})
public class NativeReadOptions { public class NativeReadOptions {
@JniField @JniField
@ -51,7 +51,7 @@ public class NativeReadOptions {
@JniField @JniField
private boolean fill_cache = true; private boolean fill_cache = true;
@JniField(cast="const leveldb::Snapshot*") @JniField(cast="const rocksdb::Snapshot*")
private long snapshot=0; private long snapshot=0;
public boolean fillCache() { public boolean fillCache() {

@ -41,14 +41,14 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER;
import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE; import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE;
/** /**
* Provides a java interface to the C++ leveldb::Slice class. * Provides a java interface to the C++ rocksdb::Slice class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */
@JniClass(name="leveldb::Slice", flags={STRUCT, CPP}) @JniClass(name="rocksdb::Slice", flags={STRUCT, CPP})
class NativeSlice { class NativeSlice {
@JniClass(name="leveldb::Slice", flags={CPP}) @JniClass(name="rocksdb::Slice", flags={CPP})
static class SliceJNI { static class SliceJNI {
static { static {
NativeDB.LIBRARY.load(); NativeDB.LIBRARY.load();
@ -74,7 +74,7 @@ class NativeSlice {
@JniMethod(flags={CONSTANT_INITIALIZER}) @JniMethod(flags={CONSTANT_INITIALIZER})
private static final native void init(); private static final native void init();
@JniField(flags={CONSTANT}, accessor="sizeof(struct leveldb::Slice)") @JniField(flags={CONSTANT}, accessor="sizeof(struct rocksdb::Slice)")
static int SIZEOF; static int SIZEOF;
} }

@ -32,7 +32,7 @@
package org.fusesource.leveldbjni.internal; package org.fusesource.leveldbjni.internal;
/** /**
* Provides a java interface to the C++ leveldb::Snapshot class. * Provides a java interface to the C++ rocksdb::Snapshot class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */

@ -39,13 +39,13 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE;
import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_METHOD; import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_METHOD;
/** /**
* Provides a java interface to the C++ leveldb::Status class. * Provides a java interface to the C++ rocksdb::Status class.
* *
* @author <a href="http://hiramchirino.com">Hiram Chirino</a> * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/ */
class NativeStatus extends NativeObject{ class NativeStatus extends NativeObject{
@JniClass(name="leveldb::Status", flags={CPP}) @JniClass(name="rocksdb::Status", flags={CPP})
static class StatusJNI { static class StatusJNI {
static { static {
NativeDB.LIBRARY.load(); NativeDB.LIBRARY.load();

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save