mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add rocksdb module
This commit is contained in:
110
src/ripple/rocksdb/ripple_rocksdb.cpp
Normal file
110
src/ripple/rocksdb/ripple_rocksdb.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "ripple_rocksdb.h"
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
|
||||
#if BEAST_WIN32
|
||||
# define ROCKSDB_PLATFORM_WINDOWS
|
||||
#else
|
||||
# define ROCKSDB_PLATFORM_POSIX
|
||||
# if BEAST_MAC || BEAST_IOS
|
||||
# define OS_MACOSX
|
||||
# elif BEAST_BSD
|
||||
# define OS_FREEBSD
|
||||
# else
|
||||
# define OS_LINUX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if BEAST_GCC
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wreorder"
|
||||
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
|
||||
#include "rocksdb/db/builder.cc"
|
||||
#include "rocksdb/db/db_filesnapshot.cc"
|
||||
#include "rocksdb/db/dbformat.cc"
|
||||
#include "rocksdb/db/db_impl.cc"
|
||||
#include "rocksdb/db/db_impl_readonly.cc"
|
||||
#include "rocksdb/db/db_iter.cc"
|
||||
#include "rocksdb/db/db_stats_logger.cc"
|
||||
#include "rocksdb/db/filename.cc"
|
||||
#include "rocksdb/db/log_reader.cc"
|
||||
#include "rocksdb/db/log_writer.cc"
|
||||
#include "rocksdb/db/memtable.cc"
|
||||
#include "rocksdb/db/memtablelist.cc"
|
||||
#include "rocksdb/db/merge_helper.cc"
|
||||
#include "rocksdb/db/merge_operator.cc"
|
||||
#include "rocksdb/db/repair.cc"
|
||||
#include "rocksdb/db/table_cache.cc"
|
||||
#include "rocksdb/db/table_properties_collector.cc"
|
||||
#include "rocksdb/db/transaction_log_impl.cc"
|
||||
#include "rocksdb/db/version_edit.cc"
|
||||
#include "rocksdb/db/version_set.cc"
|
||||
#include "rocksdb/db/version_set_reduce_num_levels.cc"
|
||||
#include "rocksdb/db/write_batch.cc"
|
||||
|
||||
#include "rocksdb/table/block_based_table_builder.cc"
|
||||
#include "rocksdb/table/block_based_table_factory.cc"
|
||||
#include "rocksdb/table/block_based_table_reader.cc"
|
||||
#include "rocksdb/table/block_builder.cc"
|
||||
#include "rocksdb/table/block.cc"
|
||||
#include "rocksdb/table/filter_block.cc"
|
||||
#include "rocksdb/table/flush_block_policy.cc"
|
||||
#include "rocksdb/table/format.cc"
|
||||
#include "rocksdb/table/iterator.cc"
|
||||
#include "rocksdb/table/merger.cc"
|
||||
#include "rocksdb/table/two_level_iterator.cc"
|
||||
|
||||
#include "rocksdb/util/arena_impl.cc"
|
||||
#include "rocksdb/util/auto_roll_logger.cc"
|
||||
#include "rocksdb/util/blob_store.cc"
|
||||
#include "rocksdb/util/bloom.cc"
|
||||
#include "rocksdb/util/cache.cc"
|
||||
#include "rocksdb/util/coding.cc"
|
||||
#include "rocksdb/util/comparator.cc"
|
||||
#include "rocksdb/util/crc32c.cc"
|
||||
#include "rocksdb/util/env.cc"
|
||||
//#include "rocksdb/util/env_hdfs.cc"
|
||||
#include "rocksdb/util/env_posix.cc"
|
||||
#include "rocksdb/util/filter_policy.cc"
|
||||
#include "rocksdb/util/hash.cc"
|
||||
#include "rocksdb/util/hash_skiplist_rep.cc"
|
||||
#include "rocksdb/util/histogram.cc"
|
||||
#include "rocksdb/util/logging.cc"
|
||||
#include "rocksdb/util/murmurhash.cc"
|
||||
#include "rocksdb/util/options.cc"
|
||||
#include "rocksdb/util/perf_context.cc"
|
||||
#include "rocksdb/util/skiplistrep.cc"
|
||||
#include "rocksdb/util/slice.cc"
|
||||
#include "rocksdb/util/statistics.cc"
|
||||
#include "rocksdb/util/status.cc"
|
||||
#include "rocksdb/util/string_util.cc"
|
||||
#include "rocksdb/util/transformrep.cc"
|
||||
#include "rocksdb/util/vectorrep.cc"
|
||||
|
||||
#include "rocksdb/port/port_posix.cc"
|
||||
|
||||
#endif
|
||||
59
src/ripple/rocksdb/ripple_rocksdb.h
Normal file
59
src/ripple/rocksdb/ripple_rocksdb.h
Normal file
@@ -0,0 +1,59 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_ROCKSDB_H_INCLUDED
|
||||
#define RIPPLE_ROCKSDB_H_INCLUDED
|
||||
|
||||
#include "beast/beast/Config.h"
|
||||
|
||||
#ifndef RIPPLE_ROCKSDB_AVAILABLE
|
||||
# if BEAST_WIN32
|
||||
# define RIPPLE_ROCKSDB_AVAILABLE 0
|
||||
# else
|
||||
# define RIPPLE_ROCKSDB_AVAILABLE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
#include "rocksdb/include/rocksdb/arena.h"
|
||||
#include "rocksdb/include/rocksdb/cache.h"
|
||||
#include "rocksdb/include/rocksdb/compaction_filter.h"
|
||||
#include "rocksdb/include/rocksdb/comparator.h"
|
||||
#include "rocksdb/include/rocksdb/db.h"
|
||||
#include "rocksdb/include/rocksdb/env.h"
|
||||
#include "rocksdb/include/rocksdb/filter_policy.h"
|
||||
#include "rocksdb/include/rocksdb/flush_block_policy.h"
|
||||
#include "rocksdb/include/rocksdb/iterator.h"
|
||||
#include "rocksdb/include/rocksdb/memtablerep.h"
|
||||
#include "rocksdb/include/rocksdb/merge_operator.h"
|
||||
#include "rocksdb/include/rocksdb/options.h"
|
||||
#include "rocksdb/include/rocksdb/perf_context.h"
|
||||
#include "rocksdb/include/rocksdb/slice.h"
|
||||
#include "rocksdb/include/rocksdb/slice_transform.h"
|
||||
#include "rocksdb/include/rocksdb/statistics.h"
|
||||
#include "rocksdb/include/rocksdb/status.h"
|
||||
#include "rocksdb/include/rocksdb/table.h"
|
||||
#include "rocksdb/include/rocksdb/table_properties.h"
|
||||
#include "rocksdb/include/rocksdb/transaction_log.h"
|
||||
#include "rocksdb/include/rocksdb/types.h"
|
||||
#include "rocksdb/include/rocksdb/universal_compaction.h"
|
||||
#include "rocksdb/include/rocksdb/write_batch.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "../include/rocksdb/env.h"
|
||||
#include "../include/rocksdb/iterator.h"
|
||||
#include "../include/rocksdb/options.h"
|
||||
#include "table/block_based_table_builder.h"
|
||||
#include "../table/block_based_table_builder.h"
|
||||
#include "../util/stop_watch.h"
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
#include "../include/rocksdb/status.h"
|
||||
#include "../include/rocksdb/table.h"
|
||||
#include "../port/port.h"
|
||||
#include "table/block.h"
|
||||
#include "table/block_based_table_factory.h"
|
||||
#include "table/merger.h"
|
||||
#include "table/two_level_iterator.h"
|
||||
#include "../table/block.h"
|
||||
#include "../table/block_based_table_factory.h"
|
||||
#include "../table/merger.h"
|
||||
#include "../table/two_level_iterator.h"
|
||||
#include "../util/auto_roll_logger.h"
|
||||
#include "../util/build_version.h"
|
||||
#include "../util/coding.h"
|
||||
@@ -283,7 +283,10 @@ DBImpl::DBImpl(const Options& options, const std::string& dbname)
|
||||
versions_.reset(new VersionSet(dbname_, &options_, storage_options_,
|
||||
table_cache_.get(), &internal_comparator_));
|
||||
|
||||
#ifdef ROCKSDB_LDB_BUILD_VERSION
|
||||
dumpLeveldbBuildVersion(options_.info_log.get());
|
||||
#endif
|
||||
|
||||
options_.Dump(options_.info_log.get());
|
||||
|
||||
char name[100];
|
||||
@@ -3587,6 +3590,7 @@ Status DestroyDB(const std::string& dbname, const Options& options) {
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef ROCKSDB_LDB_BUILD_VERSION
|
||||
//
|
||||
// A global method that can dump out the build version
|
||||
void dumpLeveldbBuildVersion(Logger * log) {
|
||||
@@ -3594,5 +3598,6 @@ void dumpLeveldbBuildVersion(Logger * log) {
|
||||
Log(log, "Compile time %s %s",
|
||||
rocksdb_build_compile_time, rocksdb_build_compile_date);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
#include "../include/rocksdb/status.h"
|
||||
#include "../include/rocksdb/table.h"
|
||||
#include "../port/port.h"
|
||||
#include "table/block.h"
|
||||
#include "table/merger.h"
|
||||
#include "table/two_level_iterator.h"
|
||||
#include "../table/block.h"
|
||||
#include "../table/merger.h"
|
||||
#include "../table/two_level_iterator.h"
|
||||
#include "../util/coding.h"
|
||||
#include "../util/logging.h"
|
||||
#include "../util/build_version.h"
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "../util/mutexlock.h"
|
||||
#include "../util/murmurhash.h"
|
||||
|
||||
#ifndef ROCKSDB_HASH_SLICE_DECLARED
|
||||
#define ROCKSDB_HASH_SLICE_DECLARED
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<rocksdb::Slice> {
|
||||
@@ -28,6 +30,7 @@ struct hash<rocksdb::Slice> {
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "../include/rocksdb/env.h"
|
||||
#include "../include/rocksdb/merge_operator.h"
|
||||
#include "../include/rocksdb/table.h"
|
||||
#include "table/merger.h"
|
||||
#include "table/two_level_iterator.h"
|
||||
#include "../table/merger.h"
|
||||
#include "../table/two_level_iterator.h"
|
||||
#include "../util/coding.h"
|
||||
#include "../util/logging.h"
|
||||
#include "../util/stop_watch.h"
|
||||
|
||||
@@ -559,7 +559,7 @@ Status BlockBasedTable::GetBlock(
|
||||
if (s.ok()) {
|
||||
if (options.fill_cache && entry->value->isCachable()) {
|
||||
entry->cache_handle = block_cache->Insert(
|
||||
key, entry->value, entry->value->size(), &DeleteCachedBlock);
|
||||
key, entry->value, entry->value->size(), &rocksdb::DeleteCachedBlock);
|
||||
RecordTick(statistics, BLOCK_CACHE_ADD);
|
||||
}
|
||||
}
|
||||
@@ -673,7 +673,7 @@ Iterator* BlockBasedTable::BlockReader(void* arg,
|
||||
if (block_cache != nullptr && block->isCachable() &&
|
||||
options.fill_cache) {
|
||||
cache_handle = block_cache->Insert(key, block, block->size(),
|
||||
&DeleteCachedBlock);
|
||||
&rocksdb::DeleteCachedBlock);
|
||||
assert(reinterpret_cast<Block*>(block_cache->Value(cache_handle))
|
||||
== block);
|
||||
}
|
||||
@@ -726,7 +726,7 @@ Iterator* BlockBasedTable::BlockReader(void* arg,
|
||||
// Release the hold on the compressed cache entry immediately.
|
||||
if (block_cache_compressed != nullptr && cblock != nullptr) {
|
||||
compressed_cache_handle = block_cache_compressed->Insert(
|
||||
ckey, cblock, cblock->size(), &DeleteCachedBlock);
|
||||
ckey, cblock, cblock->size(), &rocksdb::DeleteCachedBlock);
|
||||
block_cache_compressed->Release(compressed_cache_handle);
|
||||
RecordTick(statistics, BLOCK_CACHE_COMPRESSED_MISS);
|
||||
cblock = nullptr;
|
||||
@@ -735,7 +735,7 @@ Iterator* BlockBasedTable::BlockReader(void* arg,
|
||||
assert((block->compressionType() == kNoCompression));
|
||||
if (block_cache != nullptr) {
|
||||
cache_handle = block_cache->Insert(
|
||||
key, block, block->size(), &DeleteCachedBlock);
|
||||
key, block, block->size(), &rocksdb::DeleteCachedBlock);
|
||||
RecordTick(statistics, BLOCK_CACHE_ADD);
|
||||
assert(reinterpret_cast<Block*>(block_cache->Value(
|
||||
cache_handle))== block);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "../include/rocksdb/env.h"
|
||||
#include "../include/rocksdb/filter_policy.h"
|
||||
#include "../include/rocksdb/merge_operator.h"
|
||||
#include "table/block_based_table_factory.h"
|
||||
#include "../table/block_based_table_factory.h"
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "murmurhash.h"
|
||||
#include "stl_wrappers.h"
|
||||
|
||||
#ifndef ROCKSDB_HASH_SLICE_DECLARED
|
||||
#define ROCKSDB_HASH_SLICE_DECLARED
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<rocksdb::Slice> {
|
||||
@@ -26,6 +28,7 @@ struct hash<rocksdb::Slice> {
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace rocksdb {
|
||||
namespace {
|
||||
|
||||
Reference in New Issue
Block a user