mirror of https://github.com/facebook/rocksdb.git
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
This commit is contained in:
parent
b3ed08129b
commit
a143ef9b38
|
@ -14,7 +14,7 @@
|
|||
#include "rocksdb/iterator.h"
|
||||
#include "util/stop_watch.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
Status BuildTable(const std::string& dbname,
|
||||
Env* env,
|
||||
|
@ -204,4 +204,4 @@ Status BuildTable(const std::string& dbname,
|
|||
return s;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "rocksdb/status.h"
|
||||
#include "rocksdb/types.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
struct Options;
|
||||
struct FileMetaData;
|
||||
|
@ -36,6 +36,6 @@ extern Status BuildTable(const std::string& dbname,
|
|||
const SequenceNumber newest_snapshot,
|
||||
const SequenceNumber earliest_seqno_in_memtable);
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_BUILDER_H_
|
||||
|
|
44
db/c.cc
44
db/c.cc
|
@ -16,28 +16,28 @@
|
|||
#include "rocksdb/status.h"
|
||||
#include "rocksdb/write_batch.h"
|
||||
|
||||
using leveldb::Cache;
|
||||
using leveldb::Comparator;
|
||||
using leveldb::CompressionType;
|
||||
using leveldb::DB;
|
||||
using leveldb::Env;
|
||||
using leveldb::FileLock;
|
||||
using leveldb::FilterPolicy;
|
||||
using leveldb::Iterator;
|
||||
using leveldb::Logger;
|
||||
using leveldb::NewBloomFilterPolicy;
|
||||
using leveldb::NewLRUCache;
|
||||
using leveldb::Options;
|
||||
using leveldb::RandomAccessFile;
|
||||
using leveldb::Range;
|
||||
using leveldb::ReadOptions;
|
||||
using leveldb::SequentialFile;
|
||||
using leveldb::Slice;
|
||||
using leveldb::Snapshot;
|
||||
using leveldb::Status;
|
||||
using leveldb::WritableFile;
|
||||
using leveldb::WriteBatch;
|
||||
using leveldb::WriteOptions;
|
||||
using rocksdb::Cache;
|
||||
using rocksdb::Comparator;
|
||||
using rocksdb::CompressionType;
|
||||
using rocksdb::DB;
|
||||
using rocksdb::Env;
|
||||
using rocksdb::FileLock;
|
||||
using rocksdb::FilterPolicy;
|
||||
using rocksdb::Iterator;
|
||||
using rocksdb::Logger;
|
||||
using rocksdb::NewBloomFilterPolicy;
|
||||
using rocksdb::NewLRUCache;
|
||||
using rocksdb::Options;
|
||||
using rocksdb::RandomAccessFile;
|
||||
using rocksdb::Range;
|
||||
using rocksdb::ReadOptions;
|
||||
using rocksdb::SequentialFile;
|
||||
using rocksdb::Slice;
|
||||
using rocksdb::Snapshot;
|
||||
using rocksdb::Status;
|
||||
using rocksdb::WritableFile;
|
||||
using rocksdb::WriteBatch;
|
||||
using rocksdb::WriteOptions;
|
||||
|
||||
using std::shared_ptr;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "util/testharness.h"
|
||||
#include "util/testutil.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static const int kValueSize = 1000;
|
||||
|
||||
|
@ -68,7 +68,7 @@ class CorruptionTest {
|
|||
void RepairDB() {
|
||||
delete db_;
|
||||
db_ = nullptr;
|
||||
ASSERT_OK(::leveldb::RepairDB(dbname_, options_));
|
||||
ASSERT_OK(::rocksdb::RepairDB(dbname_, options_));
|
||||
}
|
||||
|
||||
void Build(int n) {
|
||||
|
@ -354,8 +354,8 @@ TEST(CorruptionTest, UnrelatedKeys) {
|
|||
ASSERT_EQ(Value(1000, &tmp2).ToString(), v);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
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;
|
||||
|
||||
// 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
|
||||
// (for universal compaction only).
|
||||
|
@ -201,7 +201,7 @@ static bool FLAGS_verify_checksum = false;
|
|||
|
||||
// Database statistics
|
||||
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.
|
||||
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;
|
||||
|
||||
// Algorithm used to compress the database
|
||||
static enum leveldb::CompressionType FLAGS_compression_type =
|
||||
leveldb::kSnappyCompression;
|
||||
static enum rocksdb::CompressionType FLAGS_compression_type =
|
||||
rocksdb::kSnappyCompression;
|
||||
|
||||
// If non-negative, compression starts from this level. Levels with number
|
||||
// < 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;
|
||||
|
||||
// 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
|
||||
// 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
|
||||
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
|
||||
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
|
||||
static bool FLAGS_use_multiget = false;
|
||||
|
@ -358,13 +358,13 @@ static bool FLAGS_warn_missing_keys = true;
|
|||
|
||||
// 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
|
||||
// written, in the background. Issue one request for every bytes_per_sync
|
||||
// written. 0 turns it off.
|
||||
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
|
||||
static bool FLAGS_filter_deletes = false;
|
||||
|
@ -387,9 +387,9 @@ static enum RepFactory FLAGS_rep_factory;
|
|||
static std::string FLAGS_merge_operator = "";
|
||||
|
||||
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.
|
||||
class RandomGenerator {
|
||||
|
@ -691,16 +691,16 @@ class Benchmark {
|
|||
fprintf(stdout, "Write rate limit: %d\n", FLAGS_writes_per_second);
|
||||
|
||||
switch (FLAGS_compression_type) {
|
||||
case leveldb::kNoCompression:
|
||||
case rocksdb::kNoCompression:
|
||||
fprintf(stdout, "Compression: none\n");
|
||||
break;
|
||||
case leveldb::kSnappyCompression:
|
||||
case rocksdb::kSnappyCompression:
|
||||
fprintf(stdout, "Compression: snappy\n");
|
||||
break;
|
||||
case leveldb::kZlibCompression:
|
||||
case rocksdb::kZlibCompression:
|
||||
fprintf(stdout, "Compression: zlib\n");
|
||||
break;
|
||||
case leveldb::kBZip2Compression:
|
||||
case rocksdb::kBZip2Compression:
|
||||
fprintf(stdout, "Compression: bzip2\n");
|
||||
break;
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ class Benchmark {
|
|||
"WARNING: Assertions are enabled; benchmarks unnecessarily slow\n");
|
||||
#endif
|
||||
|
||||
if (FLAGS_compression_type != leveldb::kNoCompression) {
|
||||
if (FLAGS_compression_type != rocksdb::kNoCompression) {
|
||||
// The test string should not be too small.
|
||||
const int len = FLAGS_block_size;
|
||||
char* text = (char*) malloc(len+1);
|
||||
|
@ -2303,24 +2303,24 @@ class Benchmark {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
leveldb::InstallStackTraceHandler();
|
||||
rocksdb::InstallStackTraceHandler();
|
||||
|
||||
FLAGS_write_buffer_size = leveldb::Options().write_buffer_size;
|
||||
FLAGS_max_write_buffer_number = leveldb::Options().max_write_buffer_number;
|
||||
FLAGS_write_buffer_size = rocksdb::Options().write_buffer_size;
|
||||
FLAGS_max_write_buffer_number = rocksdb::Options().max_write_buffer_number;
|
||||
FLAGS_min_write_buffer_number_to_merge =
|
||||
leveldb::Options().min_write_buffer_number_to_merge;
|
||||
FLAGS_open_files = leveldb::Options().max_open_files;
|
||||
rocksdb::Options().min_write_buffer_number_to_merge;
|
||||
FLAGS_open_files = rocksdb::Options().max_open_files;
|
||||
FLAGS_max_background_compactions =
|
||||
leveldb::Options().max_background_compactions;
|
||||
FLAGS_compaction_style = leveldb::Options().compaction_style;
|
||||
rocksdb::Options().max_background_compactions;
|
||||
FLAGS_compaction_style = rocksdb::Options().compaction_style;
|
||||
// Compression test code above refers to FLAGS_block_size
|
||||
FLAGS_block_size = leveldb::Options().block_size;
|
||||
FLAGS_use_os_buffer = leveldb::EnvOptions().use_os_buffer;
|
||||
FLAGS_use_mmap_reads = leveldb::EnvOptions().use_mmap_reads;
|
||||
FLAGS_use_mmap_writes = leveldb::EnvOptions().use_mmap_writes;
|
||||
FLAGS_block_size = rocksdb::Options().block_size;
|
||||
FLAGS_use_os_buffer = rocksdb::EnvOptions().use_os_buffer;
|
||||
FLAGS_use_mmap_reads = rocksdb::EnvOptions().use_mmap_reads;
|
||||
FLAGS_use_mmap_writes = rocksdb::EnvOptions().use_mmap_writes;
|
||||
|
||||
std::string default_db_path;
|
||||
|
||||
|
@ -2333,7 +2333,7 @@ int main(int argc, char** argv) {
|
|||
char buf[2048];
|
||||
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=");
|
||||
} else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) {
|
||||
FLAGS_compression_ratio = d;
|
||||
|
@ -2384,7 +2384,7 @@ int main(int argc, char** argv) {
|
|||
== 1) {
|
||||
FLAGS_max_background_compactions = n;
|
||||
} 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) {
|
||||
FLAGS_cache_size = l;
|
||||
} 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 &&
|
||||
(n == 0 || n == 1)) {
|
||||
if (n == 1) {
|
||||
dbstats = leveldb::CreateDBStatistics();
|
||||
dbstats = rocksdb::CreateDBStatistics();
|
||||
FLAGS_statistics = true;
|
||||
}
|
||||
} 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)) {
|
||||
FLAGS_get_approx = n;
|
||||
} 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",
|
||||
&n, &junk) == 1) {
|
||||
FLAGS_num_levels = n;
|
||||
|
@ -2478,7 +2478,7 @@ int main(int argc, char** argv) {
|
|||
} else if (sscanf(argv[i],
|
||||
"--max_bytes_for_level_multiplier_additional=%s%c",
|
||||
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++) {
|
||||
FLAGS_max_bytes_for_level_multiplier_additional.push_back(
|
||||
std::stoi(fanout[j]));
|
||||
|
@ -2492,13 +2492,13 @@ int main(int argc, char** argv) {
|
|||
} else if (strncmp(argv[i], "--compression_type=", 19) == 0) {
|
||||
const char* ctype = argv[i] + 19;
|
||||
if (!strcasecmp(ctype, "none"))
|
||||
FLAGS_compression_type = leveldb::kNoCompression;
|
||||
FLAGS_compression_type = rocksdb::kNoCompression;
|
||||
else if (!strcasecmp(ctype, "snappy"))
|
||||
FLAGS_compression_type = leveldb::kSnappyCompression;
|
||||
FLAGS_compression_type = rocksdb::kSnappyCompression;
|
||||
else if (!strcasecmp(ctype, "zlib"))
|
||||
FLAGS_compression_type = leveldb::kZlibCompression;
|
||||
FLAGS_compression_type = rocksdb::kZlibCompression;
|
||||
else if (!strcasecmp(ctype, "bzip2"))
|
||||
FLAGS_compression_type = leveldb::kBZip2Compression;
|
||||
FLAGS_compression_type = rocksdb::kBZip2Compression;
|
||||
else {
|
||||
fprintf(stdout, "Cannot parse %s\n", argv[i]);
|
||||
}
|
||||
|
@ -2561,13 +2561,13 @@ int main(int argc, char** argv) {
|
|||
FLAGS_advise_random_on_open = n;
|
||||
} else if (sscanf(argv[i], "--compaction_fadvice=%s", buf) == 1) {
|
||||
if (!strcasecmp(buf, "NONE"))
|
||||
FLAGS_compaction_fadvice = leveldb::Options::NONE;
|
||||
FLAGS_compaction_fadvice = rocksdb::Options::NONE;
|
||||
else if (!strcasecmp(buf, "NORMAL"))
|
||||
FLAGS_compaction_fadvice = leveldb::Options::NORMAL;
|
||||
FLAGS_compaction_fadvice = rocksdb::Options::NORMAL;
|
||||
else if (!strcasecmp(buf, "SEQUENTIAL"))
|
||||
FLAGS_compaction_fadvice = leveldb::Options::SEQUENTIAL;
|
||||
FLAGS_compaction_fadvice = rocksdb::Options::SEQUENTIAL;
|
||||
else if (!strcasecmp(buf, "WILLNEED"))
|
||||
FLAGS_compaction_fadvice = leveldb::Options::WILLNEED;
|
||||
FLAGS_compaction_fadvice = rocksdb::Options::WILLNEED;
|
||||
else {
|
||||
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>
|
||||
if (FLAGS_db == nullptr) {
|
||||
leveldb::Env::Default()->GetTestDirectory(&default_db_path);
|
||||
rocksdb::Env::Default()->GetTestDirectory(&default_db_path);
|
||||
default_db_path += "/dbbench";
|
||||
FLAGS_db = default_db_path.c_str();
|
||||
}
|
||||
|
||||
leveldb::Benchmark benchmark;
|
||||
rocksdb::Benchmark benchmark;
|
||||
benchmark.Run();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "port/port.h"
|
||||
#include "util/mutexlock.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
Status DBImpl::DisableFileDeletions() {
|
||||
MutexLock l(&mutex_);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "util/mutexlock.h"
|
||||
#include "util/stop_watch.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
void dumpLeveldbBuildVersion(Logger * log);
|
||||
|
||||
|
@ -3294,4 +3294,4 @@ void dumpLeveldbBuildVersion(Logger * log) {
|
|||
leveldb_build_compile_time, leveldb_build_compile_date);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "scribe/scribe_logger.h"
|
||||
#endif
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class MemTable;
|
||||
class TableCache;
|
||||
|
@ -444,6 +444,6 @@ extern Options SanitizeOptions(const std::string& db,
|
|||
const InternalFilterPolicy* ipolicy,
|
||||
const Options& src);
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_DB_IMPL_H_
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "util/logging.h"
|
||||
#include "util/build_version.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
DBImplReadOnly::DBImplReadOnly(const Options& options,
|
||||
const std::string& dbname)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "scribe/scribe_logger.h"
|
||||
#endif
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class DBImplReadOnly : public DBImpl {
|
||||
public:
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "util/mutexlock.h"
|
||||
#include "util/perf_context_imp.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
#if 0
|
||||
static void DumpInternalIter(Iterator* iter) {
|
||||
|
@ -471,4 +471,4 @@ Iterator* NewDBIterator(
|
|||
internal_iter, sequence);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "rocksdb/db.h"
|
||||
#include "db/dbformat.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// Return a new iterator that converts internal keys (yielded by
|
||||
// "*internal_iter") that were live at the specified "sequence" number
|
||||
|
@ -22,6 +22,6 @@ extern Iterator* NewDBIterator(
|
|||
Iterator* internal_iter,
|
||||
const SequenceNumber& sequence);
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_DB_ITER_H_
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "util/mutexlock.h"
|
||||
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class DBStatistics: public Statistics {
|
||||
public:
|
||||
|
@ -59,6 +59,6 @@ std::shared_ptr<Statistics> CreateDBStatistics() {
|
|||
return std::make_shared<DBStatistics>();
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // LEVELDB_STORAGE_DB_DB_STATISTICS_H_
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "port/port.h"
|
||||
#include "util/mutexlock.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
void DBImpl::MaybeScheduleLogDBDeployStats() {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "util/testutil.h"
|
||||
#include "utilities/merge_operators.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static bool SnappyCompressionSupported(const CompressionOptions& options) {
|
||||
std::string out;
|
||||
|
@ -831,7 +831,7 @@ TEST(DBTest, KeyMayExist) {
|
|||
std::string value;
|
||||
Options options = CurrentOptions();
|
||||
options.filter_policy = NewBloomFilterPolicy(20);
|
||||
options.statistics = leveldb::CreateDBStatistics();
|
||||
options.statistics = rocksdb::CreateDBStatistics();
|
||||
Reopen(&options);
|
||||
|
||||
ASSERT_TRUE(!db_->KeyMayExist(ropts, "a", &value));
|
||||
|
@ -892,7 +892,7 @@ TEST(DBTest, NonBlockingIteration) {
|
|||
do {
|
||||
ReadOptions non_blocking_opts, regular_opts;
|
||||
Options options = CurrentOptions();
|
||||
options.statistics = leveldb::CreateDBStatistics();
|
||||
options.statistics = rocksdb::CreateDBStatistics();
|
||||
non_blocking_opts.read_tier = kBlockCacheTier;
|
||||
Reopen(&options);
|
||||
|
||||
|
@ -1140,7 +1140,7 @@ TEST(DBTest, IterReseek) {
|
|||
Options options = CurrentOptions();
|
||||
options.max_sequential_skip_in_iterations = 3;
|
||||
options.create_if_missing = true;
|
||||
options.statistics = leveldb::CreateDBStatistics();
|
||||
options.statistics = rocksdb::CreateDBStatistics();
|
||||
DestroyAndReopen(&options);
|
||||
|
||||
// insert two keys with same userkey and verify that
|
||||
|
@ -3858,7 +3858,7 @@ class ModelDB: public DB {
|
|||
return -1;
|
||||
}
|
||||
|
||||
virtual Status Flush(const leveldb::FlushOptions& options) {
|
||||
virtual Status Flush(const rocksdb::FlushOptions& options) {
|
||||
Status ret;
|
||||
return ret;
|
||||
}
|
||||
|
@ -3885,8 +3885,8 @@ class ModelDB: public DB {
|
|||
virtual SequenceNumber GetLatestSequenceNumber() {
|
||||
return 0;
|
||||
}
|
||||
virtual Status GetUpdatesSince(leveldb::SequenceNumber,
|
||||
unique_ptr<leveldb::TransactionLogIterator>*) {
|
||||
virtual Status GetUpdatesSince(rocksdb::SequenceNumber,
|
||||
unique_ptr<rocksdb::TransactionLogIterator>*) {
|
||||
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);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc > 1 && std::string(argv[1]) == "--benchmark") {
|
||||
leveldb::BM_LogAndApply(1000, 1);
|
||||
leveldb::BM_LogAndApply(1000, 100);
|
||||
leveldb::BM_LogAndApply(1000, 10000);
|
||||
leveldb::BM_LogAndApply(100, 100000);
|
||||
rocksdb::BM_LogAndApply(1000, 1);
|
||||
rocksdb::BM_LogAndApply(1000, 100);
|
||||
rocksdb::BM_LogAndApply(1000, 10000);
|
||||
rocksdb::BM_LogAndApply(100, 100000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "util/coding.h"
|
||||
#include "util/perf_context_imp.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static uint64_t PackSequenceAndType(uint64_t seq, ValueType t) {
|
||||
assert(seq <= kMaxSequenceNumber);
|
||||
|
@ -139,4 +139,4 @@ LookupKey::LookupKey(const Slice& user_key, SequenceNumber s) {
|
|||
end_ = dst;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "util/coding.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class InternalKey;
|
||||
|
||||
|
@ -223,6 +223,6 @@ inline LookupKey::~LookupKey() {
|
|||
if (start_ != space_) delete[] start_;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_FORMAT_H_
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "util/logging.h"
|
||||
#include "util/testharness.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static std::string IKey(const std::string& user_key,
|
||||
uint64_t seq,
|
||||
|
@ -105,8 +105,8 @@ TEST(FormatTest, InternalKeyShortestSuccessor) {
|
|||
ShortSuccessor(IKey("\xff\xff", 100, kTypeValue)));
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <map>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class DeleteFileTest {
|
||||
public:
|
||||
|
@ -180,9 +180,9 @@ TEST(DeleteFileTest, DeleteFileWithIterator) {
|
|||
delete it;
|
||||
CloseDB();
|
||||
}
|
||||
} //namespace leveldb
|
||||
} //namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "rocksdb/env.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// 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.
|
||||
|
@ -218,4 +218,4 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
|
|||
return s;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "rocksdb/status.h"
|
||||
#include "port/port.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Env;
|
||||
|
||||
|
@ -92,6 +92,6 @@ extern Status SetCurrentFile(Env* env, const std::string& dbname,
|
|||
uint64_t descriptor_number);
|
||||
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_FILENAME_H_
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "util/logging.h"
|
||||
#include "util/testharness.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class FileNameTest { };
|
||||
|
||||
|
@ -128,8 +128,8 @@ TEST(FileNameTest, Construction) {
|
|||
ASSERT_EQ(kMetaDatabase, type);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
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_
|
||||
#define STORAGE_LEVELDB_DB_LOG_FORMAT_H_
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
namespace log {
|
||||
|
||||
enum RecordType {
|
||||
|
@ -30,6 +30,6 @@ static const unsigned int kBlockSize = 32768;
|
|||
static const int kHeaderSize = 4 + 1 + 2;
|
||||
|
||||
} // namespace log
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_LOG_FORMAT_H_
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "util/coding.h"
|
||||
#include "util/crc32c.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
namespace log {
|
||||
|
||||
Reader::Reporter::~Reporter() {
|
||||
|
@ -256,4 +256,4 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result) {
|
|||
}
|
||||
|
||||
} // namespace log
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "rocksdb/slice.h"
|
||||
#include "rocksdb/status.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class SequentialFile;
|
||||
using std::unique_ptr;
|
||||
|
@ -118,6 +118,6 @@ class Reader {
|
|||
};
|
||||
|
||||
} // namespace log
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_LOG_READER_H_
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "util/random.h"
|
||||
#include "util/testharness.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
namespace log {
|
||||
|
||||
// Construct a string of the specified length made out of the supplied
|
||||
|
@ -516,8 +516,8 @@ TEST(LogTest, ReadPastEnd) {
|
|||
}
|
||||
|
||||
} // namespace log
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "util/coding.h"
|
||||
#include "util/crc32c.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
namespace log {
|
||||
|
||||
Writer::Writer(unique_ptr<WritableFile>&& dest)
|
||||
|
@ -100,4 +100,4 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) {
|
|||
}
|
||||
|
||||
} // namespace log
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "rocksdb/slice.h"
|
||||
#include "rocksdb/status.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class WritableFile;
|
||||
|
||||
|
@ -49,6 +49,6 @@ class Writer {
|
|||
};
|
||||
|
||||
} // namespace log
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "util/coding.h"
|
||||
#include "util/murmurhash.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
MemTable::MemTable(const InternalKeyComparator& cmp,
|
||||
std::shared_ptr<MemTableRepFactory> table_factory,
|
||||
|
@ -238,4 +238,4 @@ bool MemTable::Get(const LookupKey& key, std::string* value, Status* s,
|
|||
return false;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "rocksdb/memtablerep.h"
|
||||
#include "util/arena_impl.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Mutex;
|
||||
class MemTableIterator;
|
||||
|
@ -146,6 +146,6 @@ class MemTable {
|
|||
void operator=(const MemTable&);
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_MEMTABLE_H_
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "rocksdb/iterator.h"
|
||||
#include "util/coding.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class InternalKeyComparator;
|
||||
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 "memtable.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class InternalKeyComparator;
|
||||
class Mutex;
|
||||
|
@ -99,6 +99,6 @@ class MemTableList {
|
|||
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_MEMTABLELIST_H_
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// PRE: iter points to the first merge type entry
|
||||
// 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 <deque>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Comparator;
|
||||
class Iterator;
|
||||
|
@ -93,6 +93,6 @@ class MergeHelper {
|
|||
bool success_;
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "rocksdb/merge_operator.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// Given a "real" merge from the library, call the user's
|
||||
// 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);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "utilities/utility_db.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace leveldb;
|
||||
using namespace rocksdb;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
// 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::string s;
|
||||
// std::cin >> s;
|
||||
|
@ -30,7 +30,7 @@ void SeekToFirst(leveldb::Iterator* iter) {
|
|||
// std::cin >> s2;
|
||||
}
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
std::shared_ptr<DB> OpenDb() {
|
||||
DB* db;
|
||||
|
@ -42,9 +42,9 @@ std::shared_ptr<DB> OpenDb() {
|
|||
FLAGS_min_write_buffer_number_to_merge;
|
||||
|
||||
if (FLAGS_use_set_based_memetable) {
|
||||
auto prefix_extractor = leveldb::NewFixedPrefixTransform(0);
|
||||
auto prefix_extractor = rocksdb::NewFixedPrefixTransform(0);
|
||||
options.memtable_factory =
|
||||
std::make_shared<leveldb::PrefixHashRepFactory>(prefix_extractor);
|
||||
std::make_shared<rocksdb::PrefixHashRepFactory>(prefix_extractor);
|
||||
}
|
||||
|
||||
Status s = DB::Open(options, kDbName, &db);
|
||||
|
@ -315,6 +315,6 @@ int main(int argc, char** argv) {
|
|||
|
||||
std::cout << kDbName << "\n";
|
||||
|
||||
leveldb::test::RunAllTests();
|
||||
rocksdb::test::RunAllTests();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "rocksdb/iterator.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class PrefixFilterIterator : public Iterator {
|
||||
private:
|
||||
|
@ -71,6 +71,6 @@ class PrefixFilterIterator : public Iterator {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "rocksdb/db.h"
|
||||
#include "rocksdb/env.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -383,4 +383,4 @@ Status RepairDB(const std::string& dbname, const Options& options) {
|
|||
return repairer.Run();
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "port/port.h"
|
||||
#include "util/random.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
template<typename Key, class Comparator>
|
||||
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_
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "util/random.h"
|
||||
#include "util/testharness.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
typedef uint64_t Key;
|
||||
|
||||
|
@ -371,8 +371,8 @@ TEST(SkipTest, Concurrent3) { RunConcurrent(3); }
|
|||
TEST(SkipTest, Concurrent4) { RunConcurrent(4); }
|
||||
TEST(SkipTest, Concurrent5) { RunConcurrent(5); }
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "rocksdb/db.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class SnapshotList;
|
||||
|
||||
|
@ -80,6 +80,6 @@ class SnapshotList {
|
|||
SnapshotImpl list_;
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_SNAPSHOT_H_
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "util/coding.h"
|
||||
#include "util/stop_watch.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static void DeleteEntry(const Slice& key, void* value) {
|
||||
Table* table = reinterpret_cast<Table*>(value);
|
||||
|
@ -160,4 +160,4 @@ void TableCache::Evict(uint64_t file_number) {
|
|||
cache_->Erase(Slice(buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "port/port.h"
|
||||
#include "table/table.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Env;
|
||||
|
||||
|
@ -72,6 +72,6 @@ class TableCache {
|
|||
const bool no_io = false);
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "db/transaction_log_impl.h"
|
||||
#include "db/write_batch_internal.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
TransactionLogIteratorImpl::TransactionLogIteratorImpl(
|
||||
const std::string& dbname,
|
||||
|
@ -168,4 +168,4 @@ Status TransactionLogIteratorImpl::OpenLogReader(const LogFile* logFile) {
|
|||
);
|
||||
return Status::OK();
|
||||
}
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "db/log_reader.h"
|
||||
#include "db/filename.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
struct LogReporter : public log::Reader::Reporter {
|
||||
Env* env;
|
||||
|
@ -99,5 +99,5 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
|
|||
|
||||
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
#endif // STORAGE_LEVELDB_INCLUDE_WRITES_ITERATOR_IMPL_H_
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "db/version_set.h"
|
||||
#include "util/coding.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// Tag numbers for serialized VersionEdit. These numbers are written to
|
||||
// disk and should not be changed.
|
||||
|
@ -293,4 +293,4 @@ std::string VersionEdit::DebugString(bool hex_key) const {
|
|||
return r;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <vector>
|
||||
#include "db/dbformat.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class VersionSet;
|
||||
|
||||
|
@ -122,6 +122,6 @@ class VersionEdit {
|
|||
std::vector< std::pair<int, FileMetaData> > new_files_;
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_VERSION_EDIT_H_
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "db/version_edit.h"
|
||||
#include "util/testharness.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static void TestEncodeDecode(const VersionEdit& edit) {
|
||||
std::string encoded, encoded2;
|
||||
|
@ -41,8 +41,8 @@ TEST(VersionEditTest, EncodeDecode) {
|
|||
TestEncodeDecode(edit);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "util/logging.h"
|
||||
#include "util/stop_watch.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static uint64_t TotalFileSize(const std::vector<FileMetaData*>& files) {
|
||||
uint64_t sum = 0;
|
||||
|
@ -3055,4 +3055,4 @@ void Compaction::Summary(char* output, int len) {
|
|||
level_low_summary, level_up_summary);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "port/port.h"
|
||||
#include "db/table_cache.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
namespace log { class Writer; }
|
||||
|
||||
|
@ -627,6 +627,6 @@ class Compaction {
|
|||
void ResetNextCompactionIndex();
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_VERSION_SET_H_
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "db/log_writer.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
Status VersionSet::ReduceNumberOfLevels(int new_levels, port::Mutex* mu) {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "util/testharness.h"
|
||||
#include "util/testutil.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class FindFileTest {
|
||||
public:
|
||||
|
@ -172,8 +172,8 @@ TEST(FindFileTest, OverlappingFiles) {
|
|||
ASSERT_TRUE(Overlaps("600", "700"));
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "util/coding.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// WriteBatch header has an 8-byte sequence number followed by a 4-byte count.
|
||||
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);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "rocksdb/db.h"
|
||||
#include "rocksdb/options.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class MemTable;
|
||||
|
||||
|
@ -51,7 +51,7 @@ class WriteBatchInternal {
|
|||
static void Append(WriteBatch* dst, const WriteBatch* src);
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
|
||||
#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "util/logging.h"
|
||||
#include "util/testharness.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static std::string PrintContents(WriteBatch* b) {
|
||||
InternalKeyComparator cmp(BytewiseComparator());
|
||||
|
@ -221,8 +221,8 @@ TEST(WriteBatchTest, Continue) {
|
|||
handler.seen);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
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.
|
||||
namespace {
|
||||
|
@ -664,7 +664,7 @@ class Benchmark {
|
|||
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string default_db_path;
|
||||
|
@ -672,7 +672,7 @@ int main(int argc, char** argv) {
|
|||
double d;
|
||||
int n;
|
||||
char junk;
|
||||
if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) {
|
||||
if (rocksdb::Slice(argv[i]).starts_with("--benchmarks=")) {
|
||||
FLAGS_benchmarks = argv[i] + strlen("--benchmarks=");
|
||||
} else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 &&
|
||||
(n == 0 || n == 1)) {
|
||||
|
@ -688,7 +688,7 @@ int main(int argc, char** argv) {
|
|||
FLAGS_reads = n;
|
||||
} else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) {
|
||||
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;
|
||||
} else if (sscanf(argv[i], "--page_size=%d%c", &n, &junk) == 1) {
|
||||
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>
|
||||
if (FLAGS_db == NULL) {
|
||||
leveldb::Env::Default()->GetTestDirectory(&default_db_path);
|
||||
rocksdb::Env::Default()->GetTestDirectory(&default_db_path);
|
||||
default_db_path += "/dbbench";
|
||||
FLAGS_db = default_db_path.c_str();
|
||||
}
|
||||
|
||||
leveldb::Benchmark benchmark;
|
||||
rocksdb::Benchmark benchmark;
|
||||
benchmark.Run();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ static void DBSynchronize(kyotocabinet::TreeDB* db_)
|
|||
}
|
||||
}
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// Helper for quickly generating random data.
|
||||
namespace {
|
||||
|
@ -479,7 +479,7 @@ class Benchmark {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string default_db_path;
|
||||
|
@ -487,7 +487,7 @@ int main(int argc, char** argv) {
|
|||
double d;
|
||||
int n;
|
||||
char junk;
|
||||
if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) {
|
||||
if (rocksdb::Slice(argv[i]).starts_with("--benchmarks=")) {
|
||||
FLAGS_benchmarks = argv[i] + strlen("--benchmarks=");
|
||||
} else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) {
|
||||
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>
|
||||
if (FLAGS_db == NULL) {
|
||||
leveldb::Env::Default()->GetTestDirectory(&default_db_path);
|
||||
rocksdb::Env::Default()->GetTestDirectory(&default_db_path);
|
||||
default_db_path += "/dbbench";
|
||||
FLAGS_db = default_db_path.c_str();
|
||||
}
|
||||
|
||||
leveldb::Benchmark benchmark;
|
||||
rocksdb::Benchmark benchmark;
|
||||
benchmark.Run();
|
||||
return 0;
|
||||
}
|
||||
|
|
104
doc/index.html
104
doc/index.html
|
@ -25,27 +25,27 @@ creating it if necessary:
|
|||
#include <assert>
|
||||
#include "leveldb/db.h"
|
||||
|
||||
leveldb::DB* db;
|
||||
leveldb::Options options;
|
||||
rocksdb::DB* db;
|
||||
rocksdb::Options options;
|
||||
options.create_if_missing = true;
|
||||
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
|
||||
rocksdb::Status status = rocksdb::DB::Open(options, "/tmp/testdb", &db);
|
||||
assert(status.ok());
|
||||
...
|
||||
</pre>
|
||||
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>
|
||||
options.error_if_exists = true;
|
||||
</pre>
|
||||
<h1>Status</h1>
|
||||
<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
|
||||
error. You can check if such a result is ok, and also print an
|
||||
associated error message:
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::Status s = ...;
|
||||
rocksdb::Status s = ...;
|
||||
if (!s.ok()) cerr << s.ToString() << endl;
|
||||
</pre>
|
||||
<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.
|
||||
<pre>
|
||||
std::string value;
|
||||
leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
|
||||
if (s.ok()) s = db->Put(leveldb::WriteOptions(), key2, value);
|
||||
if (s.ok()) s = db->Delete(leveldb::WriteOptions(), key1);
|
||||
rocksdb::Status s = db->Get(rocksdb::ReadOptions(), key1, &value);
|
||||
if (s.ok()) s = db->Put(rocksdb::WriteOptions(), key2, value);
|
||||
if (s.ok()) s = db->Delete(rocksdb::WriteOptions(), key1);
|
||||
</pre>
|
||||
|
||||
<h1>Atomic Updates</h1>
|
||||
|
@ -81,12 +81,12 @@ atomically apply a set of updates:
|
|||
#include "leveldb/write_batch.h"
|
||||
...
|
||||
std::string value;
|
||||
leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
|
||||
rocksdb::Status s = db->Get(rocksdb::ReadOptions(), key1, &value);
|
||||
if (s.ok()) {
|
||||
leveldb::WriteBatch batch;
|
||||
rocksdb::WriteBatch batch;
|
||||
batch.Delete(key1);
|
||||
batch.Put(key2, value);
|
||||
s = db->Write(leveldb::WriteOptions(), &batch);
|
||||
s = db->Write(rocksdb::WriteOptions(), &batch);
|
||||
}
|
||||
</pre>
|
||||
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
|
||||
<code>msync(..., MS_SYNC)</code> before the write operation returns.)
|
||||
<pre>
|
||||
leveldb::WriteOptions write_options;
|
||||
rocksdb::WriteOptions write_options;
|
||||
write_options.sync = true;
|
||||
db->Put(write_options, ...);
|
||||
</pre>
|
||||
|
@ -144,7 +144,7 @@ the batch.
|
|||
A database may only be opened by one process at a time.
|
||||
The <code>leveldb</code> implementation acquires a lock from 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
|
||||
iterators or call <code>Get</code> on the same database without any
|
||||
external synchronization (the leveldb implementation will
|
||||
|
@ -160,7 +160,7 @@ The following example demonstrates how to print all key,value pairs
|
|||
in a database.
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
|
||||
rocksdb::Iterator* it = db->NewIterator(rocksdb::ReadOptions());
|
||||
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
||||
cout << it->key().ToString() << ": " << it->value().ToString() << endl;
|
||||
}
|
||||
|
@ -196,10 +196,10 @@ implicit snapshot of the current state.
|
|||
Snapshots are created by the DB::GetSnapshot() method:
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::ReadOptions options;
|
||||
rocksdb::ReadOptions options;
|
||||
options.snapshot = db->GetSnapshot();
|
||||
... apply some updates to db ...
|
||||
leveldb::Iterator* iter = db->NewIterator(options);
|
||||
rocksdb::Iterator* iter = db->NewIterator(options);
|
||||
... read using iter to view the state when the snapshot was created ...
|
||||
delete iter;
|
||||
db->ReleaseSnapshot(options.snapshot);
|
||||
|
@ -211,7 +211,7 @@ support reading as of that snapshot.
|
|||
<h1>Slice</h1>
|
||||
<p>
|
||||
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
|
||||
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
|
||||
|
@ -223,10 +223,10 @@ C++ strings and null-terminated C-style strings can be easily converted
|
|||
to a Slice:
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::Slice s1 = "hello";
|
||||
rocksdb::Slice s1 = "hello";
|
||||
|
||||
std::string str("world");
|
||||
leveldb::Slice s2 = str;
|
||||
rocksdb::Slice s2 = str;
|
||||
</pre>
|
||||
A Slice can be easily converted back to a C++ string:
|
||||
<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:
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::Slice slice;
|
||||
rocksdb::Slice slice;
|
||||
if (...) {
|
||||
std::string 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
|
||||
database key consists of two numbers and we should sort by the first
|
||||
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>
|
||||
<pre>
|
||||
class TwoPartComparator : public leveldb::Comparator {
|
||||
class TwoPartComparator : public rocksdb::Comparator {
|
||||
public:
|
||||
// Three-way comparison function:
|
||||
// if a < b: negative result
|
||||
// if a > b: positive result
|
||||
// else: zero result
|
||||
int Compare(const leveldb::Slice& a, const leveldb::Slice& b) const {
|
||||
int Compare(const rocksdb::Slice& a, const rocksdb::Slice& b) const {
|
||||
int a1, a2, b1, b2;
|
||||
ParseKey(a, &a1, &a2);
|
||||
ParseKey(b, &b1, &b2);
|
||||
|
@ -277,7 +277,7 @@ subclass of <code>leveldb::Comparator</code> that expresses these rules:
|
|||
|
||||
// Ignore the following methods for now:
|
||||
const char* Name() const { return "TwoPartComparator"; }
|
||||
void FindShortestSeparator(std::string*, const leveldb::Slice&) const { }
|
||||
void FindShortestSeparator(std::string*, const rocksdb::Slice&) const { }
|
||||
void FindShortSuccessor(std::string*) const { }
|
||||
};
|
||||
</pre>
|
||||
|
@ -285,18 +285,18 @@ Now create a database using this custom comparator:
|
|||
<p>
|
||||
<pre>
|
||||
TwoPartComparator cmp;
|
||||
leveldb::DB* db;
|
||||
leveldb::Options options;
|
||||
rocksdb::DB* db;
|
||||
rocksdb::Options options;
|
||||
options.create_if_missing = true;
|
||||
options.comparator = &cmp;
|
||||
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
|
||||
rocksdb::Status status = rocksdb::DB::Open(options, "/tmp/testdb", &db);
|
||||
...
|
||||
</pre>
|
||||
<h2>Backwards compatibility</h2>
|
||||
<p>
|
||||
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 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
|
||||
and comparison function are incompatible with existing databases, and
|
||||
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:
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::Options options;
|
||||
options.compression = leveldb::kNoCompression;
|
||||
... leveldb::DB::Open(options, name, ...) ....
|
||||
rocksdb::Options options;
|
||||
options.compression = rocksdb::kNoCompression;
|
||||
... rocksdb::DB::Open(options, name, ...) ....
|
||||
</pre>
|
||||
<h2>Cache</h2>
|
||||
<p>
|
||||
|
@ -353,10 +353,10 @@ uncompressed block contents.
|
|||
<pre>
|
||||
#include "leveldb/cache.h"
|
||||
|
||||
leveldb::Options options;
|
||||
options.cache = leveldb::NewLRUCache(100 * 1048576); // 100MB cache
|
||||
leveldb::DB* db;
|
||||
leveldb::DB::Open(options, name, &db);
|
||||
rocksdb::Options options;
|
||||
options.cache = rocksdb::NewLRUCache(100 * 1048576); // 100MB cache
|
||||
rocksdb::DB* db;
|
||||
rocksdb::DB::Open(options, name, &db);
|
||||
... use the db ...
|
||||
delete db
|
||||
delete options.cache;
|
||||
|
@ -373,9 +373,9 @@ displacing most of the cached contents. A per-iterator option can be
|
|||
used to achieve this:
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::ReadOptions options;
|
||||
rocksdb::ReadOptions options;
|
||||
options.fill_cache = false;
|
||||
leveldb::Iterator* it = db->NewIterator(options);
|
||||
rocksdb::Iterator* it = db->NewIterator(options);
|
||||
for (it->SeekToFirst(); it->Valid(); it->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 number of disk reads substantially.
|
||||
<pre>
|
||||
leveldb::Options options;
|
||||
rocksdb::Options options;
|
||||
options.filter_policy = NewBloomFilter(10);
|
||||
leveldb::DB* db;
|
||||
leveldb::DB::Open(options, "/tmp/testdb", &db);
|
||||
rocksdb::DB* db;
|
||||
rocksdb::DB::Open(options, "/tmp/testdb", &db);
|
||||
... use the database ...
|
||||
delete db;
|
||||
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
|
||||
also ignores trailing spaces. For example:
|
||||
<pre>
|
||||
class CustomFilterPolicy : public leveldb::FilterPolicy {
|
||||
class CustomFilterPolicy : public rocksdb::FilterPolicy {
|
||||
private:
|
||||
FilterPolicy* builtin_policy_;
|
||||
public:
|
||||
|
@ -484,7 +484,7 @@ checksums are verified:
|
|||
parts of its persistent storage have been corrupted.
|
||||
<p>
|
||||
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
|
||||
<p>
|
||||
</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.
|
||||
<p>
|
||||
<pre>
|
||||
leveldb::Range ranges[2];
|
||||
ranges[0] = leveldb::Range("a", "c");
|
||||
ranges[1] = leveldb::Range("x", "z");
|
||||
rocksdb::Range ranges[2];
|
||||
ranges[0] = rocksdb::Range("a", "c");
|
||||
ranges[1] = rocksdb::Range("x", "z");
|
||||
uint64_t sizes[2];
|
||||
leveldb::Status s = db->GetApproximateSizes(ranges, 2, sizes);
|
||||
rocksdb::Status s = db->GetApproximateSizes(ranges, 2, sizes);
|
||||
</pre>
|
||||
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
|
||||
|
@ -508,21 +508,21 @@ bytes of file system space used by the key range <code>[a..c)</code> and
|
|||
<h1>Environment</h1>
|
||||
<p>
|
||||
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>
|
||||
implementation to get better control. For example, an application may
|
||||
introduce artificial delays in the file IO paths to limit the impact
|
||||
of <code>leveldb</code> on other activities in the system.
|
||||
<p>
|
||||
<pre>
|
||||
class SlowEnv : public leveldb::Env {
|
||||
class SlowEnv : public rocksdb::Env {
|
||||
.. implementation of the Env interface ...
|
||||
};
|
||||
|
||||
SlowEnv env;
|
||||
leveldb::Options options;
|
||||
rocksdb::Options options;
|
||||
options.env = &env;
|
||||
Status s = leveldb::DB::Open(options, ...);
|
||||
Status s = rocksdb::DB::Open(options, ...);
|
||||
</pre>
|
||||
<h1>Porting</h1>
|
||||
<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
|
||||
details.
|
||||
<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.
|
||||
|
||||
<h1>Other Information</h1>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#ifdef USE_HDFS
|
||||
#include "hdfs/hdfs.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static const std::string kProto = "hdfs://";
|
||||
static const std::string pathsep = "/";
|
||||
|
@ -214,12 +214,12 @@ class HdfsEnv : public Env {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#else // USE_HDFS
|
||||
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
static const Status notsup;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -383,4 +383,4 @@ Env* NewMemEnv(Env* base_env) {
|
|||
return new InMemoryEnv(base_env);
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#ifndef STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_
|
||||
#define STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Env;
|
||||
|
||||
|
@ -14,6 +14,6 @@ class Env;
|
|||
// *base_env must remain live while the result is in use.
|
||||
Env* NewMemEnv(Env* base_env);
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // STORAGE_ROCKSDB_HELPERS_MEMENV_MEMENV_H_
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class MemEnvTest {
|
||||
public:
|
||||
|
@ -226,8 +226,8 @@ TEST(MemEnvTest, DBTest) {
|
|||
delete db;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return leveldb::test::RunAllTests();
|
||||
return rocksdb::test::RunAllTests();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Arena {
|
||||
public:
|
||||
|
@ -36,6 +36,8 @@ class Arena {
|
|||
void operator=(const Arena&);
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_ARENA_H_
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdint.h>
|
||||
#include "rocksdb/slice.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
using std::shared_ptr;
|
||||
|
||||
|
@ -101,6 +101,8 @@ class Cache {
|
|||
void operator=(const Cache&);
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_UTIL_CACHE_H_
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
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_
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Slice;
|
||||
|
||||
|
@ -58,6 +58,8 @@ class Comparator {
|
|||
// must not be deleted.
|
||||
extern const Comparator* BytewiseComparator();
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_COMPARATOR_H_
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "rocksdb/types.h"
|
||||
#include "rocksdb/transaction_log.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
|
@ -306,6 +306,8 @@ Status DestroyDB(const std::string& name, const Options& options);
|
|||
// on a database that contains important information.
|
||||
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_
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdint.h>
|
||||
#include "rocksdb/status.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class FileLock;
|
||||
class Logger;
|
||||
|
@ -563,6 +563,8 @@ class EnvWrapper : public Env {
|
|||
Env* target_;
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_ENV_H_
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Slice;
|
||||
|
||||
|
@ -66,5 +66,6 @@ class FilterPolicy {
|
|||
extern const FilterPolicy* NewBloomFilterPolicy(int bits_per_key);
|
||||
|
||||
}
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_FILTER_POLICY_H_
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "rocksdb/slice.h"
|
||||
#include "rocksdb/status.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Iterator {
|
||||
public:
|
||||
|
@ -97,6 +97,8 @@ extern Iterator* NewEmptyIterator();
|
|||
// Return an empty iterator with the specified status.
|
||||
extern Iterator* NewErrorIterator(const Status& status);
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_ITERATOR_H_
|
||||
|
|
|
@ -3,12 +3,18 @@
|
|||
#define STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H
|
||||
#include "rocksdb/options.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class LDBTool {
|
||||
public:
|
||||
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
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "rocksdb/slice.h"
|
||||
#include "rocksdb/slice_transform.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class MemTableRep {
|
||||
public:
|
||||
|
@ -256,4 +256,6 @@ public:
|
|||
|
||||
}
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_DB_MEMTABLEREP_H_
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <deque>
|
||||
#include "rocksdb/slice.h" // TODO: Remove this when migration is done;
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Slice;
|
||||
class Logger;
|
||||
|
@ -142,6 +142,8 @@ class AssociativeMergeOperator : public MergeOperator {
|
|||
Logger* logger) const override;
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_MERGE_OPERATOR_H_
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "rocksdb/memtablerep.h"
|
||||
#include "rocksdb/slice_transform.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Cache;
|
||||
class Comparator;
|
||||
|
@ -673,6 +673,8 @@ struct FlushOptions {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_OPTIONS_H_
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
enum PerfLevel {
|
||||
kDisable = 0, // disable perf stats
|
||||
|
@ -36,5 +36,6 @@ extern __thread PerfContext perf_context;
|
|||
|
||||
}
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#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>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Slice {
|
||||
public:
|
||||
|
@ -117,6 +117,8 @@ inline int Slice::compare(const Slice& b) const {
|
|||
return r;
|
||||
}
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_SLICE_H_
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Slice;
|
||||
|
||||
|
@ -40,4 +40,6 @@ extern const SliceTransform* NewNoopTransform();
|
|||
|
||||
}
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_SLICE_TRANSFORM_H_
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
/**
|
||||
* 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_
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <string>
|
||||
#include "rocksdb/slice.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Status {
|
||||
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_
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "rocksdb/options.h"
|
||||
#include "rocksdb/status.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class BlockBuilder;
|
||||
class BlockHandle;
|
||||
|
@ -90,6 +90,8 @@ class TableBuilder {
|
|||
void operator=(const TableBuilder&);
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_TABLE_BUILDER_H_
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "rocksdb/types.h"
|
||||
#include "rocksdb/write_batch.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class LogFile;
|
||||
typedef std::vector<std::unique_ptr<LogFile>> VectorLogPtr;
|
||||
|
@ -76,6 +76,8 @@ class TransactionLogIterator {
|
|||
// ONLY use if Valid() is true and status() is OK.
|
||||
virtual BatchResult GetBatch() = 0;
|
||||
};
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_TRANSACTION_LOG_ITERATOR_H_
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// Define all public custom types here.
|
||||
|
||||
// Represents a sequence number in a WAL file.
|
||||
typedef uint64_t SequenceNumber;
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_TYPES_H_
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "rocksdb/slice.h"
|
||||
#include "rocksdb/statistics.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
//
|
||||
// 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
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <string>
|
||||
#include "rocksdb/status.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
class Slice;
|
||||
|
||||
|
@ -94,6 +94,8 @@ class WriteBatch {
|
|||
// Intentionally copyable
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#include "rocksdb/rocksdb_to_leveldb.h"
|
||||
|
||||
#endif // STORAGE_ROCKSDB_INCLUDE_WRITE_BATCH_H_
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "rocksdb/db.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// This class contains APIs to stack rocksdb wrappers.Eg. Stack TTL over base d
|
||||
class StackableDB : public DB {
|
||||
|
@ -160,6 +160,6 @@ class StackableDB : public DB {
|
|||
StackableDB* sdb_;
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#endif // LEVELDB_INCLUDE_UTILITIES_STACKABLE_DB_H_
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "stackable_db.h"
|
||||
|
||||
namespace leveldb {
|
||||
namespace rocksdb {
|
||||
|
||||
// This class contains APIs to open leveldb with specific support eg. TTL
|
||||
class UtilityDB {
|
||||
|
@ -49,6 +49,6 @@ class UtilityDB {
|
|||
bool read_only = false);
|
||||
};
|
||||
|
||||
} // namespace leveldb
|
||||
} // namespace rocksdb
|
||||
|
||||
#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;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
public class NativeCache extends NativeObject {
|
||||
|
||||
@JniClass(name="leveldb::Cache", flags={CPP})
|
||||
@JniClass(name="rocksdb::Cache", flags={CPP})
|
||||
private static class CacheJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
}
|
||||
|
||||
@JniMethod(cast="leveldb::Cache *", accessor="leveldb::NewLRUCache")
|
||||
@JniMethod(cast="rocksdb::Cache *", accessor="rocksdb::NewLRUCache")
|
||||
public static final native long NewLRUCache(
|
||||
@JniArg(cast="size_t") long capacity);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.*;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* Provides a java interface to the C++ leveldb::Comparator class.
|
||||
* Provides a java interface to the C++ rocksdb::Comparator class.
|
||||
* </p>
|
||||
*
|
||||
* @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)")
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
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>
|
||||
*/
|
||||
|
|
|
@ -52,7 +52,7 @@ public class NativeDB extends NativeObject {
|
|||
|
||||
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 {
|
||||
NativeDB.LIBRARY.load();
|
||||
|
@ -79,13 +79,13 @@ public class NativeDB extends NativeObject {
|
|||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", accessor = "leveldb::DB::Open")
|
||||
@JniMethod(copy="rocksdb::Status", accessor = "rocksdb::DB::Open")
|
||||
static final native long Open(
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options,
|
||||
@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(
|
||||
long self,
|
||||
@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
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
|
||||
static final native long Delete(
|
||||
long self,
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeWriteOptions options,
|
||||
@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(
|
||||
long self,
|
||||
@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(
|
||||
long self,
|
||||
@JniArg(flags={NO_OUT, BY_VALUE}) NativeReadOptions options,
|
||||
|
@ -115,26 +115,26 @@ public class NativeDB extends NativeObject {
|
|||
@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(
|
||||
long self,
|
||||
@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(
|
||||
long self);
|
||||
|
||||
@JniMethod(flags={CPP_METHOD})
|
||||
static final native void ReleaseSnapshot(
|
||||
long self,
|
||||
@JniArg(cast="const leveldb::Snapshot *") long snapshot
|
||||
@JniArg(cast="const rocksdb::Snapshot *") long snapshot
|
||||
);
|
||||
|
||||
@JniMethod(flags={CPP_METHOD})
|
||||
static final native void GetApproximateSizes(
|
||||
long self,
|
||||
@JniArg(cast="const leveldb::Range *") long range,
|
||||
@JniArg(cast="const rocksdb::Range *") long range,
|
||||
int n,
|
||||
@JniArg(cast="uint64_t*") long[] sizes
|
||||
);
|
||||
|
@ -146,12 +146,12 @@ public class NativeDB extends NativeObject {
|
|||
@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(
|
||||
@JniArg(cast="const char*") String path,
|
||||
@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(
|
||||
@JniArg(cast="const char*") String path,
|
||||
@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.*;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
public class NativeIterator extends NativeObject {
|
||||
|
||||
@JniClass(name="leveldb::Iterator", flags={CPP})
|
||||
@JniClass(name="rocksdb::Iterator", flags={CPP})
|
||||
private static class IteratorJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
|
@ -86,17 +86,17 @@ public class NativeIterator extends NativeObject {
|
|||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Slice", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Slice", flags={CPP_METHOD})
|
||||
static final native long key(
|
||||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Slice", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Slice", flags={CPP_METHOD})
|
||||
static final native long value(
|
||||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
|
||||
static final native long status(
|
||||
long self
|
||||
);
|
||||
|
|
|
@ -46,7 +46,7 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.*;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* Provides a java interface to the C++ leveldb::Logger class.
|
||||
* Provides a java interface to the C++ rocksdb::Logger class.
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
@JniClass(name="leveldb::Options", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::Options", flags={STRUCT, CPP})
|
||||
public class NativeOptions {
|
||||
|
||||
static {
|
||||
|
@ -57,7 +57,7 @@ public class NativeOptions {
|
|||
@JniMethod(flags={CONSTANT_INITIALIZER})
|
||||
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 boolean create_if_missing = false;
|
||||
|
@ -83,7 +83,7 @@ public class NativeOptions {
|
|||
|
||||
@JniField(flags={FIELD_SKIP})
|
||||
private NativeComparator comparatorObject = NativeComparator.BYTEWISE_COMPARATOR;
|
||||
@JniField(cast="const leveldb::Comparator*")
|
||||
@JniField(cast="const rocksdb::Comparator*")
|
||||
private long comparator = comparatorObject.pointer();
|
||||
|
||||
@JniField(cast="uint64_t")
|
||||
|
@ -110,17 +110,17 @@ public class NativeOptions {
|
|||
|
||||
@JniField(flags={FIELD_SKIP})
|
||||
private NativeLogger infoLogObject = null;
|
||||
@JniField(cast="leveldb::Logger*")
|
||||
@JniField(cast="rocksdb::Logger*")
|
||||
private long info_log = 0;
|
||||
|
||||
@JniField(cast="leveldb::Env*")
|
||||
@JniField(cast="rocksdb::Env*")
|
||||
private long env = DEFAULT_ENV;
|
||||
@JniField(cast="leveldb::Cache*")
|
||||
@JniField(cast="rocksdb::Cache*")
|
||||
private long block_cache = 0;
|
||||
@JniField(flags={FIELD_SKIP})
|
||||
private NativeCache cache;
|
||||
|
||||
@JniField(cast="leveldb::CompressionType")
|
||||
@JniField(cast="rocksdb::CompressionType")
|
||||
private int compression = NativeCompressionType.kSnappyCompression.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;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
public class NativeRange {
|
||||
|
||||
@JniClass(name="leveldb::Range", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::Range", flags={STRUCT, CPP})
|
||||
static public class RangeJNI {
|
||||
|
||||
static {
|
||||
|
@ -69,7 +69,7 @@ public class NativeRange {
|
|||
@JniMethod(flags={CONSTANT_INITIALIZER})
|
||||
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;
|
||||
|
||||
@JniField
|
||||
|
|
|
@ -38,11 +38,11 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.CPP;
|
|||
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>
|
||||
*/
|
||||
@JniClass(name="leveldb::ReadOptions", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::ReadOptions", flags={STRUCT, CPP})
|
||||
public class NativeReadOptions {
|
||||
|
||||
@JniField
|
||||
|
@ -51,7 +51,7 @@ public class NativeReadOptions {
|
|||
@JniField
|
||||
private boolean fill_cache = true;
|
||||
|
||||
@JniField(cast="const leveldb::Snapshot*")
|
||||
@JniField(cast="const rocksdb::Snapshot*")
|
||||
private long snapshot=0;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
@JniClass(name="leveldb::Slice", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::Slice", flags={STRUCT, CPP})
|
||||
class NativeSlice {
|
||||
|
||||
@JniClass(name="leveldb::Slice", flags={CPP})
|
||||
@JniClass(name="rocksdb::Slice", flags={CPP})
|
||||
static class SliceJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
|
@ -74,7 +74,7 @@ class NativeSlice {
|
|||
@JniMethod(flags={CONSTANT_INITIALIZER})
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
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>
|
||||
*/
|
||||
|
|
|
@ -39,13 +39,13 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE;
|
|||
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>
|
||||
*/
|
||||
class NativeStatus extends NativeObject{
|
||||
|
||||
@JniClass(name="leveldb::Status", flags={CPP})
|
||||
@JniClass(name="rocksdb::Status", flags={CPP})
|
||||
static class StatusJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue