mirror of
https://github.com/facebook/rocksdb.git
synced 2026-07-07 14:47:40 +08:00
Reformat source files (#14331)
Summary: probably something changed, maybe https://github.com/facebook/rocksdb/issues/14311 Full command: ``` git ls-files '*.cc' '*.h' | grep -v '^third-party/' | grep -v 'range_tree' | xargs clang-format -i ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/14331 Test Plan: CI Reviewed By: mszeszko-meta Differential Revision: D93246992 Pulled By: pdillinger fbshipit-source-id: 6bc5b97978fef8aee52823dadb6daa4bea57343d
This commit is contained in:
committed by
meta-codesync[bot]
parent
672389fd8c
commit
871f79d6ef
Vendored
+9
-9
@@ -101,23 +101,23 @@ class CacheEntryStatsCollector {
|
||||
}
|
||||
|
||||
// Gets saved stats, regardless of age
|
||||
void GetStats(Stats *stats) {
|
||||
void GetStats(Stats* stats) {
|
||||
std::lock_guard<std::mutex> lock(saved_mutex_);
|
||||
*stats = saved_stats_;
|
||||
}
|
||||
|
||||
Cache *GetCache() const { return cache_; }
|
||||
Cache* GetCache() const { return cache_; }
|
||||
|
||||
// Gets or creates a shared instance of CacheEntryStatsCollector in the
|
||||
// cache itself, and saves into `ptr`. This shared_ptr will hold the
|
||||
// entry in cache until all refs are destroyed.
|
||||
static Status GetShared(Cache *raw_cache, SystemClock *clock,
|
||||
std::shared_ptr<CacheEntryStatsCollector> *ptr) {
|
||||
static Status GetShared(Cache* raw_cache, SystemClock* clock,
|
||||
std::shared_ptr<CacheEntryStatsCollector>* ptr) {
|
||||
assert(raw_cache);
|
||||
BasicTypedCacheInterface<CacheEntryStatsCollector, CacheEntryRole::kMisc>
|
||||
cache{raw_cache};
|
||||
|
||||
const Slice &cache_key = GetCacheKey();
|
||||
const Slice& cache_key = GetCacheKey();
|
||||
auto h = cache.Lookup(cache_key);
|
||||
if (h == nullptr) {
|
||||
// Not yet in cache, but Cache doesn't provide a built-in way to
|
||||
@@ -152,7 +152,7 @@ class CacheEntryStatsCollector {
|
||||
}
|
||||
|
||||
private:
|
||||
explicit CacheEntryStatsCollector(Cache *cache, SystemClock *clock)
|
||||
explicit CacheEntryStatsCollector(Cache* cache, SystemClock* clock)
|
||||
: saved_stats_(),
|
||||
working_stats_(),
|
||||
last_start_time_micros_(0),
|
||||
@@ -160,7 +160,7 @@ class CacheEntryStatsCollector {
|
||||
cache_(cache),
|
||||
clock_(clock) {}
|
||||
|
||||
static const Slice &GetCacheKey() {
|
||||
static const Slice& GetCacheKey() {
|
||||
// For each template instantiation
|
||||
static CacheKey ckey = CacheKey::CreateUniqueForProcessLifetime();
|
||||
static Slice ckey_slice = ckey.AsSlice();
|
||||
@@ -175,8 +175,8 @@ class CacheEntryStatsCollector {
|
||||
uint64_t last_start_time_micros_;
|
||||
uint64_t last_end_time_micros_;
|
||||
|
||||
Cache *const cache_;
|
||||
SystemClock *const clock_;
|
||||
Cache* const cache_;
|
||||
SystemClock* const clock_;
|
||||
};
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
||||
Vendored
+3
-3
@@ -24,7 +24,7 @@ namespace ROCKSDB_NAMESPACE {
|
||||
// 0 | >= 1<<63 | CreateUniqueForProcessLifetime
|
||||
// > 0 | any | OffsetableCacheKey.WithOffset
|
||||
|
||||
CacheKey CacheKey::CreateUniqueForCacheLifetime(Cache *cache) {
|
||||
CacheKey CacheKey::CreateUniqueForCacheLifetime(Cache* cache) {
|
||||
// +1 so that we can reserve all zeros for "unset" cache key
|
||||
uint64_t id = cache->NewId() + 1;
|
||||
// Ensure we don't collide with CreateUniqueForProcessLifetime
|
||||
@@ -297,8 +297,8 @@ CacheKey CacheKey::CreateUniqueForProcessLifetime() {
|
||||
//
|
||||
// TODO: Nevertheless / regardless, an efficient way to detect (and thus
|
||||
// quantify) block cache corruptions, including collisions, should be added.
|
||||
OffsetableCacheKey::OffsetableCacheKey(const std::string &db_id,
|
||||
const std::string &db_session_id,
|
||||
OffsetableCacheKey::OffsetableCacheKey(const std::string& db_id,
|
||||
const std::string& db_session_id,
|
||||
uint64_t file_number) {
|
||||
UniqueId64x2 internal_id;
|
||||
Status s = GetSstInternalUniqueId(db_id, db_session_id, file_number,
|
||||
|
||||
Vendored
+5
-5
@@ -44,13 +44,13 @@ class CacheKey {
|
||||
inline Slice AsSlice() const {
|
||||
static_assert(sizeof(*this) == 16, "Standardized on 16-byte cache key");
|
||||
assert(!IsEmpty());
|
||||
return Slice(reinterpret_cast<const char *>(this), sizeof(*this));
|
||||
return Slice(reinterpret_cast<const char*>(this), sizeof(*this));
|
||||
}
|
||||
|
||||
// Create a CacheKey that is unique among others associated with this Cache
|
||||
// instance. Depends on Cache::NewId. This is useful for block cache
|
||||
// "reservations".
|
||||
static CacheKey CreateUniqueForCacheLifetime(Cache *cache);
|
||||
static CacheKey CreateUniqueForCacheLifetime(Cache* cache);
|
||||
|
||||
// Create a CacheKey that is unique among others for the lifetime of this
|
||||
// process. This is useful for saving in a static data member so that
|
||||
@@ -87,7 +87,7 @@ class OffsetableCacheKey : private CacheKey {
|
||||
|
||||
// Constructs an OffsetableCacheKey with the given information about a file.
|
||||
// This constructor never generates an "empty" base key.
|
||||
OffsetableCacheKey(const std::string &db_id, const std::string &db_session_id,
|
||||
OffsetableCacheKey(const std::string& db_id, const std::string& db_session_id,
|
||||
uint64_t file_number);
|
||||
|
||||
// Creates an OffsetableCacheKey from an SST unique ID, so that cache keys
|
||||
@@ -134,9 +134,9 @@ class OffsetableCacheKey : private CacheKey {
|
||||
static_assert(sizeof(file_num_etc64_) == kCommonPrefixSize,
|
||||
"8 byte common prefix expected");
|
||||
assert(!IsEmpty());
|
||||
assert(&this->file_num_etc64_ == static_cast<const void *>(this));
|
||||
assert(&this->file_num_etc64_ == static_cast<const void*>(this));
|
||||
|
||||
return Slice(reinterpret_cast<const char *>(this), kCommonPrefixSize);
|
||||
return Slice(reinterpret_cast<const char*>(this), kCommonPrefixSize);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Vendored
+16
-16
@@ -44,8 +44,8 @@ class CacheReservationManager {
|
||||
bool increase) = 0;
|
||||
virtual Status MakeCacheReservation(
|
||||
std::size_t incremental_memory_used,
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle>
|
||||
*handle) = 0;
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle>*
|
||||
handle) = 0;
|
||||
virtual std::size_t GetTotalReservedCacheSize() = 0;
|
||||
virtual std::size_t GetTotalMemoryUsed() = 0;
|
||||
};
|
||||
@@ -90,11 +90,11 @@ class CacheReservationManagerImpl
|
||||
bool delayed_decrease = false);
|
||||
|
||||
// no copy constructor, copy assignment, move constructor, move assignment
|
||||
CacheReservationManagerImpl(const CacheReservationManagerImpl &) = delete;
|
||||
CacheReservationManagerImpl &operator=(const CacheReservationManagerImpl &) =
|
||||
CacheReservationManagerImpl(const CacheReservationManagerImpl&) = delete;
|
||||
CacheReservationManagerImpl& operator=(const CacheReservationManagerImpl&) =
|
||||
delete;
|
||||
CacheReservationManagerImpl(CacheReservationManagerImpl &&) = delete;
|
||||
CacheReservationManagerImpl &operator=(CacheReservationManagerImpl &&) =
|
||||
CacheReservationManagerImpl(CacheReservationManagerImpl&&) = delete;
|
||||
CacheReservationManagerImpl& operator=(CacheReservationManagerImpl&&) =
|
||||
delete;
|
||||
|
||||
~CacheReservationManagerImpl() override;
|
||||
@@ -178,7 +178,7 @@ class CacheReservationManagerImpl
|
||||
// REQUIRES: handle != nullptr
|
||||
Status MakeCacheReservation(
|
||||
std::size_t incremental_memory_used,
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle> *handle)
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle>* handle)
|
||||
override;
|
||||
|
||||
// Return the size of the cache (which is a multiple of kSizeDummyEntry)
|
||||
@@ -200,7 +200,7 @@ class CacheReservationManagerImpl
|
||||
// For testing only - it is to help ensure the CacheItemHelperForRole<R>
|
||||
// accessed from CacheReservationManagerImpl and the one accessed from the
|
||||
// test are from the same translation units
|
||||
static const Cache::CacheItemHelper *TEST_GetCacheItemHelperForRole();
|
||||
static const Cache::CacheItemHelper* TEST_GetCacheItemHelperForRole();
|
||||
|
||||
private:
|
||||
static constexpr std::size_t kSizeDummyEntry = 256 * 1024;
|
||||
@@ -216,7 +216,7 @@ class CacheReservationManagerImpl
|
||||
bool delayed_decrease_;
|
||||
std::atomic<std::size_t> cache_allocated_size_;
|
||||
std::size_t memory_used_;
|
||||
std::vector<Cache::Handle *> dummy_handles_;
|
||||
std::vector<Cache::Handle*> dummy_handles_;
|
||||
CacheKey cache_key_;
|
||||
};
|
||||
|
||||
@@ -251,14 +251,14 @@ class ConcurrentCacheReservationManager
|
||||
std::shared_ptr<CacheReservationManager> cache_res_mgr) {
|
||||
cache_res_mgr_ = std::move(cache_res_mgr);
|
||||
}
|
||||
ConcurrentCacheReservationManager(const ConcurrentCacheReservationManager &) =
|
||||
ConcurrentCacheReservationManager(const ConcurrentCacheReservationManager&) =
|
||||
delete;
|
||||
ConcurrentCacheReservationManager &operator=(
|
||||
const ConcurrentCacheReservationManager &) = delete;
|
||||
ConcurrentCacheReservationManager(ConcurrentCacheReservationManager &&) =
|
||||
ConcurrentCacheReservationManager& operator=(
|
||||
const ConcurrentCacheReservationManager&) = delete;
|
||||
ConcurrentCacheReservationManager(ConcurrentCacheReservationManager&&) =
|
||||
delete;
|
||||
ConcurrentCacheReservationManager &operator=(
|
||||
ConcurrentCacheReservationManager &&) = delete;
|
||||
ConcurrentCacheReservationManager& operator=(
|
||||
ConcurrentCacheReservationManager&&) = delete;
|
||||
|
||||
~ConcurrentCacheReservationManager() override {}
|
||||
|
||||
@@ -286,7 +286,7 @@ class ConcurrentCacheReservationManager
|
||||
|
||||
inline Status MakeCacheReservation(
|
||||
std::size_t incremental_memory_used,
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle> *handle)
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle>* handle)
|
||||
override {
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle>
|
||||
wrapped_handle;
|
||||
|
||||
@@ -1427,8 +1427,12 @@ TEST_F(DBBasicTestWithTimestamp, ReseekToNextUserKey) {
|
||||
{
|
||||
std::string ts_str = Timestamp(static_cast<uint64_t>(kNumKeys + 1), 0);
|
||||
WriteBatch batch(0, 0, 0, kTimestampSize);
|
||||
{ ASSERT_OK(batch.Put("a", "new_value")); }
|
||||
{ ASSERT_OK(batch.Put("b", "new_value")); }
|
||||
{
|
||||
ASSERT_OK(batch.Put("a", "new_value"));
|
||||
}
|
||||
{
|
||||
ASSERT_OK(batch.Put("b", "new_value"));
|
||||
}
|
||||
s = batch.UpdateTimestamps(
|
||||
ts_str, [kTimestampSize](uint32_t) { return kTimestampSize; });
|
||||
ASSERT_OK(s);
|
||||
|
||||
+2
-1
@@ -1188,7 +1188,8 @@ class SstQueryFilterConfigsManagerImpl : public SstQueryFilterConfigsManager {
|
||||
break;
|
||||
default:
|
||||
// TODO? Report problem
|
||||
{}
|
||||
{
|
||||
}
|
||||
// Unknown filter type
|
||||
}
|
||||
if (!may_match) {
|
||||
|
||||
Vendored
+2
-2
@@ -674,7 +674,7 @@ class PosixFileSystem : public FileSystem {
|
||||
|
||||
IOStatus GetFileSize(const std::string& fname, const IOOptions& /*opts*/,
|
||||
uint64_t* size, IODebugContext* /*dbg*/) override {
|
||||
struct stat sbuf {};
|
||||
struct stat sbuf{};
|
||||
if (stat(fname.c_str(), &sbuf) != 0) {
|
||||
*size = 0;
|
||||
return IOError("while stat a file for size", fname, errno);
|
||||
@@ -981,7 +981,7 @@ class PosixFileSystem : public FileSystem {
|
||||
// file size. However this API only works on opened file.
|
||||
IOStatus GetFileSizeOnOpenedFile(const int fd, const std::string& name,
|
||||
uint64_t* size) {
|
||||
struct stat sb {};
|
||||
struct stat sb{};
|
||||
*size = 0;
|
||||
// Get file information using fstat
|
||||
if (fstat(fd, &sb) == -1) {
|
||||
|
||||
Vendored
+1
-1
@@ -610,7 +610,7 @@ PosixRandomAccessFile::PosixRandomAccessFile(
|
||||
PosixRandomAccessFile::~PosixRandomAccessFile() { close(fd_); }
|
||||
|
||||
IOStatus PosixRandomAccessFile::GetFileSize(uint64_t* result) {
|
||||
struct stat sbuf {};
|
||||
struct stat sbuf{};
|
||||
if (fstat(fd_, &sbuf) != 0) {
|
||||
*result = 0;
|
||||
return IOError("While fstat with fd " + std::to_string(fd_), filename_,
|
||||
|
||||
+1
-1
@@ -2728,7 +2728,7 @@ rocksdb_slicetransform_create(
|
||||
unsigned char (*in_range)(void*, const char* key, size_t length),
|
||||
const char* (*name)(void*));
|
||||
extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t*
|
||||
rocksdb_slicetransform_create_fixed_prefix(size_t);
|
||||
rocksdb_slicetransform_create_fixed_prefix(size_t);
|
||||
extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t*
|
||||
rocksdb_slicetransform_create_noop(void);
|
||||
extern ROCKSDB_LIBRARY_API void rocksdb_slicetransform_destroy(
|
||||
|
||||
@@ -44,7 +44,7 @@ void call(Function f, Tuple t) {
|
||||
template <typename... Args>
|
||||
class FunctorWrapper {
|
||||
public:
|
||||
explicit FunctorWrapper(std::function<void(Args...)> functor, Args &&...args)
|
||||
explicit FunctorWrapper(std::function<void(Args...)> functor, Args&&... args)
|
||||
: functor_(std::move(functor)), args_(std::forward<Args>(args)...) {}
|
||||
|
||||
void invoke() { detail::call(functor_, args_); }
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace ROCKSDB_NAMESPACE {
|
||||
// And assuming one generates many SST files in the lifetime of each process,
|
||||
// the probability of ID collisions is much "better than random"; see
|
||||
// https://github.com/pdillinger/unique_id
|
||||
Status GetUniqueIdFromTableProperties(const TableProperties &props,
|
||||
std::string *out_id);
|
||||
Status GetUniqueIdFromTableProperties(const TableProperties& props,
|
||||
std::string* out_id);
|
||||
|
||||
// Computes a 192-bit (24 binary char) stable, universally unique ID
|
||||
// with an extra 64 bits of uniqueness compared to the standard ID. It is only
|
||||
@@ -44,12 +44,12 @@ Status GetUniqueIdFromTableProperties(const TableProperties &props,
|
||||
// example above would expect a global file ID collision every 4 days with
|
||||
// 128-bit IDs (using some worst-case assumptions about process lifetime).
|
||||
// It's 10^17 years with 192-bit IDs.
|
||||
Status GetExtendedUniqueIdFromTableProperties(const TableProperties &props,
|
||||
std::string *out_id);
|
||||
Status GetExtendedUniqueIdFromTableProperties(const TableProperties& props,
|
||||
std::string* out_id);
|
||||
|
||||
// Converts a binary string (unique id) to hexadecimal, with each 64 bits
|
||||
// separated by '-', e.g. 6474DF650323BDF0-B48E64F3039308CA-17284B32E7F7444B
|
||||
// Also works on unique id prefix.
|
||||
std::string UniqueIdToHumanString(const std::string &id);
|
||||
std::string UniqueIdToHumanString(const std::string& id);
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
* Method: disposeInternal
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_ConfigOptions_disposeInternalJni(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_ConfigOptions_disposeInternalJni(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
auto *co = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(jhandle);
|
||||
auto* co = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions*>(jhandle);
|
||||
assert(co != nullptr);
|
||||
delete co;
|
||||
}
|
||||
@@ -31,8 +31,8 @@ void Java_org_rocksdb_ConfigOptions_disposeInternalJni(JNIEnv *, jclass,
|
||||
* Method: newConfigOptions
|
||||
* Signature: ()J
|
||||
*/
|
||||
jlong Java_org_rocksdb_ConfigOptions_newConfigOptions(JNIEnv *, jclass) {
|
||||
auto *cfg_opt = new ROCKSDB_NAMESPACE::ConfigOptions();
|
||||
jlong Java_org_rocksdb_ConfigOptions_newConfigOptions(JNIEnv*, jclass) {
|
||||
auto* cfg_opt = new ROCKSDB_NAMESPACE::ConfigOptions();
|
||||
return GET_CPLUSPLUS_POINTER(cfg_opt);
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ jlong Java_org_rocksdb_ConfigOptions_newConfigOptions(JNIEnv *, jclass) {
|
||||
* Method: setEnv
|
||||
* Signature: (JJ;)V
|
||||
*/
|
||||
void Java_org_rocksdb_ConfigOptions_setEnv(JNIEnv *, jclass, jlong handle,
|
||||
void Java_org_rocksdb_ConfigOptions_setEnv(JNIEnv*, jclass, jlong handle,
|
||||
jlong rocksdb_env_handle) {
|
||||
auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle);
|
||||
auto *rocksdb_env =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Env *>(rocksdb_env_handle);
|
||||
auto* cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions*>(handle);
|
||||
auto* rocksdb_env =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(rocksdb_env_handle);
|
||||
cfg_opt->env = rocksdb_env;
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ void Java_org_rocksdb_ConfigOptions_setEnv(JNIEnv *, jclass, jlong handle,
|
||||
* Method: setDelimiter
|
||||
* Signature: (JLjava/lang/String;)V
|
||||
*/
|
||||
void Java_org_rocksdb_ConfigOptions_setDelimiter(JNIEnv *env, jclass,
|
||||
void Java_org_rocksdb_ConfigOptions_setDelimiter(JNIEnv* env, jclass,
|
||||
jlong handle, jstring s) {
|
||||
auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle);
|
||||
const char *delim = env->GetStringUTFChars(s, nullptr);
|
||||
auto* cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions*>(handle);
|
||||
const char* delim = env->GetStringUTFChars(s, nullptr);
|
||||
if (delim == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
@@ -71,10 +71,10 @@ void Java_org_rocksdb_ConfigOptions_setDelimiter(JNIEnv *env, jclass,
|
||||
* Method: setIgnoreUnknownOptions
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_ConfigOptions_setIgnoreUnknownOptions(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_ConfigOptions_setIgnoreUnknownOptions(JNIEnv*, jclass,
|
||||
jlong handle,
|
||||
jboolean b) {
|
||||
auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle);
|
||||
auto* cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions*>(handle);
|
||||
cfg_opt->ignore_unknown_options = static_cast<bool>(b);
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ void Java_org_rocksdb_ConfigOptions_setIgnoreUnknownOptions(JNIEnv *, jclass,
|
||||
* Method: setInputStringsEscaped
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_ConfigOptions_setInputStringsEscaped(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_ConfigOptions_setInputStringsEscaped(JNIEnv*, jclass,
|
||||
jlong handle,
|
||||
jboolean b) {
|
||||
auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle);
|
||||
auto* cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions*>(handle);
|
||||
cfg_opt->input_strings_escaped = static_cast<bool>(b);
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ void Java_org_rocksdb_ConfigOptions_setInputStringsEscaped(JNIEnv *, jclass,
|
||||
* Method: setSanityLevel
|
||||
* Signature: (JI)V
|
||||
*/
|
||||
void Java_org_rocksdb_ConfigOptions_setSanityLevel(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_ConfigOptions_setSanityLevel(JNIEnv*, jclass,
|
||||
jlong handle, jbyte level) {
|
||||
auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle);
|
||||
auto* cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions*>(handle);
|
||||
cfg_opt->sanity_level =
|
||||
ROCKSDB_NAMESPACE::SanityLevelJni::toCppSanityLevel(level);
|
||||
}
|
||||
|
||||
@@ -13,28 +13,28 @@
|
||||
#include "rocksdb/env.h"
|
||||
#include "rocksjni/cplusplus_to_java_convert.h"
|
||||
|
||||
#define ENV_OPTIONS_SET_BOOL(_jhandle, _opt) \
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt = \
|
||||
#define ENV_OPTIONS_SET_BOOL(_jhandle, _opt) \
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions*>(_jhandle)->_opt = \
|
||||
static_cast<bool>(_opt)
|
||||
|
||||
#define ENV_OPTIONS_SET_SIZE_T(_jhandle, _opt) \
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt = \
|
||||
#define ENV_OPTIONS_SET_SIZE_T(_jhandle, _opt) \
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions*>(_jhandle)->_opt = \
|
||||
static_cast<size_t>(_opt)
|
||||
|
||||
#define ENV_OPTIONS_SET_UINT64_T(_jhandle, _opt) \
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt = \
|
||||
#define ENV_OPTIONS_SET_UINT64_T(_jhandle, _opt) \
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions*>(_jhandle)->_opt = \
|
||||
static_cast<uint64_t>(_opt)
|
||||
|
||||
#define ENV_OPTIONS_GET(_jhandle, _opt) \
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions*>(_jhandle)->_opt
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_EnvOptions
|
||||
* Method: newEnvOptions
|
||||
* Signature: ()J
|
||||
*/
|
||||
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__(JNIEnv *, jclass) {
|
||||
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions();
|
||||
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__(JNIEnv*, jclass) {
|
||||
auto* env_opt = new ROCKSDB_NAMESPACE::EnvOptions();
|
||||
return GET_CPLUSPLUS_POINTER(env_opt);
|
||||
}
|
||||
|
||||
@@ -43,11 +43,11 @@ jlong Java_org_rocksdb_EnvOptions_newEnvOptions__(JNIEnv *, jclass) {
|
||||
* Method: newEnvOptions
|
||||
* Signature: (J)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J(JNIEnv *, jclass,
|
||||
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J(JNIEnv*, jclass,
|
||||
jlong jdboptions_handle) {
|
||||
auto *db_options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions *>(jdboptions_handle);
|
||||
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions(*db_options);
|
||||
auto* db_options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jdboptions_handle);
|
||||
auto* env_opt = new ROCKSDB_NAMESPACE::EnvOptions(*db_options);
|
||||
return GET_CPLUSPLUS_POINTER(env_opt);
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J(JNIEnv *, jclass,
|
||||
* Method: disposeInternal
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_disposeInternalJni(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_EnvOptions_disposeInternalJni(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
auto *eo = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(jhandle);
|
||||
auto* eo = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions*>(jhandle);
|
||||
assert(eo != nullptr);
|
||||
delete eo;
|
||||
}
|
||||
@@ -68,8 +68,7 @@ void Java_org_rocksdb_EnvOptions_disposeInternalJni(JNIEnv *, jclass,
|
||||
* Method: setUseMmapReads
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv *, jclass,
|
||||
jlong jhandle,
|
||||
void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv*, jclass, jlong jhandle,
|
||||
jboolean use_mmap_reads) {
|
||||
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_reads);
|
||||
}
|
||||
@@ -79,7 +78,7 @@ void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv *, jclass,
|
||||
* Method: useMmapReads
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv *, jclass,
|
||||
jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, use_mmap_reads);
|
||||
}
|
||||
@@ -89,7 +88,7 @@ jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv *, jclass,
|
||||
* Method: setUseMmapWrites
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv*, jclass,
|
||||
jlong jhandle,
|
||||
jboolean use_mmap_writes) {
|
||||
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_writes);
|
||||
@@ -100,7 +99,7 @@ void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv *, jclass,
|
||||
* Method: useMmapWrites
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv *, jclass,
|
||||
jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, use_mmap_writes);
|
||||
}
|
||||
@@ -110,7 +109,7 @@ jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv *, jclass,
|
||||
* Method: setUseDirectReads
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv*, jclass,
|
||||
jlong jhandle,
|
||||
jboolean use_direct_reads) {
|
||||
ENV_OPTIONS_SET_BOOL(jhandle, use_direct_reads);
|
||||
@@ -121,7 +120,7 @@ void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv *, jclass,
|
||||
* Method: useDirectReads
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv *, jclass,
|
||||
jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, use_direct_reads);
|
||||
}
|
||||
@@ -132,7 +131,7 @@ jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv *, jclass,
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setUseDirectWrites(
|
||||
JNIEnv *, jclass, jlong jhandle, jboolean use_direct_writes) {
|
||||
JNIEnv*, jclass, jlong jhandle, jboolean use_direct_writes) {
|
||||
ENV_OPTIONS_SET_BOOL(jhandle, use_direct_writes);
|
||||
}
|
||||
|
||||
@@ -141,7 +140,7 @@ void Java_org_rocksdb_EnvOptions_setUseDirectWrites(
|
||||
* Method: useDirectWrites
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv *, jclass,
|
||||
jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, use_direct_writes);
|
||||
}
|
||||
@@ -151,7 +150,7 @@ jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv *, jclass,
|
||||
* Method: setAllowFallocate
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv *, jclass,
|
||||
void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv*, jclass,
|
||||
jlong jhandle,
|
||||
jboolean allow_fallocate) {
|
||||
ENV_OPTIONS_SET_BOOL(jhandle, allow_fallocate);
|
||||
@@ -162,7 +161,7 @@ void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv *, jclass,
|
||||
* Method: allowFallocate
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv *, jclass,
|
||||
jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, allow_fallocate);
|
||||
}
|
||||
@@ -172,8 +171,7 @@ jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv *, jclass,
|
||||
* Method: setSetFdCloexec
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv *, jclass,
|
||||
jlong jhandle,
|
||||
void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv*, jclass, jlong jhandle,
|
||||
jboolean set_fd_cloexec) {
|
||||
ENV_OPTIONS_SET_BOOL(jhandle, set_fd_cloexec);
|
||||
}
|
||||
@@ -183,7 +181,7 @@ void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv *, jclass,
|
||||
* Method: setFdCloexec
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv *, jclass,
|
||||
jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, set_fd_cloexec);
|
||||
}
|
||||
@@ -193,8 +191,7 @@ jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv *, jclass,
|
||||
* Method: setBytesPerSync
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv *, jclass,
|
||||
jlong jhandle,
|
||||
void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv*, jclass, jlong jhandle,
|
||||
jlong bytes_per_sync) {
|
||||
ENV_OPTIONS_SET_UINT64_T(jhandle, bytes_per_sync);
|
||||
}
|
||||
@@ -204,8 +201,7 @@ void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv *, jclass,
|
||||
* Method: bytesPerSync
|
||||
* Signature: (J)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv *, jclass,
|
||||
jlong jhandle) {
|
||||
jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv*, jclass, jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, bytes_per_sync);
|
||||
}
|
||||
|
||||
@@ -215,7 +211,7 @@ jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv *, jclass,
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setFallocateWithKeepSize(
|
||||
JNIEnv *, jclass, jlong jhandle, jboolean fallocate_with_keep_size) {
|
||||
JNIEnv*, jclass, jlong jhandle, jboolean fallocate_with_keep_size) {
|
||||
ENV_OPTIONS_SET_BOOL(jhandle, fallocate_with_keep_size);
|
||||
}
|
||||
|
||||
@@ -224,7 +220,7 @@ void Java_org_rocksdb_EnvOptions_setFallocateWithKeepSize(
|
||||
* Method: fallocateWithKeepSize
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv *, jclass,
|
||||
jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, fallocate_with_keep_size);
|
||||
}
|
||||
@@ -235,7 +231,7 @@ jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv *, jclass,
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setCompactionReadaheadSize(
|
||||
JNIEnv *, jclass, jlong jhandle, jlong compaction_readahead_size) {
|
||||
JNIEnv*, jclass, jlong jhandle, jlong compaction_readahead_size) {
|
||||
ENV_OPTIONS_SET_SIZE_T(jhandle, compaction_readahead_size);
|
||||
}
|
||||
|
||||
@@ -244,7 +240,7 @@ void Java_org_rocksdb_EnvOptions_setCompactionReadaheadSize(
|
||||
* Method: compactionReadaheadSize
|
||||
* Signature: (J)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv *, jclass,
|
||||
jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, compaction_readahead_size);
|
||||
}
|
||||
@@ -255,7 +251,7 @@ jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv *, jclass,
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setWritableFileMaxBufferSize(
|
||||
JNIEnv *, jclass, jlong jhandle, jlong writable_file_max_buffer_size) {
|
||||
JNIEnv*, jclass, jlong jhandle, jlong writable_file_max_buffer_size) {
|
||||
ENV_OPTIONS_SET_SIZE_T(jhandle, writable_file_max_buffer_size);
|
||||
}
|
||||
|
||||
@@ -264,7 +260,7 @@ void Java_org_rocksdb_EnvOptions_setWritableFileMaxBufferSize(
|
||||
* Method: writableFileMaxBufferSize
|
||||
* Signature: (J)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv *, jclass,
|
||||
jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv*, jclass,
|
||||
jlong jhandle) {
|
||||
return ENV_OPTIONS_GET(jhandle, writable_file_max_buffer_size);
|
||||
}
|
||||
@@ -274,11 +270,11 @@ jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv *, jclass,
|
||||
* Method: setRateLimiter
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_EnvOptions_setRateLimiter(JNIEnv *, jclass, jlong jhandle,
|
||||
void Java_org_rocksdb_EnvOptions_setRateLimiter(JNIEnv*, jclass, jlong jhandle,
|
||||
jlong rl_handle) {
|
||||
auto *sptr_rate_limiter =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::RateLimiter> *>(
|
||||
auto* sptr_rate_limiter =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::RateLimiter>*>(
|
||||
rl_handle);
|
||||
auto *env_opt = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(jhandle);
|
||||
auto* env_opt = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions*>(jhandle);
|
||||
env_opt->rate_limiter = sptr_rate_limiter->get();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* Signature: ()J
|
||||
*/
|
||||
jlong Java_org_rocksdb_ImportColumnFamilyOptions_newImportColumnFamilyOptions(
|
||||
JNIEnv *, jclass) {
|
||||
ROCKSDB_NAMESPACE::ImportColumnFamilyOptions *opts =
|
||||
JNIEnv*, jclass) {
|
||||
ROCKSDB_NAMESPACE::ImportColumnFamilyOptions* opts =
|
||||
new ROCKSDB_NAMESPACE::ImportColumnFamilyOptions();
|
||||
return GET_CPLUSPLUS_POINTER(opts);
|
||||
}
|
||||
@@ -28,9 +28,9 @@ jlong Java_org_rocksdb_ImportColumnFamilyOptions_newImportColumnFamilyOptions(
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_ImportColumnFamilyOptions_setMoveFiles(
|
||||
JNIEnv *, jobject, jlong jhandle, jboolean jmove_files) {
|
||||
auto *options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::ImportColumnFamilyOptions *>(jhandle);
|
||||
JNIEnv*, jobject, jlong jhandle, jboolean jmove_files) {
|
||||
auto* options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::ImportColumnFamilyOptions*>(jhandle);
|
||||
options->move_files = static_cast<bool>(jmove_files);
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ void Java_org_rocksdb_ImportColumnFamilyOptions_setMoveFiles(
|
||||
* Method: moveFiles
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_ImportColumnFamilyOptions_moveFiles(JNIEnv *, jobject,
|
||||
jboolean Java_org_rocksdb_ImportColumnFamilyOptions_moveFiles(JNIEnv*, jobject,
|
||||
jlong jhandle) {
|
||||
auto *options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::ImportColumnFamilyOptions *>(jhandle);
|
||||
auto* options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::ImportColumnFamilyOptions*>(jhandle);
|
||||
return static_cast<jboolean>(options->move_files);
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ jboolean Java_org_rocksdb_ImportColumnFamilyOptions_moveFiles(JNIEnv *, jobject,
|
||||
* Method: disposeInternal
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_ImportColumnFamilyOptions_disposeInternal(JNIEnv *,
|
||||
void Java_org_rocksdb_ImportColumnFamilyOptions_disposeInternal(JNIEnv*,
|
||||
jobject,
|
||||
jlong jhandle) {
|
||||
delete reinterpret_cast<ROCKSDB_NAMESPACE::ImportColumnFamilyOptions *>(
|
||||
delete reinterpret_cast<ROCKSDB_NAMESPACE::ImportColumnFamilyOptions*>(
|
||||
jhandle);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class KVException : public std::exception {
|
||||
}
|
||||
}
|
||||
|
||||
KVException(jint code) : kCode_(code){};
|
||||
KVException(jint code) : kCode_(code) {};
|
||||
|
||||
virtual const char* what() const noexcept {
|
||||
return "Exception raised by JNI. There may be a Java exception in the "
|
||||
@@ -176,13 +176,13 @@ class JByteArrayPinnableSlice {
|
||||
: env_(env),
|
||||
jbuffer_(jbuffer),
|
||||
jbuffer_off_(jbuffer_off),
|
||||
jbuffer_len_(jbuffer_len){};
|
||||
jbuffer_len_(jbuffer_len) {};
|
||||
|
||||
/**
|
||||
* @brief Construct an empty new JByteArrayPinnableSlice object
|
||||
*
|
||||
*/
|
||||
JByteArrayPinnableSlice(JNIEnv* env) : env_(env){};
|
||||
JByteArrayPinnableSlice(JNIEnv* env) : env_(env) {};
|
||||
|
||||
PinnableSlice& pinnable_slice() { return pinnable_slice_; }
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
* Signature: ([J[J)Ljava/util/Map;
|
||||
*/
|
||||
jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
|
||||
JNIEnv *env, jclass, jlongArray jdb_handles, jlongArray jcache_handles) {
|
||||
JNIEnv* env, jclass, jlongArray jdb_handles, jlongArray jcache_handles) {
|
||||
jboolean has_exception = JNI_FALSE;
|
||||
std::vector<ROCKSDB_NAMESPACE::DB *> dbs =
|
||||
std::vector<ROCKSDB_NAMESPACE::DB*> dbs =
|
||||
ROCKSDB_NAMESPACE::JniUtil::fromJPointers<ROCKSDB_NAMESPACE::DB>(
|
||||
env, jdb_handles, &has_exception);
|
||||
if (has_exception == JNI_TRUE) {
|
||||
@@ -31,18 +31,18 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unordered_set<const ROCKSDB_NAMESPACE::Cache *> cache_set;
|
||||
std::unordered_set<const ROCKSDB_NAMESPACE::Cache*> cache_set;
|
||||
jsize cache_handle_count = env->GetArrayLength(jcache_handles);
|
||||
if (cache_handle_count > 0) {
|
||||
jlong *ptr_jcache_handles =
|
||||
jlong* ptr_jcache_handles =
|
||||
env->GetLongArrayElements(jcache_handles, nullptr);
|
||||
if (ptr_jcache_handles == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return nullptr;
|
||||
}
|
||||
for (jsize i = 0; i < cache_handle_count; i++) {
|
||||
auto *cache_ptr =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache> *>(
|
||||
auto* cache_ptr =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache>*>(
|
||||
ptr_jcache_handles[i]);
|
||||
cache_set.insert(cache_ptr->get());
|
||||
}
|
||||
@@ -68,7 +68,7 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
|
||||
jobject>
|
||||
fn_map_kv = [env](
|
||||
const std::pair<ROCKSDB_NAMESPACE::MemoryUtil::UsageType,
|
||||
uint64_t> &pair) {
|
||||
uint64_t>& pair) {
|
||||
// Construct key
|
||||
const jobject jusage_type = ROCKSDB_NAMESPACE::ByteJni::valueOf(
|
||||
env, ROCKSDB_NAMESPACE::MemoryUsageTypeJni::toJavaMemoryUsageType(
|
||||
|
||||
@@ -67,11 +67,11 @@ jlong rocksdb_open_helper(JNIEnv* env, jlong jopt_handle, jstring jdb_path,
|
||||
jlong Java_org_rocksdb_RocksDB_open__JLjava_lang_String_2(JNIEnv* env, jclass,
|
||||
jlong jopt_handle,
|
||||
jstring jdb_path) {
|
||||
return rocksdb_open_helper(env, jopt_handle, jdb_path,
|
||||
(ROCKSDB_NAMESPACE::Status(*)(
|
||||
const ROCKSDB_NAMESPACE::Options&,
|
||||
const std::string&, ROCKSDB_NAMESPACE::DB**)) &
|
||||
ROCKSDB_NAMESPACE::DB::Open);
|
||||
return rocksdb_open_helper(
|
||||
env, jopt_handle, jdb_path,
|
||||
(ROCKSDB_NAMESPACE::Status (*)(
|
||||
const ROCKSDB_NAMESPACE::Options&, const std::string&,
|
||||
ROCKSDB_NAMESPACE::DB**))&ROCKSDB_NAMESPACE::DB::Open);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -213,12 +213,11 @@ jlongArray Java_org_rocksdb_RocksDB_open__JLjava_lang_String_2_3_3B_3J(
|
||||
jobjectArray jcolumn_names, jlongArray jcolumn_options) {
|
||||
return rocksdb_open_helper(
|
||||
env, jopt_handle, jdb_path, jcolumn_names, jcolumn_options,
|
||||
(ROCKSDB_NAMESPACE::Status(*)(
|
||||
(ROCKSDB_NAMESPACE::Status (*)(
|
||||
const ROCKSDB_NAMESPACE::DBOptions&, const std::string&,
|
||||
const std::vector<ROCKSDB_NAMESPACE::ColumnFamilyDescriptor>&,
|
||||
std::vector<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>*,
|
||||
ROCKSDB_NAMESPACE::DB**)) &
|
||||
ROCKSDB_NAMESPACE::DB::Open);
|
||||
ROCKSDB_NAMESPACE::DB**))&ROCKSDB_NAMESPACE::DB::Open);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
* Method: newSstFileReader
|
||||
* Signature: (J)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_SstFileReader_newSstFileReader(JNIEnv * /*env*/,
|
||||
jlong Java_org_rocksdb_SstFileReader_newSstFileReader(JNIEnv* /*env*/,
|
||||
jclass /*jcls*/,
|
||||
jlong joptions) {
|
||||
auto *options =
|
||||
reinterpret_cast<const ROCKSDB_NAMESPACE::Options *>(joptions);
|
||||
ROCKSDB_NAMESPACE::SstFileReader *sst_file_reader =
|
||||
auto* options = reinterpret_cast<const ROCKSDB_NAMESPACE::Options*>(joptions);
|
||||
ROCKSDB_NAMESPACE::SstFileReader* sst_file_reader =
|
||||
new ROCKSDB_NAMESPACE::SstFileReader(*options);
|
||||
return GET_CPLUSPLUS_POINTER(sst_file_reader);
|
||||
}
|
||||
@@ -39,15 +38,15 @@ jlong Java_org_rocksdb_SstFileReader_newSstFileReader(JNIEnv * /*env*/,
|
||||
* Method: open
|
||||
* Signature: (JLjava/lang/String;)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileReader_open(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileReader_open(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle, jstring jfile_path) {
|
||||
const char *file_path = env->GetStringUTFChars(jfile_path, nullptr);
|
||||
const char* file_path = env->GetStringUTFChars(jfile_path, nullptr);
|
||||
if (file_path == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
}
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader *>(jhandle)->Open(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader*>(jhandle)->Open(
|
||||
file_path);
|
||||
env->ReleaseStringUTFChars(jfile_path, file_path);
|
||||
|
||||
@@ -61,13 +60,13 @@ void Java_org_rocksdb_SstFileReader_open(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: newIterator
|
||||
* Signature: (JJ)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_SstFileReader_newIterator(JNIEnv * /*env*/,
|
||||
jlong Java_org_rocksdb_SstFileReader_newIterator(JNIEnv* /*env*/,
|
||||
jclass /*jcls*/, jlong jhandle,
|
||||
jlong jread_options_handle) {
|
||||
auto *sst_file_reader =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader *>(jhandle);
|
||||
auto *read_options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions *>(jread_options_handle);
|
||||
auto* sst_file_reader =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader*>(jhandle);
|
||||
auto* read_options =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jread_options_handle);
|
||||
return GET_CPLUSPLUS_POINTER(sst_file_reader->NewIterator(*read_options));
|
||||
}
|
||||
|
||||
@@ -76,10 +75,10 @@ jlong Java_org_rocksdb_SstFileReader_newIterator(JNIEnv * /*env*/,
|
||||
* Method: disposeInternal
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileReader_disposeInternalJni(JNIEnv * /*env*/,
|
||||
void Java_org_rocksdb_SstFileReader_disposeInternalJni(JNIEnv* /*env*/,
|
||||
jclass /*jcls*/,
|
||||
jlong jhandle) {
|
||||
delete reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader *>(jhandle);
|
||||
delete reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader*>(jhandle);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -87,10 +86,10 @@ void Java_org_rocksdb_SstFileReader_disposeInternalJni(JNIEnv * /*env*/,
|
||||
* Method: verifyChecksum
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileReader_verifyChecksum(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileReader_verifyChecksum(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle) {
|
||||
auto *sst_file_reader =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader *>(jhandle);
|
||||
auto* sst_file_reader =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader*>(jhandle);
|
||||
auto s = sst_file_reader->VerifyChecksum();
|
||||
if (!s.ok()) {
|
||||
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
||||
@@ -102,11 +101,11 @@ void Java_org_rocksdb_SstFileReader_verifyChecksum(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: getTableProperties
|
||||
* Signature: (J)J
|
||||
*/
|
||||
jobject Java_org_rocksdb_SstFileReader_getTableProperties(JNIEnv *env,
|
||||
jobject Java_org_rocksdb_SstFileReader_getTableProperties(JNIEnv* env,
|
||||
jclass /*jcls*/,
|
||||
jlong jhandle) {
|
||||
auto *sst_file_reader =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader *>(jhandle);
|
||||
auto* sst_file_reader =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader*>(jhandle);
|
||||
std::shared_ptr<const ROCKSDB_NAMESPACE::TableProperties> tp =
|
||||
sst_file_reader->GetTableProperties();
|
||||
jobject jtable_properties =
|
||||
|
||||
@@ -25,27 +25,26 @@
|
||||
* Signature: (JJJB)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJB(
|
||||
JNIEnv * /*env*/, jclass /*jcls*/, jlong jenvoptions, jlong joptions,
|
||||
JNIEnv* /*env*/, jclass /*jcls*/, jlong jenvoptions, jlong joptions,
|
||||
jlong jcomparator_handle, jbyte jcomparator_type) {
|
||||
ROCKSDB_NAMESPACE::Comparator *comparator = nullptr;
|
||||
ROCKSDB_NAMESPACE::Comparator* comparator = nullptr;
|
||||
switch (jcomparator_type) {
|
||||
// JAVA_COMPARATOR
|
||||
case 0x0:
|
||||
comparator = reinterpret_cast<ROCKSDB_NAMESPACE::ComparatorJniCallback *>(
|
||||
comparator = reinterpret_cast<ROCKSDB_NAMESPACE::ComparatorJniCallback*>(
|
||||
jcomparator_handle);
|
||||
break;
|
||||
|
||||
// JAVA_NATIVE_COMPARATOR_WRAPPER
|
||||
case 0x1:
|
||||
comparator =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Comparator *>(jcomparator_handle);
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Comparator*>(jcomparator_handle);
|
||||
break;
|
||||
}
|
||||
auto *env_options =
|
||||
reinterpret_cast<const ROCKSDB_NAMESPACE::EnvOptions *>(jenvoptions);
|
||||
auto *options =
|
||||
reinterpret_cast<const ROCKSDB_NAMESPACE::Options *>(joptions);
|
||||
ROCKSDB_NAMESPACE::SstFileWriter *sst_file_writer =
|
||||
auto* env_options =
|
||||
reinterpret_cast<const ROCKSDB_NAMESPACE::EnvOptions*>(jenvoptions);
|
||||
auto* options = reinterpret_cast<const ROCKSDB_NAMESPACE::Options*>(joptions);
|
||||
ROCKSDB_NAMESPACE::SstFileWriter* sst_file_writer =
|
||||
new ROCKSDB_NAMESPACE::SstFileWriter(*env_options, *options, comparator);
|
||||
return GET_CPLUSPLUS_POINTER(sst_file_writer);
|
||||
}
|
||||
@@ -55,15 +54,14 @@ jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJB(
|
||||
* Method: newSstFileWriter
|
||||
* Signature: (JJ)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv * /*env*/,
|
||||
jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv* /*env*/,
|
||||
jclass /*jcls*/,
|
||||
jlong jenvoptions,
|
||||
jlong joptions) {
|
||||
auto *env_options =
|
||||
reinterpret_cast<const ROCKSDB_NAMESPACE::EnvOptions *>(jenvoptions);
|
||||
auto *options =
|
||||
reinterpret_cast<const ROCKSDB_NAMESPACE::Options *>(joptions);
|
||||
ROCKSDB_NAMESPACE::SstFileWriter *sst_file_writer =
|
||||
auto* env_options =
|
||||
reinterpret_cast<const ROCKSDB_NAMESPACE::EnvOptions*>(jenvoptions);
|
||||
auto* options = reinterpret_cast<const ROCKSDB_NAMESPACE::Options*>(joptions);
|
||||
ROCKSDB_NAMESPACE::SstFileWriter* sst_file_writer =
|
||||
new ROCKSDB_NAMESPACE::SstFileWriter(*env_options, *options);
|
||||
return GET_CPLUSPLUS_POINTER(sst_file_writer);
|
||||
}
|
||||
@@ -73,15 +71,15 @@ jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv * /*env*/,
|
||||
* Method: open
|
||||
* Signature: (JLjava/lang/String;)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_open(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_open(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle, jstring jfile_path) {
|
||||
const char *file_path = env->GetStringUTFChars(jfile_path, nullptr);
|
||||
const char* file_path = env->GetStringUTFChars(jfile_path, nullptr);
|
||||
if (file_path == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
}
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Open(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Open(
|
||||
file_path);
|
||||
env->ReleaseStringUTFChars(jfile_path, file_path);
|
||||
|
||||
@@ -95,14 +93,14 @@ void Java_org_rocksdb_SstFileWriter_open(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: put
|
||||
* Signature: (JJJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_put__JJJ(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_put__JJJ(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle, jlong jkey_handle,
|
||||
jlong jvalue_handle) {
|
||||
auto *key_slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice *>(jkey_handle);
|
||||
auto *value_slice =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Slice *>(jvalue_handle);
|
||||
auto* key_slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(jkey_handle);
|
||||
auto* value_slice =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(jvalue_handle);
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Put(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Put(
|
||||
*key_slice, *value_slice);
|
||||
if (!s.ok()) {
|
||||
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
||||
@@ -114,28 +112,28 @@ void Java_org_rocksdb_SstFileWriter_put__JJJ(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: put
|
||||
* Signature: (JJJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_put__J_3B_3B(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_put__J_3B_3B(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle, jbyteArray jkey,
|
||||
jbyteArray jval) {
|
||||
jbyte *key = env->GetByteArrayElements(jkey, nullptr);
|
||||
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
|
||||
if (key == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
}
|
||||
ROCKSDB_NAMESPACE::Slice key_slice(reinterpret_cast<char *>(key),
|
||||
ROCKSDB_NAMESPACE::Slice key_slice(reinterpret_cast<char*>(key),
|
||||
env->GetArrayLength(jkey));
|
||||
|
||||
jbyte *value = env->GetByteArrayElements(jval, nullptr);
|
||||
jbyte* value = env->GetByteArrayElements(jval, nullptr);
|
||||
if (value == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
|
||||
return;
|
||||
}
|
||||
ROCKSDB_NAMESPACE::Slice value_slice(reinterpret_cast<char *>(value),
|
||||
ROCKSDB_NAMESPACE::Slice value_slice(reinterpret_cast<char*>(value),
|
||||
env->GetArrayLength(jval));
|
||||
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Put(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Put(
|
||||
key_slice, value_slice);
|
||||
|
||||
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
|
||||
@@ -151,15 +149,15 @@ void Java_org_rocksdb_SstFileWriter_put__J_3B_3B(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: putDirect
|
||||
* Signature: (JLjava/nio/ByteBuffer;IILjava/nio/ByteBuffer;II)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_putDirect(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_putDirect(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jdb_handle, jobject jkey,
|
||||
jint jkey_off, jint jkey_len,
|
||||
jobject jval, jint jval_off,
|
||||
jint jval_len) {
|
||||
auto *writer =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jdb_handle);
|
||||
auto put = [&env, &writer](ROCKSDB_NAMESPACE::Slice &key,
|
||||
ROCKSDB_NAMESPACE::Slice &value) {
|
||||
auto* writer =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jdb_handle);
|
||||
auto put = [&env, &writer](ROCKSDB_NAMESPACE::Slice& key,
|
||||
ROCKSDB_NAMESPACE::Slice& value) {
|
||||
ROCKSDB_NAMESPACE::Status s = writer->Put(key, value);
|
||||
if (s.ok()) {
|
||||
return;
|
||||
@@ -175,10 +173,10 @@ void Java_org_rocksdb_SstFileWriter_putDirect(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: fileSize
|
||||
* Signature: (J)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_SstFileWriter_fileSize(JNIEnv * /*env*/, jclass /*jcls*/,
|
||||
jlong Java_org_rocksdb_SstFileWriter_fileSize(JNIEnv* /*env*/, jclass /*jcls*/,
|
||||
jlong jdb_handle) {
|
||||
auto *writer =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jdb_handle);
|
||||
auto* writer =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jdb_handle);
|
||||
return static_cast<jlong>(writer->FileSize());
|
||||
}
|
||||
|
||||
@@ -187,14 +185,14 @@ jlong Java_org_rocksdb_SstFileWriter_fileSize(JNIEnv * /*env*/, jclass /*jcls*/,
|
||||
* Method: merge
|
||||
* Signature: (JJJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_merge__JJJ(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_merge__JJJ(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle, jlong jkey_handle,
|
||||
jlong jvalue_handle) {
|
||||
auto *key_slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice *>(jkey_handle);
|
||||
auto *value_slice =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Slice *>(jvalue_handle);
|
||||
auto* key_slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(jkey_handle);
|
||||
auto* value_slice =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(jvalue_handle);
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Merge(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Merge(
|
||||
*key_slice, *value_slice);
|
||||
if (!s.ok()) {
|
||||
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
||||
@@ -206,29 +204,29 @@ void Java_org_rocksdb_SstFileWriter_merge__JJJ(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: merge
|
||||
* Signature: (J[B[B)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_merge__J_3B_3B(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_merge__J_3B_3B(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle,
|
||||
jbyteArray jkey,
|
||||
jbyteArray jval) {
|
||||
jbyte *key = env->GetByteArrayElements(jkey, nullptr);
|
||||
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
|
||||
if (key == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
}
|
||||
ROCKSDB_NAMESPACE::Slice key_slice(reinterpret_cast<char *>(key),
|
||||
ROCKSDB_NAMESPACE::Slice key_slice(reinterpret_cast<char*>(key),
|
||||
env->GetArrayLength(jkey));
|
||||
|
||||
jbyte *value = env->GetByteArrayElements(jval, nullptr);
|
||||
jbyte* value = env->GetByteArrayElements(jval, nullptr);
|
||||
if (value == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
|
||||
return;
|
||||
}
|
||||
ROCKSDB_NAMESPACE::Slice value_slice(reinterpret_cast<char *>(value),
|
||||
ROCKSDB_NAMESPACE::Slice value_slice(reinterpret_cast<char*>(value),
|
||||
env->GetArrayLength(jval));
|
||||
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Merge(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Merge(
|
||||
key_slice, value_slice);
|
||||
|
||||
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
|
||||
@@ -244,19 +242,19 @@ void Java_org_rocksdb_SstFileWriter_merge__J_3B_3B(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: delete
|
||||
* Signature: (JJJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_delete__J_3B(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_delete__J_3B(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle,
|
||||
jbyteArray jkey) {
|
||||
jbyte *key = env->GetByteArrayElements(jkey, nullptr);
|
||||
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
|
||||
if (key == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
}
|
||||
ROCKSDB_NAMESPACE::Slice key_slice(reinterpret_cast<char *>(key),
|
||||
ROCKSDB_NAMESPACE::Slice key_slice(reinterpret_cast<char*>(key),
|
||||
env->GetArrayLength(jkey));
|
||||
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Delete(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Delete(
|
||||
key_slice);
|
||||
|
||||
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
|
||||
@@ -271,12 +269,12 @@ void Java_org_rocksdb_SstFileWriter_delete__J_3B(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: delete
|
||||
* Signature: (JJJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_delete__JJ(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_delete__JJ(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle,
|
||||
jlong jkey_handle) {
|
||||
auto *key_slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice *>(jkey_handle);
|
||||
auto* key_slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(jkey_handle);
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Delete(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Delete(
|
||||
*key_slice);
|
||||
if (!s.ok()) {
|
||||
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
||||
@@ -288,10 +286,10 @@ void Java_org_rocksdb_SstFileWriter_delete__JJ(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: finish
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_finish(JNIEnv *env, jclass /*jcls*/,
|
||||
void Java_org_rocksdb_SstFileWriter_finish(JNIEnv* env, jclass /*jcls*/,
|
||||
jlong jhandle) {
|
||||
ROCKSDB_NAMESPACE::Status s =
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle)->Finish();
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle)->Finish();
|
||||
if (!s.ok()) {
|
||||
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
||||
}
|
||||
@@ -302,8 +300,8 @@ void Java_org_rocksdb_SstFileWriter_finish(JNIEnv *env, jclass /*jcls*/,
|
||||
* Method: disposeInternal
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_SstFileWriter_disposeInternalJni(JNIEnv * /*env*/,
|
||||
void Java_org_rocksdb_SstFileWriter_disposeInternalJni(JNIEnv* /*env*/,
|
||||
jclass /*jobj*/,
|
||||
jlong jhandle) {
|
||||
delete reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter *>(jhandle);
|
||||
delete reinterpret_cast<ROCKSDB_NAMESPACE::SstFileWriter*>(jhandle);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* Signature: (IIDIIBZZ)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_PlainTableConfig_newTableFactoryHandle(
|
||||
JNIEnv * /*env*/, jclass /*jcls*/, jint jkey_size, jint jbloom_bits_per_key,
|
||||
JNIEnv* /*env*/, jclass /*jcls*/, jint jkey_size, jint jbloom_bits_per_key,
|
||||
jdouble jhash_table_ratio, jint jindex_sparseness, jint jhuge_page_tlb_size,
|
||||
jbyte jencoding_type, jboolean jfull_scan_mode,
|
||||
jboolean jstore_index_in_file) {
|
||||
@@ -48,7 +48,7 @@ jlong Java_org_rocksdb_PlainTableConfig_newTableFactoryHandle(
|
||||
* Signature: (ZZZZBBDBZJJJIIIJZZZJZZIIZZJJBJI)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
|
||||
JNIEnv *, jclass, jboolean jcache_index_and_filter_blocks,
|
||||
JNIEnv*, jclass, jboolean jcache_index_and_filter_blocks,
|
||||
jboolean jcache_index_and_filter_blocks_with_high_priority,
|
||||
jboolean jpin_l0_filter_and_index_blocks_in_cache,
|
||||
jboolean jpin_top_level_index_and_filter, jbyte jindex_type_value,
|
||||
@@ -89,8 +89,8 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
|
||||
options.block_cache = nullptr;
|
||||
} else {
|
||||
if (jblock_cache_handle > 0) {
|
||||
std::shared_ptr<ROCKSDB_NAMESPACE::Cache> *pCache =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache> *>(
|
||||
std::shared_ptr<ROCKSDB_NAMESPACE::Cache>* pCache =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache>*>(
|
||||
jblock_cache_handle);
|
||||
options.block_cache = *pCache;
|
||||
} else if (jblock_cache_size >= 0) {
|
||||
@@ -108,8 +108,8 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
|
||||
}
|
||||
}
|
||||
if (jpersistent_cache_handle > 0) {
|
||||
std::shared_ptr<ROCKSDB_NAMESPACE::PersistentCache> *pCache =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::PersistentCache> *>(
|
||||
std::shared_ptr<ROCKSDB_NAMESPACE::PersistentCache>* pCache =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::PersistentCache>*>(
|
||||
jpersistent_cache_handle);
|
||||
options.persistent_cache = *pCache;
|
||||
}
|
||||
@@ -124,8 +124,8 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
|
||||
static_cast<bool>(joptimize_filters_for_memory);
|
||||
options.use_delta_encoding = static_cast<bool>(juse_delta_encoding);
|
||||
if (jfilter_policy_handle > 0) {
|
||||
std::shared_ptr<ROCKSDB_NAMESPACE::FilterPolicy> *pFilterPolicy =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::FilterPolicy> *>(
|
||||
std::shared_ptr<ROCKSDB_NAMESPACE::FilterPolicy>* pFilterPolicy =
|
||||
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::FilterPolicy>*>(
|
||||
jfilter_policy_handle);
|
||||
options.filter_policy = *pFilterPolicy;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
* Signature: (JJD)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_TablePropertiesCollectorFactory_newCompactOnDeletionCollectorFactory(
|
||||
JNIEnv *, jclass, jlong sliding_window_size, jlong deletion_trigger,
|
||||
JNIEnv*, jclass, jlong sliding_window_size, jlong deletion_trigger,
|
||||
jdouble deletion_ratio) {
|
||||
auto *wrapper = new TablePropertiesCollectorFactoriesJniWrapper();
|
||||
auto* wrapper = new TablePropertiesCollectorFactoriesJniWrapper();
|
||||
wrapper->table_properties_collector_factories =
|
||||
ROCKSDB_NAMESPACE::NewCompactOnDeletionCollectorFactory(
|
||||
sliding_window_size, deletion_trigger, deletion_ratio);
|
||||
@@ -32,8 +32,8 @@ jlong Java_org_rocksdb_TablePropertiesCollectorFactory_newCompactOnDeletionColle
|
||||
* Signature: (J)J
|
||||
*/
|
||||
void Java_org_rocksdb_TablePropertiesCollectorFactory_deleteCompactOnDeletionCollectorFactory(
|
||||
JNIEnv *, jclass, jlong jhandle) {
|
||||
JNIEnv*, jclass, jlong jhandle) {
|
||||
auto instance =
|
||||
reinterpret_cast<TablePropertiesCollectorFactoriesJniWrapper *>(jhandle);
|
||||
reinterpret_cast<TablePropertiesCollectorFactoriesJniWrapper*>(jhandle);
|
||||
delete instance;
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ static TableProperties newTablePropertiesForTest() {
|
||||
* Signature: (J)V
|
||||
*/
|
||||
void Java_org_rocksdb_test_TestableEventListener_invokeAllCallbacks(
|
||||
JNIEnv *, jclass, jlong jhandle) {
|
||||
const auto &el =
|
||||
*reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::EventListener> *>(
|
||||
JNIEnv*, jclass, jlong jhandle) {
|
||||
const auto& el =
|
||||
*reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::EventListener>*>(
|
||||
jhandle);
|
||||
|
||||
TableProperties table_properties = newTablePropertiesForTest();
|
||||
@@ -127,7 +127,7 @@ void Java_org_rocksdb_test_TestableEventListener_invokeAllCallbacks(
|
||||
compaction_job_info.output_file_infos = {};
|
||||
compaction_job_info.table_properties = {
|
||||
{"tableProperties", std::shared_ptr<TableProperties>(
|
||||
&table_properties, [](TableProperties *) {})}};
|
||||
&table_properties, [](TableProperties*) {})}};
|
||||
compaction_job_info.compaction_reason = CompactionReason::kFlush;
|
||||
compaction_job_info.compression = CompressionType::kSnappyCompression;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ struct KeyMaker {
|
||||
// To get range [avg_size - 2, avg_size + 2]
|
||||
// use range [smallest_size, smallest_size + 4]
|
||||
len += FastRange32((val_num >> 5) * 1234567891, 5);
|
||||
char *data = buf_.get() + start;
|
||||
char* data = buf_.get() + start;
|
||||
// Populate key data such that all data makes it into a key of at
|
||||
// least 8 bytes. We also don't want all the within-filter key
|
||||
// variance confined to a contiguous 32 bits, because then a 32 bit
|
||||
@@ -51,7 +51,7 @@ struct KeyMaker {
|
||||
// 1. filter config bits_per_key
|
||||
// 2. average data key length
|
||||
// 3. data entry number
|
||||
static void CustomArguments(benchmark::internal::Benchmark *b) {
|
||||
static void CustomArguments(benchmark::internal::Benchmark* b) {
|
||||
const auto kImplCount =
|
||||
static_cast<int>(BloomLikeFilterPolicy::GetAllFixedImpls().size());
|
||||
for (int filter_impl = 0; filter_impl < kImplCount; ++filter_impl) {
|
||||
@@ -66,7 +66,7 @@ static void CustomArguments(benchmark::internal::Benchmark *b) {
|
||||
b->ArgNames({"filter_impl", "bits_per_key", "key_len_avg", "entry_num"});
|
||||
}
|
||||
|
||||
static void FilterBuild(benchmark::State &state) {
|
||||
static void FilterBuild(benchmark::State& state) {
|
||||
// setup data
|
||||
auto filter = BloomLikeFilterPolicy::Create(
|
||||
BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)),
|
||||
@@ -89,7 +89,7 @@ static void FilterBuild(benchmark::State &state) {
|
||||
}
|
||||
BENCHMARK(FilterBuild)->Apply(CustomArguments);
|
||||
|
||||
static void FilterQueryPositive(benchmark::State &state) {
|
||||
static void FilterQueryPositive(benchmark::State& state) {
|
||||
// setup data
|
||||
auto filter = BloomLikeFilterPolicy::Create(
|
||||
BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)),
|
||||
@@ -117,7 +117,7 @@ static void FilterQueryPositive(benchmark::State &state) {
|
||||
}
|
||||
BENCHMARK(FilterQueryPositive)->Apply(CustomArguments);
|
||||
|
||||
static void FilterQueryNegative(benchmark::State &state) {
|
||||
static void FilterQueryNegative(benchmark::State& state) {
|
||||
// setup data
|
||||
auto filter = BloomLikeFilterPolicy::Create(
|
||||
BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)),
|
||||
|
||||
@@ -259,10 +259,10 @@ void PerfContext::Reset() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void PerfContextByLevel::Reset(){
|
||||
void PerfContextByLevel::Reset() {
|
||||
#ifndef NPERF_CONTEXT
|
||||
#define EMIT_FIELDS(x) x = 0;
|
||||
DEF_PERF_CONTEXT_LEVEL_METRICS(EMIT_FIELDS)
|
||||
DEF_PERF_CONTEXT_LEVEL_METRICS(EMIT_FIELDS)
|
||||
#undef EMIT_FIELDS
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ TEST_F(OptionsSettableTest, ColumnFamilyOptionsAllFieldsSettable) {
|
||||
// ColumnFamilyOptions.
|
||||
const OffsetGap kColumnFamilyOptionsExcluded = {
|
||||
{offsetof(struct ColumnFamilyOptions, inplace_callback),
|
||||
sizeof(UpdateStatus(*)(char*, uint32_t*, Slice, std::string*))},
|
||||
sizeof(UpdateStatus (*)(char*, uint32_t*, Slice, std::string*))},
|
||||
{offsetof(struct ColumnFamilyOptions,
|
||||
memtable_insert_with_hint_prefix_extractor),
|
||||
sizeof(std::shared_ptr<const SliceTransform>)},
|
||||
|
||||
+15
-17
@@ -59,33 +59,31 @@ static inline bool HasJemalloc() { return true; }
|
||||
|
||||
// Declare non-standard jemalloc APIs as weak symbols. We can null-check these
|
||||
// symbols to detect whether jemalloc is linked with the binary.
|
||||
extern "C" JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN void JEMALLOC_NOTHROW *
|
||||
extern "C" JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN void JEMALLOC_NOTHROW*
|
||||
mallocx(size_t, int) JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1)
|
||||
__attribute__((__weak__));
|
||||
extern "C" JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN void JEMALLOC_NOTHROW *
|
||||
rallocx(void *, size_t, int) JEMALLOC_ALLOC_SIZE(2) __attribute__((__weak__));
|
||||
extern "C" size_t JEMALLOC_NOTHROW xallocx(void *, size_t, size_t, int)
|
||||
extern "C" JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN void JEMALLOC_NOTHROW*
|
||||
rallocx(void*, size_t, int) JEMALLOC_ALLOC_SIZE(2) __attribute__((__weak__));
|
||||
extern "C" size_t JEMALLOC_NOTHROW xallocx(void*, size_t, size_t, int)
|
||||
__attribute__((__weak__));
|
||||
extern "C" size_t JEMALLOC_NOTHROW sallocx(const void *, int)
|
||||
JEMALLOC_ATTR(pure) __attribute__((__weak__));
|
||||
extern "C" void JEMALLOC_NOTHROW dallocx(void *, int) __attribute__((__weak__));
|
||||
extern "C" void JEMALLOC_NOTHROW sdallocx(void *, size_t, int)
|
||||
extern "C" size_t JEMALLOC_NOTHROW sallocx(const void*, int) JEMALLOC_ATTR(pure)
|
||||
__attribute__((__weak__));
|
||||
extern "C" void JEMALLOC_NOTHROW dallocx(void*, int) __attribute__((__weak__));
|
||||
extern "C" void JEMALLOC_NOTHROW sdallocx(void*, size_t, int)
|
||||
__attribute__((__weak__));
|
||||
extern "C" size_t JEMALLOC_NOTHROW nallocx(size_t, int) JEMALLOC_ATTR(pure)
|
||||
__attribute__((__weak__));
|
||||
extern "C" int JEMALLOC_NOTHROW mallctl(const char *, void *, size_t *, void *,
|
||||
extern "C" int JEMALLOC_NOTHROW mallctl(const char*, void*, size_t*, void*,
|
||||
size_t) __attribute__((__weak__));
|
||||
extern "C" int JEMALLOC_NOTHROW mallctlnametomib(const char *, size_t *,
|
||||
size_t *)
|
||||
extern "C" int JEMALLOC_NOTHROW mallctlnametomib(const char*, size_t*, size_t*)
|
||||
__attribute__((__weak__));
|
||||
extern "C" int JEMALLOC_NOTHROW mallctlbymib(const size_t *, size_t, void *,
|
||||
size_t *, void *, size_t)
|
||||
__attribute__((__weak__));
|
||||
extern "C" void JEMALLOC_NOTHROW
|
||||
malloc_stats_print(void (*)(void *, const char *), void *, const char *)
|
||||
extern "C" int JEMALLOC_NOTHROW mallctlbymib(const size_t*, size_t, void*,
|
||||
size_t*, void*, size_t)
|
||||
__attribute__((__weak__));
|
||||
extern "C" void JEMALLOC_NOTHROW malloc_stats_print(
|
||||
void (*)(void*, const char*), void*, const char*) __attribute__((__weak__));
|
||||
extern "C" size_t JEMALLOC_NOTHROW
|
||||
malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *) JEMALLOC_CXX_THROW
|
||||
malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void*) JEMALLOC_CXX_THROW
|
||||
__attribute__((__weak__));
|
||||
|
||||
// Check if Jemalloc is linked with the binary. Note the main program might be
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
std::string GenerateInternalKey(int primary_key, int secondary_key,
|
||||
int padding_size, Random *rnd,
|
||||
int padding_size, Random* rnd,
|
||||
size_t ts_sz = 0) {
|
||||
char buf[50];
|
||||
char *p = &buf[0];
|
||||
char* p = &buf[0];
|
||||
snprintf(buf, sizeof(buf), "%6d%4d", primary_key, secondary_key);
|
||||
std::string k(p);
|
||||
if (padding_size) {
|
||||
@@ -55,8 +55,8 @@ std::string GenerateInternalKey(int primary_key, int secondary_key,
|
||||
// Generate random key value pairs.
|
||||
// The generated key will be sorted. You can tune the parameters to generated
|
||||
// different kinds of test key/value pairs for different scenario.
|
||||
void GenerateRandomKVs(std::vector<std::string> *keys,
|
||||
std::vector<std::string> *values, const int from,
|
||||
void GenerateRandomKVs(std::vector<std::string>* keys,
|
||||
std::vector<std::string>* values, const int from,
|
||||
const int len, const int step = 1,
|
||||
const int padding_size = 0,
|
||||
const int keys_share_prefix = 1, size_t ts_sz = 0) {
|
||||
@@ -133,7 +133,7 @@ TEST_P(BlockTest, SimpleTest) {
|
||||
|
||||
// read contents of block sequentially
|
||||
int count = 0;
|
||||
InternalIterator *iter = reader.NewDataIterator(
|
||||
InternalIterator* iter = reader.NewDataIterator(
|
||||
options.comparator, kDisableGlobalSequenceNumber, nullptr /* iter */,
|
||||
nullptr /* stats */, false /* block_contents_pinned */,
|
||||
shouldPersistUDT());
|
||||
@@ -169,9 +169,9 @@ TEST_P(BlockTest, SimpleTest) {
|
||||
|
||||
// return the block contents
|
||||
BlockContents GetBlockContents(
|
||||
std::unique_ptr<BlockBuilder> *builder,
|
||||
const std::vector<std::string> &keys,
|
||||
const std::vector<std::string> &values, bool key_use_delta_encoding,
|
||||
std::unique_ptr<BlockBuilder>* builder,
|
||||
const std::vector<std::string>& keys,
|
||||
const std::vector<std::string>& values, bool key_use_delta_encoding,
|
||||
size_t ts_sz, bool should_persist_udt, const int /*prefix_group_size*/ = 1,
|
||||
BlockBasedTableOptions::DataBlockIndexType dblock_index_type =
|
||||
BlockBasedTableOptions::DataBlockIndexType::kDataBlockBinarySearch) {
|
||||
@@ -194,8 +194,8 @@ BlockContents GetBlockContents(
|
||||
}
|
||||
|
||||
void CheckBlockContents(BlockContents contents, const int max_key,
|
||||
const std::vector<std::string> &keys,
|
||||
const std::vector<std::string> &values,
|
||||
const std::vector<std::string>& keys,
|
||||
const std::vector<std::string>& values,
|
||||
bool is_udt_enabled, bool should_persist_udt) {
|
||||
const size_t prefix_size = 6;
|
||||
// create block reader
|
||||
@@ -356,8 +356,8 @@ class BlockReadAmpBitmapSlowAndAccurate {
|
||||
TEST_F(BlockTest, BlockReadAmpBitmap) {
|
||||
uint32_t pin_offset = 0;
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlockReadAmpBitmap:rnd", [&pin_offset](void *arg) {
|
||||
pin_offset = *(static_cast<uint32_t *>(arg));
|
||||
"BlockReadAmpBitmap:rnd", [&pin_offset](void* arg) {
|
||||
pin_offset = *(static_cast<uint32_t*>(arg));
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
std::vector<size_t> block_sizes = {
|
||||
@@ -414,7 +414,7 @@ TEST_F(BlockTest, BlockReadAmpBitmap) {
|
||||
|
||||
for (size_t i = 0; i < random_entries.size(); i++) {
|
||||
read_amp_slow_and_accurate.ResetCheckSequence();
|
||||
auto ¤t_entry = random_entries[rnd.Next() % random_entries.size()];
|
||||
auto& current_entry = random_entries[rnd.Next() % random_entries.size()];
|
||||
|
||||
read_amp_bitmap.Mark(static_cast<uint32_t>(current_entry.first),
|
||||
static_cast<uint32_t>(current_entry.second));
|
||||
@@ -465,7 +465,7 @@ TEST_F(BlockTest, BlockWithReadAmpBitmap) {
|
||||
|
||||
// read contents of block sequentially
|
||||
size_t read_bytes = 0;
|
||||
DataBlockIter *iter = reader.NewDataIterator(
|
||||
DataBlockIter* iter = reader.NewDataIterator(
|
||||
options.comparator, kDisableGlobalSequenceNumber, nullptr, stats.get());
|
||||
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||
iter->value();
|
||||
@@ -496,7 +496,7 @@ TEST_F(BlockTest, BlockWithReadAmpBitmap) {
|
||||
Block reader(std::move(contents), kBytesPerBit, stats.get());
|
||||
|
||||
size_t read_bytes = 0;
|
||||
DataBlockIter *iter = reader.NewDataIterator(
|
||||
DataBlockIter* iter = reader.NewDataIterator(
|
||||
options.comparator, kDisableGlobalSequenceNumber, nullptr, stats.get());
|
||||
for (int i = 0; i < num_records; i++) {
|
||||
Slice k(keys[i]);
|
||||
@@ -530,7 +530,7 @@ TEST_F(BlockTest, BlockWithReadAmpBitmap) {
|
||||
Block reader(std::move(contents), kBytesPerBit, stats.get());
|
||||
|
||||
size_t read_bytes = 0;
|
||||
DataBlockIter *iter = reader.NewDataIterator(
|
||||
DataBlockIter* iter = reader.NewDataIterator(
|
||||
options.comparator, kDisableGlobalSequenceNumber, nullptr, stats.get());
|
||||
std::unordered_set<int> read_keys;
|
||||
for (int i = 0; i < num_records; i++) {
|
||||
@@ -595,9 +595,9 @@ class IndexBlockTest
|
||||
};
|
||||
|
||||
// Similar to GenerateRandomKVs but for index block contents.
|
||||
void GenerateRandomIndexEntries(std::vector<std::string> *separators,
|
||||
std::vector<BlockHandle> *block_handles,
|
||||
std::vector<std::string> *first_keys,
|
||||
void GenerateRandomIndexEntries(std::vector<std::string>* separators,
|
||||
std::vector<BlockHandle>* block_handles,
|
||||
std::vector<std::string>* first_keys,
|
||||
const int len, size_t ts_sz = 0,
|
||||
bool zero_seqno = false) {
|
||||
Random rnd(42);
|
||||
@@ -689,10 +689,10 @@ TEST_P(IndexBlockTest, IndexValueEncodingTest) {
|
||||
Block reader(std::move(contents));
|
||||
|
||||
const bool kTotalOrderSeek = true;
|
||||
IndexBlockIter *kNullIter = nullptr;
|
||||
Statistics *kNullStats = nullptr;
|
||||
IndexBlockIter* kNullIter = nullptr;
|
||||
Statistics* kNullStats = nullptr;
|
||||
// read contents of block sequentially
|
||||
InternalIteratorBase<IndexValue> *iter = reader.NewIndexIterator(
|
||||
InternalIteratorBase<IndexValue>* iter = reader.NewIndexIterator(
|
||||
options.comparator, kDisableGlobalSequenceNumber, kNullIter, kNullStats,
|
||||
kTotalOrderSeek, includeFirstKey(), keyIncludesSeq(),
|
||||
!useValueDeltaEncoding(), false /* block_contents_pinned */,
|
||||
@@ -764,8 +764,8 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
: DBTestBase("block_per_kv_checksum", /*env_do_fsync=*/false) {}
|
||||
|
||||
template <typename TBlockIter>
|
||||
void TestIterateForward(std::unique_ptr<TBlockIter> &biter,
|
||||
size_t &verification_count) {
|
||||
void TestIterateForward(std::unique_ptr<TBlockIter>& biter,
|
||||
size_t& verification_count) {
|
||||
while (biter->Valid()) {
|
||||
verification_count = 0;
|
||||
biter->Next();
|
||||
@@ -776,8 +776,8 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
}
|
||||
|
||||
template <typename TBlockIter>
|
||||
void TestIterateBackward(std::unique_ptr<TBlockIter> &biter,
|
||||
size_t &verification_count) {
|
||||
void TestIterateBackward(std::unique_ptr<TBlockIter>& biter,
|
||||
size_t& verification_count) {
|
||||
while (biter->Valid()) {
|
||||
verification_count = 0;
|
||||
biter->Prev();
|
||||
@@ -788,8 +788,8 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
}
|
||||
|
||||
template <typename TBlockIter>
|
||||
void TestSeekToFirst(std::unique_ptr<TBlockIter> &biter,
|
||||
size_t &verification_count) {
|
||||
void TestSeekToFirst(std::unique_ptr<TBlockIter>& biter,
|
||||
size_t& verification_count) {
|
||||
verification_count = 0;
|
||||
biter->SeekToFirst();
|
||||
ASSERT_GE(verification_count, 1);
|
||||
@@ -797,8 +797,8 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
}
|
||||
|
||||
template <typename TBlockIter>
|
||||
void TestSeekToLast(std::unique_ptr<TBlockIter> &biter,
|
||||
size_t &verification_count) {
|
||||
void TestSeekToLast(std::unique_ptr<TBlockIter>& biter,
|
||||
size_t& verification_count) {
|
||||
verification_count = 0;
|
||||
biter->SeekToLast();
|
||||
ASSERT_GE(verification_count, 1);
|
||||
@@ -806,8 +806,8 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
}
|
||||
|
||||
template <typename TBlockIter>
|
||||
void TestSeekForPrev(std::unique_ptr<TBlockIter> &biter,
|
||||
size_t &verification_count, std::string k) {
|
||||
void TestSeekForPrev(std::unique_ptr<TBlockIter>& biter,
|
||||
size_t& verification_count, std::string k) {
|
||||
verification_count = 0;
|
||||
biter->SeekForPrev(k);
|
||||
ASSERT_GE(verification_count, 1);
|
||||
@@ -815,7 +815,7 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
}
|
||||
|
||||
template <typename TBlockIter>
|
||||
void TestSeek(std::unique_ptr<TBlockIter> &biter, size_t &verification_count,
|
||||
void TestSeek(std::unique_ptr<TBlockIter>& biter, size_t& verification_count,
|
||||
std::string k) {
|
||||
verification_count = 0;
|
||||
biter->Seek(k);
|
||||
@@ -823,8 +823,8 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
TestIterateForward(biter, verification_count);
|
||||
}
|
||||
|
||||
bool VerifyChecksum(uint32_t checksum_len, const char *checksum_ptr,
|
||||
const Slice &key, const Slice &val) {
|
||||
bool VerifyChecksum(uint32_t checksum_len, const char* checksum_ptr,
|
||||
const Slice& key, const Slice& val) {
|
||||
if (!checksum_len) {
|
||||
return checksum_ptr == nullptr;
|
||||
}
|
||||
@@ -834,11 +834,11 @@ class BlockPerKVChecksumTest : public DBTestBase {
|
||||
};
|
||||
|
||||
namespace {
|
||||
const BlockBasedTableOptions *kTableOptions() {
|
||||
const BlockBasedTableOptions* kTableOptions() {
|
||||
static BlockBasedTableOptions opts{};
|
||||
return &opts;
|
||||
}
|
||||
Decompressor *kDecompressor() {
|
||||
Decompressor* kDecompressor() {
|
||||
static auto mgr = GetBuiltinV2CompressionManager();
|
||||
static auto decomp = mgr->GetDecompressor();
|
||||
return decomp.get();
|
||||
@@ -1056,7 +1056,7 @@ class DataBlockKVChecksumTest
|
||||
bool GetUseDeltaEncoding() const { return std::get<3>(GetParam()); }
|
||||
|
||||
std::unique_ptr<Block_kData> GenerateDataBlock(
|
||||
std::vector<std::string> &keys, std::vector<std::string> &values,
|
||||
std::vector<std::string>& keys, std::vector<std::string>& values,
|
||||
int num_record) {
|
||||
BlockCreateContext create_context{
|
||||
kTableOptions(), nullptr /* statistics */, nullptr /* ioptions */,
|
||||
@@ -1089,9 +1089,9 @@ INSTANTIATE_TEST_CASE_P(
|
||||
::testing::Values(0, 1, 2, 4, 8) /* protection_bytes_per_key */,
|
||||
::testing::Values(1, 2, 3, 8, 16) /* restart_interval */,
|
||||
::testing::Values(false, true)) /* delta_encoding */,
|
||||
[](const testing::TestParamInfo<std::tuple<
|
||||
BlockBasedTableOptions::DataBlockIndexType, uint8_t, uint32_t, bool>>
|
||||
&args) {
|
||||
[](const testing::TestParamInfo<
|
||||
std::tuple<BlockBasedTableOptions::DataBlockIndexType, uint8_t,
|
||||
uint32_t, bool>>& args) {
|
||||
std::ostringstream oss;
|
||||
oss << GetDataBlockIndexTypeStr(std::get<0>(args.param))
|
||||
<< "ProtectionPerKey" << std::to_string(std::get<1>(args.param))
|
||||
@@ -1114,7 +1114,7 @@ TEST_P(DataBlockKVChecksumTest, ChecksumConstructionAndVerification) {
|
||||
std::unique_ptr<Block_kData> data_block =
|
||||
GenerateDataBlock(keys, values, kNumRecords);
|
||||
|
||||
const char *checksum_ptr = data_block->TEST_GetKVChecksum();
|
||||
const char* checksum_ptr = data_block->TEST_GetKVChecksum();
|
||||
// Check checksum of correct length is generated
|
||||
for (int i = 0; i < kNumRecords; i++) {
|
||||
ASSERT_TRUE(VerifyChecksum(protection_bytes_per_key,
|
||||
@@ -1132,8 +1132,8 @@ TEST_P(DataBlockKVChecksumTest, ChecksumConstructionAndVerification) {
|
||||
// that case (see Block::VerifyChecksum()).
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"Block::VerifyChecksum::checksum_len",
|
||||
[&verification_count, protection_bytes_per_key](void *checksum_len) {
|
||||
ASSERT_EQ((*static_cast<uint8_t *>(checksum_len)),
|
||||
[&verification_count, protection_bytes_per_key](void* checksum_len) {
|
||||
ASSERT_EQ((*static_cast<uint8_t*>(checksum_len)),
|
||||
protection_bytes_per_key);
|
||||
++verification_count;
|
||||
});
|
||||
@@ -1177,9 +1177,9 @@ class IndexBlockKVChecksumTest
|
||||
bool IncludeFirstKey() const { return std::get<4>(GetParam()); }
|
||||
|
||||
std::unique_ptr<Block_kIndex> GenerateIndexBlock(
|
||||
std::vector<std::string> &separators,
|
||||
std::vector<BlockHandle> &block_handles,
|
||||
std::vector<std::string> &first_keys, int num_record) {
|
||||
std::vector<std::string>& separators,
|
||||
std::vector<BlockHandle>& block_handles,
|
||||
std::vector<std::string>& first_keys, int num_record) {
|
||||
Options options = Options();
|
||||
uint8_t protection_bytes_per_key = GetChecksumLen();
|
||||
BlockCreateContext create_context{
|
||||
@@ -1235,7 +1235,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
::testing::Values(true, false), ::testing::Values(true, false)),
|
||||
[](const testing::TestParamInfo<
|
||||
std::tuple<BlockBasedTableOptions::DataBlockIndexType, uint8_t,
|
||||
uint32_t, bool, bool>> &args) {
|
||||
uint32_t, bool, bool>>& args) {
|
||||
std::ostringstream oss;
|
||||
oss << GetDataBlockIndexTypeStr(std::get<0>(args.param)) << "ProtBytes"
|
||||
<< std::to_string(std::get<1>(args.param)) << "RestartInterval"
|
||||
@@ -1264,8 +1264,8 @@ TEST_P(IndexBlockKVChecksumTest, ChecksumConstructionAndVerification) {
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
std::unique_ptr<Block_kIndex> index_block = GenerateIndexBlock(
|
||||
separators, block_handles, first_keys, kNumRecords);
|
||||
IndexBlockIter *kNullIter = nullptr;
|
||||
Statistics *kNullStats = nullptr;
|
||||
IndexBlockIter* kNullIter = nullptr;
|
||||
Statistics* kNullStats = nullptr;
|
||||
// read contents of block sequentially
|
||||
std::unique_ptr<IndexBlockIter> biter{index_block->NewIndexIterator(
|
||||
options.comparator, seqno, kNullIter, kNullStats,
|
||||
@@ -1276,7 +1276,7 @@ TEST_P(IndexBlockKVChecksumTest, ChecksumConstructionAndVerification) {
|
||||
true /* user_defined_timestamps_persisted */,
|
||||
nullptr /* prefix_index */)};
|
||||
biter->SeekToFirst();
|
||||
const char *checksum_ptr = index_block->TEST_GetKVChecksum();
|
||||
const char* checksum_ptr = index_block->TEST_GetKVChecksum();
|
||||
// Check checksum of correct length is generated
|
||||
for (int i = 0; i < kNumRecords; i++) {
|
||||
// Obtaining the actual content written as value to index block is not
|
||||
@@ -1296,8 +1296,8 @@ TEST_P(IndexBlockKVChecksumTest, ChecksumConstructionAndVerification) {
|
||||
// assert checking on checksum_len here.
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"Block::VerifyChecksum::checksum_len",
|
||||
[&verification_count, protection_bytes_per_key](void *checksum_len) {
|
||||
ASSERT_EQ((*static_cast<uint8_t *>(checksum_len)),
|
||||
[&verification_count, protection_bytes_per_key](void* checksum_len) {
|
||||
ASSERT_EQ((*static_cast<uint8_t*>(checksum_len)),
|
||||
protection_bytes_per_key);
|
||||
++verification_count;
|
||||
});
|
||||
@@ -1320,7 +1320,7 @@ class MetaIndexBlockKVChecksumTest
|
||||
uint32_t GetRestartInterval() const { return 1; }
|
||||
|
||||
std::unique_ptr<Block_kMetaIndex> GenerateMetaIndexBlock(
|
||||
std::vector<std::string> &keys, std::vector<std::string> &values,
|
||||
std::vector<std::string>& keys, std::vector<std::string>& values,
|
||||
int num_record) {
|
||||
Options options = Options();
|
||||
uint8_t protection_bytes_per_key = GetChecksumLen();
|
||||
@@ -1346,7 +1346,7 @@ class MetaIndexBlockKVChecksumTest
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(P, MetaIndexBlockKVChecksumTest,
|
||||
::testing::Values(0, 1, 2, 4, 8),
|
||||
[](const testing::TestParamInfo<uint8_t> &args) {
|
||||
[](const testing::TestParamInfo<uint8_t>& args) {
|
||||
std::ostringstream oss;
|
||||
oss << "ProtBytes" << std::to_string(args.param);
|
||||
return oss.str();
|
||||
@@ -1368,7 +1368,7 @@ TEST_P(MetaIndexBlockKVChecksumTest, ChecksumConstructionAndVerification) {
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
std::unique_ptr<Block_kMetaIndex> meta_block =
|
||||
GenerateMetaIndexBlock(keys, values, kNumRecords);
|
||||
const char *checksum_ptr = meta_block->TEST_GetKVChecksum();
|
||||
const char* checksum_ptr = meta_block->TEST_GetKVChecksum();
|
||||
// Check checksum of correct length is generated
|
||||
for (int i = 0; i < kNumRecords; i++) {
|
||||
ASSERT_TRUE(VerifyChecksum(protection_bytes_per_key,
|
||||
@@ -1383,8 +1383,8 @@ TEST_P(MetaIndexBlockKVChecksumTest, ChecksumConstructionAndVerification) {
|
||||
// checking on checksum_len here.
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"Block::VerifyChecksum::checksum_len",
|
||||
[&verification_count, protection_bytes_per_key](void *checksum_len) {
|
||||
ASSERT_EQ((*static_cast<uint8_t *>(checksum_len)),
|
||||
[&verification_count, protection_bytes_per_key](void* checksum_len) {
|
||||
ASSERT_EQ((*static_cast<uint8_t*>(checksum_len)),
|
||||
protection_bytes_per_key);
|
||||
++verification_count;
|
||||
});
|
||||
@@ -1404,7 +1404,7 @@ class DataBlockKVChecksumCorruptionTest : public DataBlockKVChecksumTest {
|
||||
DataBlockKVChecksumCorruptionTest() = default;
|
||||
|
||||
std::unique_ptr<DataBlockIter> GenerateDataBlockIter(
|
||||
std::vector<std::string> &keys, std::vector<std::string> &values,
|
||||
std::vector<std::string>& keys, std::vector<std::string>& values,
|
||||
int num_record) {
|
||||
// During Block construction, we may create block iter to initialize per kv
|
||||
// checksum. Disable syncpoint that may be created for block iter methods.
|
||||
@@ -1430,15 +1430,15 @@ TEST_P(DataBlockKVChecksumCorruptionTest, CorruptEntry) {
|
||||
GenerateRandomKVs(&keys, &values, 0, kNumRecords + 1, 1 /* step */,
|
||||
24 /* padding_size */);
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlockIter::UpdateKey::value", [](void *arg) {
|
||||
char *value = static_cast<char *>(arg);
|
||||
"BlockIter::UpdateKey::value", [](void* arg) {
|
||||
char* value = static_cast<char*>(arg);
|
||||
// values generated by GenerateRandomKVs are of length 100
|
||||
++value[10];
|
||||
});
|
||||
|
||||
// Purely for reducing the number of lines of code.
|
||||
typedef std::unique_ptr<DataBlockIter> IterPtr;
|
||||
typedef void(IterAPI)(IterPtr & iter, std::string &);
|
||||
typedef void(IterAPI)(IterPtr & iter, std::string&);
|
||||
|
||||
std::string seek_key = keys[kNumRecords / 2];
|
||||
auto test_seek = [&](IterAPI iter_api) {
|
||||
@@ -1449,14 +1449,14 @@ TEST_P(DataBlockKVChecksumCorruptionTest, CorruptEntry) {
|
||||
ASSERT_TRUE(biter->status().IsCorruption());
|
||||
};
|
||||
|
||||
test_seek([](IterPtr &iter, std::string &) { iter->SeekToFirst(); });
|
||||
test_seek([](IterPtr &iter, std::string &) { iter->SeekToLast(); });
|
||||
test_seek([](IterPtr &iter, std::string &k) { iter->Seek(k); });
|
||||
test_seek([](IterPtr &iter, std::string &k) { iter->SeekForPrev(k); });
|
||||
test_seek([](IterPtr &iter, std::string &k) { iter->SeekForGet(k); });
|
||||
test_seek([](IterPtr& iter, std::string&) { iter->SeekToFirst(); });
|
||||
test_seek([](IterPtr& iter, std::string&) { iter->SeekToLast(); });
|
||||
test_seek([](IterPtr& iter, std::string& k) { iter->Seek(k); });
|
||||
test_seek([](IterPtr& iter, std::string& k) { iter->SeekForPrev(k); });
|
||||
test_seek([](IterPtr& iter, std::string& k) { iter->SeekForGet(k); });
|
||||
|
||||
typedef void (DataBlockIter::*IterStepAPI)();
|
||||
auto test_step = [&](IterStepAPI iter_api, std::string &k) {
|
||||
auto test_step = [&](IterStepAPI iter_api, std::string& k) {
|
||||
IterPtr biter = GenerateDataBlockIter(keys, values, kNumRecords);
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
biter->Seek(k);
|
||||
@@ -1485,9 +1485,9 @@ INSTANTIATE_TEST_CASE_P(
|
||||
::testing::Values(4, 8) /* block_protection_bytes_per_key */,
|
||||
::testing::Values(1, 3, 8, 16) /* restart_interval */,
|
||||
::testing::Values(false, true)),
|
||||
[](const testing::TestParamInfo<std::tuple<
|
||||
BlockBasedTableOptions::DataBlockIndexType, uint8_t, uint32_t, bool>>
|
||||
&args) {
|
||||
[](const testing::TestParamInfo<
|
||||
std::tuple<BlockBasedTableOptions::DataBlockIndexType, uint8_t,
|
||||
uint32_t, bool>>& args) {
|
||||
std::ostringstream oss;
|
||||
oss << GetDataBlockIndexTypeStr(std::get<0>(args.param)) << "ProtBytes"
|
||||
<< std::to_string(std::get<1>(args.param)) << "RestartInterval"
|
||||
@@ -1501,9 +1501,9 @@ class IndexBlockKVChecksumCorruptionTest : public IndexBlockKVChecksumTest {
|
||||
IndexBlockKVChecksumCorruptionTest() = default;
|
||||
|
||||
std::unique_ptr<IndexBlockIter> GenerateIndexBlockIter(
|
||||
std::vector<std::string> &separators,
|
||||
std::vector<BlockHandle> &block_handles,
|
||||
std::vector<std::string> &first_keys, int num_record,
|
||||
std::vector<std::string>& separators,
|
||||
std::vector<BlockHandle>& block_handles,
|
||||
std::vector<std::string>& first_keys, int num_record,
|
||||
SequenceNumber seqno) {
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
block_ =
|
||||
@@ -1536,7 +1536,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
::testing::Values(true, false), ::testing::Values(true, false)),
|
||||
[](const testing::TestParamInfo<
|
||||
std::tuple<BlockBasedTableOptions::DataBlockIndexType, uint8_t,
|
||||
uint32_t, bool, bool>> &args) {
|
||||
uint32_t, bool, bool>>& args) {
|
||||
std::ostringstream oss;
|
||||
oss << GetDataBlockIndexTypeStr(std::get<0>(args.param)) << "ProtBytes"
|
||||
<< std::to_string(std::get<1>(args.param)) << "RestartInterval"
|
||||
@@ -1561,15 +1561,15 @@ TEST_P(IndexBlockKVChecksumCorruptionTest, CorruptEntry) {
|
||||
kNumRecords, 0 /* ts_sz */,
|
||||
seqno != kDisableGlobalSequenceNumber);
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlockIter::UpdateKey::value", [](void *arg) {
|
||||
char *value = static_cast<char *>(arg);
|
||||
"BlockIter::UpdateKey::value", [](void* arg) {
|
||||
char* value = static_cast<char*>(arg);
|
||||
// value can be delta-encoded with different lengths, so we corrupt
|
||||
// first bytes here to be safe
|
||||
++value[0];
|
||||
});
|
||||
|
||||
typedef std::unique_ptr<IndexBlockIter> IterPtr;
|
||||
typedef void(IterAPI)(IterPtr & iter, std::string &);
|
||||
typedef void(IterAPI)(IterPtr & iter, std::string&);
|
||||
std::string seek_key = first_keys[kNumRecords / 2];
|
||||
auto test_seek = [&](IterAPI iter_api) {
|
||||
std::unique_ptr<IndexBlockIter> biter = GenerateIndexBlockIter(
|
||||
@@ -1579,12 +1579,12 @@ TEST_P(IndexBlockKVChecksumCorruptionTest, CorruptEntry) {
|
||||
ASSERT_FALSE(biter->Valid());
|
||||
ASSERT_TRUE(biter->status().IsCorruption());
|
||||
};
|
||||
test_seek([](IterPtr &iter, std::string &) { iter->SeekToFirst(); });
|
||||
test_seek([](IterPtr &iter, std::string &) { iter->SeekToLast(); });
|
||||
test_seek([](IterPtr &iter, std::string &k) { iter->Seek(k); });
|
||||
test_seek([](IterPtr& iter, std::string&) { iter->SeekToFirst(); });
|
||||
test_seek([](IterPtr& iter, std::string&) { iter->SeekToLast(); });
|
||||
test_seek([](IterPtr& iter, std::string& k) { iter->Seek(k); });
|
||||
|
||||
typedef void (IndexBlockIter::*IterStepAPI)();
|
||||
auto test_step = [&](IterStepAPI iter_api, std::string &k) {
|
||||
auto test_step = [&](IterStepAPI iter_api, std::string& k) {
|
||||
std::unique_ptr<IndexBlockIter> biter = GenerateIndexBlockIter(
|
||||
separators, block_handles, first_keys, kNumRecords, seqno);
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
@@ -1610,7 +1610,7 @@ class MetaIndexBlockKVChecksumCorruptionTest
|
||||
MetaIndexBlockKVChecksumCorruptionTest() = default;
|
||||
|
||||
std::unique_ptr<MetaBlockIter> GenerateMetaIndexBlockIter(
|
||||
std::vector<std::string> &keys, std::vector<std::string> &values,
|
||||
std::vector<std::string>& keys, std::vector<std::string>& values,
|
||||
int num_record) {
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
block_ = GenerateMetaIndexBlock(keys, values, num_record);
|
||||
@@ -1627,7 +1627,7 @@ class MetaIndexBlockKVChecksumCorruptionTest
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
P, MetaIndexBlockKVChecksumCorruptionTest,
|
||||
::testing::Values(4, 8) /* block_protection_bytes_per_key */,
|
||||
[](const testing::TestParamInfo<uint8_t> &args) {
|
||||
[](const testing::TestParamInfo<uint8_t>& args) {
|
||||
std::ostringstream oss;
|
||||
oss << "ProtBytes" << std::to_string(args.param);
|
||||
return oss.str();
|
||||
@@ -1644,14 +1644,14 @@ TEST_P(MetaIndexBlockKVChecksumCorruptionTest, CorruptEntry) {
|
||||
GenerateRandomKVs(&keys, &values, 0, kNumRecords + 1, 1 /* step */,
|
||||
24 /* padding_size */);
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlockIter::UpdateKey::value", [](void *arg) {
|
||||
char *value = static_cast<char *>(arg);
|
||||
"BlockIter::UpdateKey::value", [](void* arg) {
|
||||
char* value = static_cast<char*>(arg);
|
||||
// values generated by GenerateRandomKVs are of length 100
|
||||
++value[10];
|
||||
});
|
||||
|
||||
typedef std::unique_ptr<MetaBlockIter> IterPtr;
|
||||
typedef void(IterAPI)(IterPtr & iter, std::string &);
|
||||
typedef void(IterAPI)(IterPtr & iter, std::string&);
|
||||
typedef void (MetaBlockIter::*IterStepAPI)();
|
||||
std::string seek_key = keys[kNumRecords / 2];
|
||||
auto test_seek = [&](IterAPI iter_api) {
|
||||
@@ -1662,12 +1662,12 @@ TEST_P(MetaIndexBlockKVChecksumCorruptionTest, CorruptEntry) {
|
||||
ASSERT_TRUE(biter->status().IsCorruption());
|
||||
};
|
||||
|
||||
test_seek([](IterPtr &iter, std::string &) { iter->SeekToFirst(); });
|
||||
test_seek([](IterPtr &iter, std::string &) { iter->SeekToLast(); });
|
||||
test_seek([](IterPtr &iter, std::string &k) { iter->Seek(k); });
|
||||
test_seek([](IterPtr &iter, std::string &k) { iter->SeekForPrev(k); });
|
||||
test_seek([](IterPtr& iter, std::string&) { iter->SeekToFirst(); });
|
||||
test_seek([](IterPtr& iter, std::string&) { iter->SeekToLast(); });
|
||||
test_seek([](IterPtr& iter, std::string& k) { iter->Seek(k); });
|
||||
test_seek([](IterPtr& iter, std::string& k) { iter->SeekForPrev(k); });
|
||||
|
||||
auto test_step = [&](IterStepAPI iter_api, const std::string &k) {
|
||||
auto test_step = [&](IterStepAPI iter_api, const std::string& k) {
|
||||
IterPtr biter = GenerateMetaIndexBlockIter(keys, values, kNumRecords);
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
biter->Seek(k);
|
||||
@@ -1687,7 +1687,7 @@ TEST_P(MetaIndexBlockKVChecksumCorruptionTest, CorruptEntry) {
|
||||
}
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
@@ -32,7 +32,7 @@ class MockBlockBasedTableTester {
|
||||
|
||||
explicit MockBlockBasedTableTester(const FilterPolicy* filter_policy)
|
||||
: MockBlockBasedTableTester(
|
||||
std::shared_ptr<const FilterPolicy>(filter_policy)){};
|
||||
std::shared_ptr<const FilterPolicy>(filter_policy)) {};
|
||||
|
||||
explicit MockBlockBasedTableTester(
|
||||
std::shared_ptr<const FilterPolicy> filter_policy)
|
||||
|
||||
@@ -31,7 +31,9 @@ void Multiplier(void* arg1, void* arg2) {
|
||||
TEST_F(CleanableTest, Register) {
|
||||
int n2 = 2, n3 = 3;
|
||||
int res = 1;
|
||||
{ Cleanable c1; }
|
||||
{
|
||||
Cleanable c1;
|
||||
}
|
||||
// ~Cleanable
|
||||
ASSERT_EQ(1, res);
|
||||
|
||||
|
||||
+15
-15
@@ -14,7 +14,7 @@ namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
std::string EncodeSessionId(uint64_t upper, uint64_t lower) {
|
||||
std::string db_session_id(20U, '\0');
|
||||
char *buf = db_session_id.data();
|
||||
char* buf = db_session_id.data();
|
||||
// Preserving `lower` is slightly tricky. 36^12 is slightly more than
|
||||
// 62 bits, so we use 12 chars plus the bottom two bits of one more.
|
||||
// (A tiny fraction of 20 digit strings go unused.)
|
||||
@@ -26,8 +26,8 @@ std::string EncodeSessionId(uint64_t upper, uint64_t lower) {
|
||||
return db_session_id;
|
||||
}
|
||||
|
||||
Status DecodeSessionId(const std::string &db_session_id, uint64_t *upper,
|
||||
uint64_t *lower) {
|
||||
Status DecodeSessionId(const std::string& db_session_id, uint64_t* upper,
|
||||
uint64_t* lower) {
|
||||
const size_t len = db_session_id.size();
|
||||
if (len == 0) {
|
||||
return Status::NotSupported("Missing db_session_id");
|
||||
@@ -41,7 +41,7 @@ Status DecodeSessionId(const std::string &db_session_id, uint64_t *upper,
|
||||
return Status::NotSupported("Too long db_session_id");
|
||||
}
|
||||
uint64_t a = 0, b = 0;
|
||||
const char *buf = &db_session_id.front();
|
||||
const char* buf = &db_session_id.front();
|
||||
bool success = ParseBaseChars<36>(&buf, len - 12U, &a);
|
||||
if (!success) {
|
||||
return Status::NotSupported("Bad digit in db_session_id");
|
||||
@@ -56,8 +56,8 @@ Status DecodeSessionId(const std::string &db_session_id, uint64_t *upper,
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status GetSstInternalUniqueId(const std::string &db_id,
|
||||
const std::string &db_session_id,
|
||||
Status GetSstInternalUniqueId(const std::string& db_id,
|
||||
const std::string& db_session_id,
|
||||
uint64_t file_number, UniqueIdPtr out,
|
||||
bool force) {
|
||||
if (!force) {
|
||||
@@ -160,11 +160,11 @@ std::string EncodeUniqueIdBytes(UniqueIdPtr in) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Status DecodeUniqueIdBytes(const std::string &unique_id, UniqueIdPtr out) {
|
||||
Status DecodeUniqueIdBytes(const std::string& unique_id, UniqueIdPtr out) {
|
||||
if (unique_id.size() != (out.extended ? 24 : 16)) {
|
||||
return Status::NotSupported("Not a valid unique_id");
|
||||
}
|
||||
const char *buf = &unique_id.front();
|
||||
const char* buf = &unique_id.front();
|
||||
out.ptr[0] = DecodeFixed64(&buf[0]);
|
||||
out.ptr[1] = DecodeFixed64(&buf[8]);
|
||||
if (out.extended) {
|
||||
@@ -174,8 +174,8 @@ Status DecodeUniqueIdBytes(const std::string &unique_id, UniqueIdPtr out) {
|
||||
}
|
||||
|
||||
template <typename ID>
|
||||
Status GetUniqueIdFromTablePropertiesHelper(const TableProperties &props,
|
||||
std::string *out_id) {
|
||||
Status GetUniqueIdFromTablePropertiesHelper(const TableProperties& props,
|
||||
std::string* out_id) {
|
||||
ID tmp{};
|
||||
Status s = GetSstInternalUniqueId(props.db_id, props.db_session_id,
|
||||
props.orig_file_number, &tmp);
|
||||
@@ -188,17 +188,17 @@ Status GetUniqueIdFromTablePropertiesHelper(const TableProperties &props,
|
||||
return s;
|
||||
}
|
||||
|
||||
Status GetExtendedUniqueIdFromTableProperties(const TableProperties &props,
|
||||
std::string *out_id) {
|
||||
Status GetExtendedUniqueIdFromTableProperties(const TableProperties& props,
|
||||
std::string* out_id) {
|
||||
return GetUniqueIdFromTablePropertiesHelper<UniqueId64x3>(props, out_id);
|
||||
}
|
||||
|
||||
Status GetUniqueIdFromTableProperties(const TableProperties &props,
|
||||
std::string *out_id) {
|
||||
Status GetUniqueIdFromTableProperties(const TableProperties& props,
|
||||
std::string* out_id) {
|
||||
return GetUniqueIdFromTablePropertiesHelper<UniqueId64x2>(props, out_id);
|
||||
}
|
||||
|
||||
std::string UniqueIdToHumanString(const std::string &id) {
|
||||
std::string UniqueIdToHumanString(const std::string& id) {
|
||||
std::string hex = Slice(id).ToString(/*hex*/ true);
|
||||
std::string result;
|
||||
result.reserve(hex.size() + hex.size() / 16);
|
||||
|
||||
@@ -26,14 +26,14 @@ constexpr UniqueId64x3 kNullUniqueId64x3 = {};
|
||||
|
||||
// Dynamic pointer wrapper for one of the two above
|
||||
struct UniqueIdPtr {
|
||||
uint64_t *ptr = nullptr;
|
||||
uint64_t* ptr = nullptr;
|
||||
bool extended = false;
|
||||
|
||||
/*implicit*/ UniqueIdPtr(UniqueId64x2 *id) {
|
||||
/*implicit*/ UniqueIdPtr(UniqueId64x2* id) {
|
||||
ptr = (*id).data();
|
||||
extended = false;
|
||||
}
|
||||
/*implicit*/ UniqueIdPtr(UniqueId64x3 *id) {
|
||||
/*implicit*/ UniqueIdPtr(UniqueId64x3* id) {
|
||||
ptr = (*id).data();
|
||||
extended = true;
|
||||
}
|
||||
@@ -45,8 +45,8 @@ struct UniqueIdPtr {
|
||||
// unique id, so can be manipulated in more ways but very carefully.
|
||||
// These must be long term stable to ensure GetUniqueIdFromTableProperties
|
||||
// is long term stable.
|
||||
Status GetSstInternalUniqueId(const std::string &db_id,
|
||||
const std::string &db_session_id,
|
||||
Status GetSstInternalUniqueId(const std::string& db_id,
|
||||
const std::string& db_session_id,
|
||||
uint64_t file_number, UniqueIdPtr out,
|
||||
bool force = false);
|
||||
|
||||
@@ -66,7 +66,7 @@ void ExternalUniqueIdToInternal(UniqueIdPtr in_out);
|
||||
std::string EncodeUniqueIdBytes(UniqueIdPtr in);
|
||||
|
||||
// Reverse of EncodeUniqueIdBytes.
|
||||
Status DecodeUniqueIdBytes(const std::string &unique_id, UniqueIdPtr out);
|
||||
Status DecodeUniqueIdBytes(const std::string& unique_id, UniqueIdPtr out);
|
||||
|
||||
// For presenting internal IDs for debugging purposes. Visually distinct from
|
||||
// UniqueIdToHumanString for external IDs.
|
||||
@@ -87,7 +87,7 @@ std::string EncodeSessionId(uint64_t upper, uint64_t lower);
|
||||
// Reverse of EncodeSessionId. Returns NotSupported on error rather than
|
||||
// Corruption because non-standard session IDs should be allowed with degraded
|
||||
// functionality.
|
||||
Status DecodeSessionId(const std::string &db_session_id, uint64_t *upper,
|
||||
uint64_t *lower);
|
||||
Status DecodeSessionId(const std::string& db_session_id, uint64_t* upper,
|
||||
uint64_t* lower);
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
||||
@@ -25,7 +25,7 @@ DEFINE_bool(compact, false, "Compact the db after loading the dumped file");
|
||||
DEFINE_string(db_options, "",
|
||||
"Options string used to open the database that will be loaded");
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
if (FLAGS_db_path == "" || FLAGS_dump_location == "") {
|
||||
|
||||
+16
-16
@@ -198,13 +198,13 @@ class FastLocalBloomImpl {
|
||||
}
|
||||
|
||||
static inline void AddHash(uint32_t h1, uint32_t h2, uint32_t len_bytes,
|
||||
int num_probes, char *data) {
|
||||
int num_probes, char* data) {
|
||||
uint32_t bytes_to_cache_line = FastRange32(h1, len_bytes >> 6) << 6;
|
||||
AddHashPrepared(h2, num_probes, data + bytes_to_cache_line);
|
||||
}
|
||||
|
||||
static inline void AddHashPrepared(uint32_t h2, int num_probes,
|
||||
char *data_at_cache_line) {
|
||||
char* data_at_cache_line) {
|
||||
uint32_t h = h2;
|
||||
for (int i = 0; i < num_probes; ++i, h *= uint32_t{0x9e3779b9}) {
|
||||
// 9-bit address within 512 bit cache line
|
||||
@@ -214,8 +214,8 @@ class FastLocalBloomImpl {
|
||||
}
|
||||
|
||||
static inline void PrepareHash(uint32_t h1, uint32_t len_bytes,
|
||||
const char *data,
|
||||
uint32_t /*out*/ *byte_offset) {
|
||||
const char* data,
|
||||
uint32_t /*out*/* byte_offset) {
|
||||
uint32_t bytes_to_cache_line = FastRange32(h1, len_bytes >> 6) << 6;
|
||||
PREFETCH(data + bytes_to_cache_line, 0 /* rw */, 1 /* locality */);
|
||||
PREFETCH(data + bytes_to_cache_line + 63, 0 /* rw */, 1 /* locality */);
|
||||
@@ -223,13 +223,13 @@ class FastLocalBloomImpl {
|
||||
}
|
||||
|
||||
static inline bool HashMayMatch(uint32_t h1, uint32_t h2, uint32_t len_bytes,
|
||||
int num_probes, const char *data) {
|
||||
int num_probes, const char* data) {
|
||||
uint32_t bytes_to_cache_line = FastRange32(h1, len_bytes >> 6) << 6;
|
||||
return HashMayMatchPrepared(h2, num_probes, data + bytes_to_cache_line);
|
||||
}
|
||||
|
||||
static inline bool HashMayMatchPrepared(uint32_t h2, int num_probes,
|
||||
const char *data_at_cache_line) {
|
||||
const char* data_at_cache_line) {
|
||||
uint32_t h = h2;
|
||||
#ifdef __AVX2__
|
||||
int rem_probes = num_probes;
|
||||
@@ -277,8 +277,8 @@ class FastLocalBloomImpl {
|
||||
// /*bytes / i32*/ 4);
|
||||
// END Option 1
|
||||
// Potentially unaligned as we're not *always* cache-aligned -> loadu
|
||||
const __m256i *mm_data =
|
||||
reinterpret_cast<const __m256i *>(data_at_cache_line);
|
||||
const __m256i* mm_data =
|
||||
reinterpret_cast<const __m256i*>(data_at_cache_line);
|
||||
__m256i lower = _mm256_loadu_si256(mm_data);
|
||||
__m256i upper = _mm256_loadu_si256(mm_data + 1);
|
||||
// Option 2: AVX512VL permute hack
|
||||
@@ -362,7 +362,7 @@ class LegacyNoLocalityBloomImpl {
|
||||
}
|
||||
|
||||
static inline void AddHash(uint32_t h, uint32_t total_bits, int num_probes,
|
||||
char *data) {
|
||||
char* data) {
|
||||
const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits
|
||||
for (int i = 0; i < num_probes; i++) {
|
||||
const uint32_t bitpos = h % total_bits;
|
||||
@@ -372,7 +372,7 @@ class LegacyNoLocalityBloomImpl {
|
||||
}
|
||||
|
||||
static inline bool HashMayMatch(uint32_t h, uint32_t total_bits,
|
||||
int num_probes, const char *data) {
|
||||
int num_probes, const char* data) {
|
||||
const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits
|
||||
for (int i = 0; i < num_probes; i++) {
|
||||
const uint32_t bitpos = h % total_bits;
|
||||
@@ -430,10 +430,10 @@ class LegacyLocalityBloomImpl {
|
||||
}
|
||||
|
||||
static inline void AddHash(uint32_t h, uint32_t num_lines, int num_probes,
|
||||
char *data, int log2_cache_line_bytes) {
|
||||
char* data, int log2_cache_line_bytes) {
|
||||
const int log2_cache_line_bits = log2_cache_line_bytes + 3;
|
||||
|
||||
char *data_at_offset =
|
||||
char* data_at_offset =
|
||||
data + (GetLine(h, num_lines) << log2_cache_line_bytes);
|
||||
const uint32_t delta = (h >> 17) | (h << 15);
|
||||
for (int i = 0; i < num_probes; ++i) {
|
||||
@@ -448,8 +448,8 @@ class LegacyLocalityBloomImpl {
|
||||
}
|
||||
|
||||
static inline void PrepareHashMayMatch(uint32_t h, uint32_t num_lines,
|
||||
const char *data,
|
||||
uint32_t /*out*/ *byte_offset,
|
||||
const char* data,
|
||||
uint32_t /*out*/* byte_offset,
|
||||
int log2_cache_line_bytes) {
|
||||
uint32_t b = GetLine(h, num_lines) << log2_cache_line_bytes;
|
||||
PREFETCH(data + b, 0 /* rw */, 1 /* locality */);
|
||||
@@ -459,14 +459,14 @@ class LegacyLocalityBloomImpl {
|
||||
}
|
||||
|
||||
static inline bool HashMayMatch(uint32_t h, uint32_t num_lines,
|
||||
int num_probes, const char *data,
|
||||
int num_probes, const char* data,
|
||||
int log2_cache_line_bytes) {
|
||||
uint32_t b = GetLine(h, num_lines) << log2_cache_line_bytes;
|
||||
return HashMayMatchPrepared(h, num_probes, data + b, log2_cache_line_bytes);
|
||||
}
|
||||
|
||||
static inline bool HashMayMatchPrepared(uint32_t h, int num_probes,
|
||||
const char *data_at_offset,
|
||||
const char* data_at_offset,
|
||||
int log2_cache_line_bytes) {
|
||||
const int log2_cache_line_bits = log2_cache_line_bytes + 3;
|
||||
|
||||
|
||||
+2
-4
@@ -355,8 +355,7 @@ __attribute__((__no_sanitize__("alignment")))
|
||||
__attribute__((__no_sanitize_undefined__))
|
||||
#endif
|
||||
#endif
|
||||
inline void
|
||||
PutUnaligned(T* memory, const T& value) {
|
||||
inline void PutUnaligned(T* memory, const T& value) {
|
||||
#if defined(PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED)
|
||||
char* nonAlignedMemory = reinterpret_cast<char*>(memory);
|
||||
memcpy(nonAlignedMemory, reinterpret_cast<const char*>(&value), sizeof(T));
|
||||
@@ -373,8 +372,7 @@ __attribute__((__no_sanitize__("alignment")))
|
||||
__attribute__((__no_sanitize_undefined__))
|
||||
#endif
|
||||
#endif
|
||||
inline void
|
||||
GetUnaligned(const T* memory, T* value) {
|
||||
inline void GetUnaligned(const T* memory, T* value) {
|
||||
#if defined(PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED)
|
||||
char* nonAlignedMemory = reinterpret_cast<char*>(value);
|
||||
memcpy(nonAlignedMemory, reinterpret_cast<const char*>(memory), sizeof(T));
|
||||
|
||||
@@ -113,10 +113,9 @@ __attribute__((__no_sanitize__("alignment")))
|
||||
__attribute__((__no_sanitize_undefined__))
|
||||
#endif
|
||||
#endif
|
||||
uint32_t
|
||||
crc32c_arm64(uint32_t crc, unsigned char const *data, size_t len) {
|
||||
const uint8_t *buf8;
|
||||
const uint64_t *buf64 = (uint64_t *)data;
|
||||
uint32_t crc32c_arm64(uint32_t crc, unsigned char const* data, size_t len) {
|
||||
const uint8_t* buf8;
|
||||
const uint64_t* buf64 = (uint64_t*)data;
|
||||
int length = (int)len;
|
||||
crc ^= 0xffffffff;
|
||||
|
||||
@@ -148,7 +147,7 @@ crc32c_arm64(uint32_t crc, unsigned char const *data, size_t len) {
|
||||
uint32_t k0 = 0xe417f38a, k1 = 0x8f158014;
|
||||
|
||||
/* Prefetch data for following block to avoid cache miss */
|
||||
PREF1KL1((uint8_t *)buf64, 1024);
|
||||
PREF1KL1((uint8_t*)buf64, 1024);
|
||||
|
||||
/* First 8 byte for better pipelining */
|
||||
crc0 = crc32c_u64(crc, *buf64++);
|
||||
@@ -184,22 +183,22 @@ crc32c_arm64(uint32_t crc, unsigned char const *data, size_t len) {
|
||||
#endif
|
||||
} // if Pmull runtime check here
|
||||
|
||||
buf8 = (const uint8_t *)buf64;
|
||||
buf8 = (const uint8_t*)buf64;
|
||||
while (length >= 8) {
|
||||
crc = crc32c_u64(crc, *(const uint64_t *)buf8);
|
||||
crc = crc32c_u64(crc, *(const uint64_t*)buf8);
|
||||
buf8 += 8;
|
||||
length -= 8;
|
||||
}
|
||||
|
||||
/* The following is more efficient than the straight loop */
|
||||
if (length >= 4) {
|
||||
crc = crc32c_u32(crc, *(const uint32_t *)buf8);
|
||||
crc = crc32c_u32(crc, *(const uint32_t*)buf8);
|
||||
buf8 += 4;
|
||||
length -= 4;
|
||||
}
|
||||
|
||||
if (length >= 2) {
|
||||
crc = crc32c_u16(crc, *(const uint16_t *)buf8);
|
||||
crc = crc32c_u16(crc, *(const uint16_t*)buf8);
|
||||
buf8 += 2;
|
||||
length -= 2;
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
PREF4X64L1(buffer, (PREF_OFFSET), 8) \
|
||||
PREF4X64L1(buffer, (PREF_OFFSET), 12)
|
||||
|
||||
uint32_t crc32c_arm64(uint32_t crc, unsigned char const *data, size_t len);
|
||||
uint32_t crc32c_arm64(uint32_t crc, unsigned char const* data, size_t len);
|
||||
uint32_t crc32c_runtime_check(void);
|
||||
bool crc32c_pmull_runtime_check(void);
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint32_t crc32c_ppc(uint32_t crc, unsigned char const *buffer, size_t len);
|
||||
uint32_t crc32c_ppc(uint32_t crc, unsigned char const* buffer, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ struct KeyMaker {
|
||||
// Sequential, within a hash function block
|
||||
inline Slice Seq(uint64_t i) {
|
||||
a = i;
|
||||
return Slice(reinterpret_cast<char *>(&a), sizeof(a));
|
||||
return Slice(reinterpret_cast<char*>(&a), sizeof(a));
|
||||
}
|
||||
// Not quite sequential, varies across hash function blocks
|
||||
inline Slice Nonseq(uint64_t i) {
|
||||
a = i;
|
||||
b = i * 123;
|
||||
return Slice(reinterpret_cast<char *>(this), sizeof(*this));
|
||||
return Slice(reinterpret_cast<char*>(this), sizeof(*this));
|
||||
}
|
||||
inline Slice Key(uint64_t i, bool nonseq) {
|
||||
return nonseq ? Nonseq(i) : Seq(i);
|
||||
@@ -315,7 +315,7 @@ TEST_F(DynamicBloomTest, concurrent_with_perf) {
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
+18
-18
@@ -126,7 +126,7 @@ DEFINE_bool(legend, false,
|
||||
|
||||
DEFINE_uint32(runs, 1, "Number of times to rebuild and run benchmark tests");
|
||||
|
||||
void _always_assert_fail(int line, const char *file, const char *expr) {
|
||||
void _always_assert_fail(int line, const char* file, const char* expr) {
|
||||
fprintf(stderr, "%s: %d: Assertion %s failed\n", file, line, expr);
|
||||
abort();
|
||||
}
|
||||
@@ -195,7 +195,7 @@ struct KeyMaker {
|
||||
len += FastRange32(
|
||||
(val_num >> FLAGS_vary_key_size_log2_interval) * 1234567891, 5);
|
||||
}
|
||||
char *data = buf_.get() + start;
|
||||
char* data = buf_.get() + start;
|
||||
// Populate key data such that all data makes it into a key of at
|
||||
// least 8 bytes. We also don't want all the within-filter key
|
||||
// variance confined to a contiguous 32 bits, because then a 32 bit
|
||||
@@ -220,7 +220,7 @@ void PrintWarnings() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void PrintError(const char *error) { fprintf(stderr, "ERROR: %s\n", error); }
|
||||
void PrintError(const char* error) { fprintf(stderr, "ERROR: %s\n", error); }
|
||||
|
||||
struct FilterInfo {
|
||||
uint32_t filter_id_ = 0;
|
||||
@@ -258,7 +258,7 @@ static const std::vector<TestMode> bestCaseTestModes = {
|
||||
kSingleFilter,
|
||||
};
|
||||
|
||||
const char *TestModeToString(TestMode tm) {
|
||||
const char* TestModeToString(TestMode tm) {
|
||||
switch (tm) {
|
||||
case kSingleFilter:
|
||||
return "Single filter";
|
||||
@@ -278,7 +278,7 @@ const char *TestModeToString(TestMode tm) {
|
||||
|
||||
// Do just enough to keep some data dependence for the
|
||||
// compiler / CPU
|
||||
static uint32_t DryRunNoHash(Slice &s) {
|
||||
static uint32_t DryRunNoHash(Slice& s) {
|
||||
uint32_t sz = static_cast<uint32_t>(s.size());
|
||||
if (sz >= 4) {
|
||||
return sz + s.data()[3];
|
||||
@@ -287,16 +287,16 @@ static uint32_t DryRunNoHash(Slice &s) {
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t DryRunHash32(Slice &s) {
|
||||
static uint32_t DryRunHash32(Slice& s) {
|
||||
// Same perf characteristics as GetSliceHash()
|
||||
return BloomHash(s);
|
||||
}
|
||||
|
||||
static uint32_t DryRunHash64(Slice &s) {
|
||||
static uint32_t DryRunHash64(Slice& s) {
|
||||
return Lower32of64(GetSliceHash64(s));
|
||||
}
|
||||
|
||||
const std::shared_ptr<const FilterPolicy> &GetPolicy() {
|
||||
const std::shared_ptr<const FilterPolicy>& GetPolicy() {
|
||||
static std::shared_ptr<const FilterPolicy> policy;
|
||||
if (!policy) {
|
||||
policy = BloomLikeFilterPolicy::Create(
|
||||
@@ -378,7 +378,7 @@ void FilterBench::Go() {
|
||||
FLAGS_average_keys_per_filter);
|
||||
const uint32_t variance_offset = variance_range / 2;
|
||||
|
||||
const std::vector<TestMode> &testModes = FLAGS_best_case ? bestCaseTestModes
|
||||
const std::vector<TestMode>& testModes = FLAGS_best_case ? bestCaseTestModes
|
||||
: FLAGS_quick ? quickTestModes
|
||||
: allTestModes;
|
||||
|
||||
@@ -425,7 +425,7 @@ void FilterBench::Go() {
|
||||
keys_to_add = static_cast<uint32_t>(max_total_keys - total_keys_added);
|
||||
}
|
||||
infos_.emplace_back();
|
||||
FilterInfo &info = infos_.back();
|
||||
FilterInfo& info = infos_.back();
|
||||
info.filter_id_ = filter_id;
|
||||
info.keys_added_ = keys_to_add;
|
||||
if (FLAGS_use_plain_table_bloom) {
|
||||
@@ -475,7 +475,7 @@ void FilterBench::Go() {
|
||||
total_size += info.filter_.size();
|
||||
#ifdef ROCKSDB_MALLOC_USABLE_SIZE
|
||||
total_memory_used +=
|
||||
malloc_usable_size(const_cast<char *>(info.filter_.data()));
|
||||
malloc_usable_size(const_cast<char*>(info.filter_.data()));
|
||||
#endif // ROCKSDB_MALLOC_USABLE_SIZE
|
||||
total_keys_added += keys_to_add;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ void FilterBench::Go() {
|
||||
static_cast<uint32_t>(m_queries_ * 1000000 / infos_.size());
|
||||
uint64_t fps = 0;
|
||||
for (uint32_t i = 0; i < infos_.size(); ++i) {
|
||||
FilterInfo &info = infos_[i];
|
||||
FilterInfo& info = infos_[i];
|
||||
for (uint32_t j = 0; j < info.keys_added_; ++j) {
|
||||
if (FLAGS_use_plain_table_bloom) {
|
||||
uint32_t hash = GetSliceHash(kms_[0].Get(info.filter_id_, j));
|
||||
@@ -593,7 +593,7 @@ void FilterBench::Go() {
|
||||
|
||||
double FilterBench::RandomQueryTest(uint32_t inside_threshold, bool dry_run,
|
||||
TestMode mode) {
|
||||
for (auto &info : infos_) {
|
||||
for (auto& info : infos_) {
|
||||
info.outside_queries_ = 0;
|
||||
info.false_positives_ = 0;
|
||||
}
|
||||
@@ -644,14 +644,14 @@ double FilterBench::RandomQueryTest(uint32_t inside_threshold, bool dry_run,
|
||||
}
|
||||
uint32_t batch_size = 1;
|
||||
std::unique_ptr<Slice[]> batch_slices;
|
||||
std::unique_ptr<Slice *[]> batch_slice_ptrs;
|
||||
std::unique_ptr<Slice*[]> batch_slice_ptrs;
|
||||
std::unique_ptr<bool[]> batch_results;
|
||||
if (mode == kBatchPrepared || mode == kBatchUnprepared) {
|
||||
batch_size = static_cast<uint32_t>(kms_.size());
|
||||
}
|
||||
|
||||
batch_slices.reset(new Slice[batch_size]);
|
||||
batch_slice_ptrs.reset(new Slice *[batch_size]);
|
||||
batch_slice_ptrs.reset(new Slice*[batch_size]);
|
||||
batch_results.reset(new bool[batch_size]);
|
||||
for (uint32_t i = 0; i < batch_size; ++i) {
|
||||
batch_results[i] = false;
|
||||
@@ -672,7 +672,7 @@ double FilterBench::RandomQueryTest(uint32_t inside_threshold, bool dry_run,
|
||||
filter_index = num_primary_filters +
|
||||
random_.Uniformish(num_infos - num_primary_filters);
|
||||
}
|
||||
FilterInfo &info = infos_[filter_index];
|
||||
FilterInfo& info = infos_[filter_index];
|
||||
for (uint32_t i = 0; i < batch_size; ++i) {
|
||||
if (inside_this_time) {
|
||||
batch_slices[i] =
|
||||
@@ -767,7 +767,7 @@ double FilterBench::RandomQueryTest(uint32_t inside_threshold, bool dry_run,
|
||||
uint64_t fp = 0;
|
||||
double worst_fp_rate = 0.0;
|
||||
double best_fp_rate = 1.0;
|
||||
for (auto &info : infos_) {
|
||||
for (auto& info : infos_) {
|
||||
q += info.outside_queries_;
|
||||
fp += info.false_positives_;
|
||||
if (info.outside_queries_ > 0) {
|
||||
@@ -789,7 +789,7 @@ double FilterBench::RandomQueryTest(uint32_t inside_threshold, bool dry_run,
|
||||
return ns;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
|
||||
SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) +
|
||||
" [-quick] [OTHER OPTIONS]...");
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
namespace gflags_compat { \
|
||||
DEFINE_int32(name, val, txt); \
|
||||
} \
|
||||
uint32_t &FLAGS_##name = \
|
||||
*reinterpret_cast<uint32_t *>(&gflags_compat::FLAGS_##name);
|
||||
uint32_t& FLAGS_##name = \
|
||||
*reinterpret_cast<uint32_t*>(&gflags_compat::FLAGS_##name);
|
||||
|
||||
#define DECLARE_uint32(name) extern uint32_t &FLAGS_##name;
|
||||
#define DECLARE_uint32(name) extern uint32_t& FLAGS_##name;
|
||||
#endif // !DEFINE_uint32
|
||||
|
||||
+7
-7
@@ -233,8 +233,8 @@ TEST(HashTest, Hash64SmallValueSchema) {
|
||||
uint64_t{10551812464348219044u});
|
||||
}
|
||||
|
||||
std::string Hash64TestDescriptor(const char *repeat, size_t limit) {
|
||||
const char *mod61_encode =
|
||||
std::string Hash64TestDescriptor(const char* repeat, size_t limit) {
|
||||
const char* mod61_encode =
|
||||
"abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
std::string input;
|
||||
@@ -388,8 +388,8 @@ TEST(HashTest, Hash128Trivial) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Hash128TestDescriptor(const char *repeat, size_t limit) {
|
||||
const char *mod61_encode =
|
||||
std::string Hash128TestDescriptor(const char* repeat, size_t limit) {
|
||||
const char* mod61_encode =
|
||||
"abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
std::string input;
|
||||
@@ -850,7 +850,7 @@ TEST(MathTest, Math128) {
|
||||
}
|
||||
|
||||
TEST(MathTest, Coding128) {
|
||||
const char *in = "_1234567890123456";
|
||||
const char* in = "_1234567890123456";
|
||||
// Note: in + 1 is likely unaligned
|
||||
Unsigned128 decoded = DecodeFixed128(in + 1);
|
||||
EXPECT_EQ(Lower64of128(decoded), 0x3837363534333231U);
|
||||
@@ -863,7 +863,7 @@ TEST(MathTest, Coding128) {
|
||||
}
|
||||
|
||||
TEST(MathTest, CodingGeneric) {
|
||||
const char *in = "_1234567890123456";
|
||||
const char* in = "_1234567890123456";
|
||||
// Decode
|
||||
// Note: in + 1 is likely unaligned
|
||||
Unsigned128 decoded128 = DecodeFixedGeneric<Unsigned128>(in + 1);
|
||||
@@ -899,7 +899,7 @@ TEST(MathTest, CodingGeneric) {
|
||||
EXPECT_EQ(std::string("_12"), std::string(out));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
fprintf(stderr, "NPHash64 id: %x\n",
|
||||
static_cast<int>(ROCKSDB_NAMESPACE::GetSliceNPHash64("RocksDB")));
|
||||
ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
|
||||
|
||||
@@ -719,7 +719,6 @@ TEST_F(IODispatcherTest, ReadSetDestroysUnpinsBlocks) {
|
||||
<< " final=" << final_pinned_usage;
|
||||
}
|
||||
|
||||
|
||||
// Test that verifies the coalescing logic: adjacent blocks within the
|
||||
// coalesce threshold should be combined into a single read request.
|
||||
TEST_F(IODispatcherTest, VerifyCoalescing) {
|
||||
|
||||
+19
-19
@@ -34,15 +34,15 @@ namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
class MutexLock {
|
||||
public:
|
||||
explicit MutexLock(port::Mutex *mu) : mu_(mu) { this->mu_->Lock(); }
|
||||
explicit MutexLock(port::Mutex* mu) : mu_(mu) { this->mu_->Lock(); }
|
||||
// No copying allowed
|
||||
MutexLock(const MutexLock &) = delete;
|
||||
void operator=(const MutexLock &) = delete;
|
||||
MutexLock(const MutexLock&) = delete;
|
||||
void operator=(const MutexLock&) = delete;
|
||||
|
||||
~MutexLock() { this->mu_->Unlock(); }
|
||||
|
||||
private:
|
||||
port::Mutex *const mu_;
|
||||
port::Mutex* const mu_;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -52,15 +52,15 @@ class MutexLock {
|
||||
//
|
||||
class ReadLock {
|
||||
public:
|
||||
explicit ReadLock(port::RWMutex *mu) : mu_(mu) { this->mu_->ReadLock(); }
|
||||
explicit ReadLock(port::RWMutex* mu) : mu_(mu) { this->mu_->ReadLock(); }
|
||||
// No copying allowed
|
||||
ReadLock(const ReadLock &) = delete;
|
||||
void operator=(const ReadLock &) = delete;
|
||||
ReadLock(const ReadLock&) = delete;
|
||||
void operator=(const ReadLock&) = delete;
|
||||
|
||||
~ReadLock() { this->mu_->ReadUnlock(); }
|
||||
|
||||
private:
|
||||
port::RWMutex *const mu_;
|
||||
port::RWMutex* const mu_;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -68,15 +68,15 @@ class ReadLock {
|
||||
//
|
||||
class ReadUnlock {
|
||||
public:
|
||||
explicit ReadUnlock(port::RWMutex *mu) : mu_(mu) { mu->AssertHeld(); }
|
||||
explicit ReadUnlock(port::RWMutex* mu) : mu_(mu) { mu->AssertHeld(); }
|
||||
// No copying allowed
|
||||
ReadUnlock(const ReadUnlock &) = delete;
|
||||
ReadUnlock &operator=(const ReadUnlock &) = delete;
|
||||
ReadUnlock(const ReadUnlock&) = delete;
|
||||
ReadUnlock& operator=(const ReadUnlock&) = delete;
|
||||
|
||||
~ReadUnlock() { mu_->ReadUnlock(); }
|
||||
|
||||
private:
|
||||
port::RWMutex *const mu_;
|
||||
port::RWMutex* const mu_;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -86,15 +86,15 @@ class ReadUnlock {
|
||||
//
|
||||
class WriteLock {
|
||||
public:
|
||||
explicit WriteLock(port::RWMutex *mu) : mu_(mu) { this->mu_->WriteLock(); }
|
||||
explicit WriteLock(port::RWMutex* mu) : mu_(mu) { this->mu_->WriteLock(); }
|
||||
// No copying allowed
|
||||
WriteLock(const WriteLock &) = delete;
|
||||
void operator=(const WriteLock &) = delete;
|
||||
WriteLock(const WriteLock&) = delete;
|
||||
void operator=(const WriteLock&) = delete;
|
||||
|
||||
~WriteLock() { this->mu_->WriteUnlock(); }
|
||||
|
||||
private:
|
||||
port::RWMutex *const mu_;
|
||||
port::RWMutex* const mu_;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -145,12 +145,12 @@ struct ALIGN_AS(CACHE_LINE_SIZE) CacheAlignedWrapper {
|
||||
template <class T>
|
||||
struct Unwrap {
|
||||
using type = T;
|
||||
static type &Go(T &t) { return t; }
|
||||
static type& Go(T& t) { return t; }
|
||||
};
|
||||
template <class T>
|
||||
struct Unwrap<CacheAlignedWrapper<T>> {
|
||||
using type = T;
|
||||
static type &Go(CacheAlignedWrapper<T> &t) { return t.obj_; }
|
||||
static type& Go(CacheAlignedWrapper<T>& t) { return t.obj_; }
|
||||
};
|
||||
|
||||
//
|
||||
@@ -169,7 +169,7 @@ class Striped {
|
||||
: stripe_count_(stripe_count), data_(new T[stripe_count]) {}
|
||||
|
||||
using Unwrapped = typename Unwrap<T>::type;
|
||||
Unwrapped &Get(const Key &key, uint64_t seed = 0) {
|
||||
Unwrapped& Get(const Key& key, uint64_t seed = 0) {
|
||||
size_t index = FastRangeGeneric(hash_(key, seed), stripe_count_);
|
||||
return Unwrap<T>::Go(data_[index]);
|
||||
}
|
||||
|
||||
+25
-25
@@ -545,10 +545,10 @@ namespace ribbon {
|
||||
// solution satisfying all the cr@start -> rr entries added.
|
||||
template <bool kFirstCoeffAlwaysOne, typename BandingStorage,
|
||||
typename BacktrackStorage>
|
||||
bool BandingAdd(BandingStorage *bs, typename BandingStorage::Index start,
|
||||
bool BandingAdd(BandingStorage* bs, typename BandingStorage::Index start,
|
||||
typename BandingStorage::ResultRow rr,
|
||||
typename BandingStorage::CoeffRow cr, BacktrackStorage *bts,
|
||||
typename BandingStorage::Index *backtrack_pos) {
|
||||
typename BandingStorage::CoeffRow cr, BacktrackStorage* bts,
|
||||
typename BandingStorage::Index* backtrack_pos) {
|
||||
using CoeffRow = typename BandingStorage::CoeffRow;
|
||||
using ResultRow = typename BandingStorage::ResultRow;
|
||||
using Index = typename BandingStorage::Index;
|
||||
@@ -608,8 +608,8 @@ bool BandingAdd(BandingStorage *bs, typename BandingStorage::Index start,
|
||||
//
|
||||
template <typename BandingStorage, typename BacktrackStorage,
|
||||
typename BandingHasher, typename InputIterator>
|
||||
bool BandingAddRange(BandingStorage *bs, BacktrackStorage *bts,
|
||||
const BandingHasher &bh, InputIterator begin,
|
||||
bool BandingAddRange(BandingStorage* bs, BacktrackStorage* bts,
|
||||
const BandingHasher& bh, InputIterator begin,
|
||||
InputIterator end) {
|
||||
using CoeffRow = typename BandingStorage::CoeffRow;
|
||||
using Index = typename BandingStorage::Index;
|
||||
@@ -703,7 +703,7 @@ bool BandingAddRange(BandingStorage *bs, BacktrackStorage *bts,
|
||||
//
|
||||
template <typename BandingStorage, typename BandingHasher,
|
||||
typename InputIterator>
|
||||
bool BandingAddRange(BandingStorage *bs, const BandingHasher &bh,
|
||||
bool BandingAddRange(BandingStorage* bs, const BandingHasher& bh,
|
||||
InputIterator begin, InputIterator end) {
|
||||
using Index = typename BandingStorage::Index;
|
||||
struct NoopBacktrackStorage {
|
||||
@@ -754,7 +754,7 @@ bool BandingAddRange(BandingStorage *bs, const BandingHasher &bh,
|
||||
// Back-substitution for generating a solution from BandingStorage to
|
||||
// SimpleSolutionStorage.
|
||||
template <typename SimpleSolutionStorage, typename BandingStorage>
|
||||
void SimpleBackSubst(SimpleSolutionStorage *sss, const BandingStorage &bs) {
|
||||
void SimpleBackSubst(SimpleSolutionStorage* sss, const BandingStorage& bs) {
|
||||
using CoeffRow = typename BandingStorage::CoeffRow;
|
||||
using Index = typename BandingStorage::Index;
|
||||
using ResultRow = typename BandingStorage::ResultRow;
|
||||
@@ -815,7 +815,7 @@ template <typename SimpleSolutionStorage>
|
||||
typename SimpleSolutionStorage::ResultRow SimpleQueryHelper(
|
||||
typename SimpleSolutionStorage::Index start_slot,
|
||||
typename SimpleSolutionStorage::CoeffRow cr,
|
||||
const SimpleSolutionStorage &sss) {
|
||||
const SimpleSolutionStorage& sss) {
|
||||
using CoeffRow = typename SimpleSolutionStorage::CoeffRow;
|
||||
using ResultRow = typename SimpleSolutionStorage::ResultRow;
|
||||
|
||||
@@ -833,8 +833,8 @@ typename SimpleSolutionStorage::ResultRow SimpleQueryHelper(
|
||||
// General PHSF query a key from SimpleSolutionStorage.
|
||||
template <typename SimpleSolutionStorage, typename PhsfQueryHasher>
|
||||
typename SimpleSolutionStorage::ResultRow SimplePhsfQuery(
|
||||
const typename PhsfQueryHasher::Key &key, const PhsfQueryHasher &hasher,
|
||||
const SimpleSolutionStorage &sss) {
|
||||
const typename PhsfQueryHasher::Key& key, const PhsfQueryHasher& hasher,
|
||||
const SimpleSolutionStorage& sss) {
|
||||
const typename PhsfQueryHasher::Hash hash = hasher.GetHash(key);
|
||||
|
||||
static_assert(sizeof(typename SimpleSolutionStorage::Index) ==
|
||||
@@ -850,9 +850,9 @@ typename SimpleSolutionStorage::ResultRow SimplePhsfQuery(
|
||||
|
||||
// Filter query a key from SimpleSolutionStorage.
|
||||
template <typename SimpleSolutionStorage, typename FilterQueryHasher>
|
||||
bool SimpleFilterQuery(const typename FilterQueryHasher::Key &key,
|
||||
const FilterQueryHasher &hasher,
|
||||
const SimpleSolutionStorage &sss) {
|
||||
bool SimpleFilterQuery(const typename FilterQueryHasher::Key& key,
|
||||
const FilterQueryHasher& hasher,
|
||||
const SimpleSolutionStorage& sss) {
|
||||
const typename FilterQueryHasher::Hash hash = hasher.GetHash(key);
|
||||
const typename SimpleSolutionStorage::ResultRow expected =
|
||||
hasher.GetResultRowFromHash(hash);
|
||||
@@ -968,9 +968,9 @@ bool SimpleFilterQuery(const typename FilterQueryHasher::Key &key,
|
||||
|
||||
// A helper for InterleavedBackSubst.
|
||||
template <typename BandingStorage>
|
||||
inline void BackSubstBlock(typename BandingStorage::CoeffRow *state,
|
||||
inline void BackSubstBlock(typename BandingStorage::CoeffRow* state,
|
||||
typename BandingStorage::Index num_columns,
|
||||
const BandingStorage &bs,
|
||||
const BandingStorage& bs,
|
||||
typename BandingStorage::Index start_slot) {
|
||||
using CoeffRow = typename BandingStorage::CoeffRow;
|
||||
using Index = typename BandingStorage::Index;
|
||||
@@ -1004,8 +1004,8 @@ inline void BackSubstBlock(typename BandingStorage::CoeffRow *state,
|
||||
// Back-substitution for generating a solution from BandingStorage to
|
||||
// InterleavedSolutionStorage.
|
||||
template <typename InterleavedSolutionStorage, typename BandingStorage>
|
||||
void InterleavedBackSubst(InterleavedSolutionStorage *iss,
|
||||
const BandingStorage &bs) {
|
||||
void InterleavedBackSubst(InterleavedSolutionStorage* iss,
|
||||
const BandingStorage& bs) {
|
||||
using CoeffRow = typename BandingStorage::CoeffRow;
|
||||
using Index = typename BandingStorage::Index;
|
||||
|
||||
@@ -1084,12 +1084,12 @@ void InterleavedBackSubst(InterleavedSolutionStorage *iss,
|
||||
// Prefetch memory for a key in InterleavedSolutionStorage.
|
||||
template <typename InterleavedSolutionStorage, typename PhsfQueryHasher>
|
||||
inline void InterleavedPrepareQuery(
|
||||
const typename PhsfQueryHasher::Key &key, const PhsfQueryHasher &hasher,
|
||||
const InterleavedSolutionStorage &iss,
|
||||
typename PhsfQueryHasher::Hash *saved_hash,
|
||||
typename InterleavedSolutionStorage::Index *saved_segment_num,
|
||||
typename InterleavedSolutionStorage::Index *saved_num_columns,
|
||||
typename InterleavedSolutionStorage::Index *saved_start_bit) {
|
||||
const typename PhsfQueryHasher::Key& key, const PhsfQueryHasher& hasher,
|
||||
const InterleavedSolutionStorage& iss,
|
||||
typename PhsfQueryHasher::Hash* saved_hash,
|
||||
typename InterleavedSolutionStorage::Index* saved_segment_num,
|
||||
typename InterleavedSolutionStorage::Index* saved_num_columns,
|
||||
typename InterleavedSolutionStorage::Index* saved_start_bit) {
|
||||
using Hash = typename PhsfQueryHasher::Hash;
|
||||
using CoeffRow = typename InterleavedSolutionStorage::CoeffRow;
|
||||
using Index = typename InterleavedSolutionStorage::Index;
|
||||
@@ -1131,7 +1131,7 @@ inline typename InterleavedSolutionStorage::ResultRow InterleavedPhsfQuery(
|
||||
typename InterleavedSolutionStorage::Index segment_num,
|
||||
typename InterleavedSolutionStorage::Index num_columns,
|
||||
typename InterleavedSolutionStorage::Index start_bit,
|
||||
const PhsfQueryHasher &hasher, const InterleavedSolutionStorage &iss) {
|
||||
const PhsfQueryHasher& hasher, const InterleavedSolutionStorage& iss) {
|
||||
using CoeffRow = typename InterleavedSolutionStorage::CoeffRow;
|
||||
using Index = typename InterleavedSolutionStorage::Index;
|
||||
using ResultRow = typename InterleavedSolutionStorage::ResultRow;
|
||||
@@ -1170,7 +1170,7 @@ inline bool InterleavedFilterQuery(
|
||||
typename InterleavedSolutionStorage::Index segment_num,
|
||||
typename InterleavedSolutionStorage::Index num_columns,
|
||||
typename InterleavedSolutionStorage::Index start_bit,
|
||||
const FilterQueryHasher &hasher, const InterleavedSolutionStorage &iss) {
|
||||
const FilterQueryHasher& hasher, const InterleavedSolutionStorage& iss) {
|
||||
using CoeffRow = typename InterleavedSolutionStorage::CoeffRow;
|
||||
using Index = typename InterleavedSolutionStorage::Index;
|
||||
using ResultRow = typename InterleavedSolutionStorage::ResultRow;
|
||||
|
||||
@@ -51,7 +51,7 @@ RowValue CreateRowTombstone(int64_t timestamp) {
|
||||
}
|
||||
|
||||
void VerifyRowValueColumns(
|
||||
const std::vector<std::shared_ptr<ColumnBase>> &columns,
|
||||
const std::vector<std::shared_ptr<ColumnBase>>& columns,
|
||||
std::size_t index_of_vector, int8_t expected_mask, int8_t expected_index,
|
||||
int64_t expected_timestamp) {
|
||||
EXPECT_EQ(expected_timestamp, columns[index_of_vector]->Timestamp());
|
||||
|
||||
@@ -32,7 +32,7 @@ RowValue CreateTestRowValue(
|
||||
RowValue CreateRowTombstone(int64_t timestamp);
|
||||
|
||||
void VerifyRowValueColumns(
|
||||
const std::vector<std::shared_ptr<ColumnBase>> &columns,
|
||||
const std::vector<std::shared_ptr<ColumnBase>>& columns,
|
||||
std::size_t index_of_vector, int8_t expected_mask, int8_t expected_index,
|
||||
int64_t expected_timestamp);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
namespace {
|
||||
bool MatchesInteger(const std::string &target, size_t start, size_t pos) {
|
||||
bool MatchesInteger(const std::string& target, size_t start, size_t pos) {
|
||||
// If it is numeric, everything up to the match must be a number
|
||||
int digits = 0;
|
||||
if (target[start] == '-') {
|
||||
@@ -31,7 +31,7 @@ bool MatchesInteger(const std::string &target, size_t start, size_t pos) {
|
||||
return (digits > 0);
|
||||
}
|
||||
|
||||
bool MatchesDecimal(const std::string &target, size_t start, size_t pos) {
|
||||
bool MatchesDecimal(const std::string& target, size_t start, size_t pos) {
|
||||
int digits = 0;
|
||||
if (target[start] == '-') {
|
||||
start++; // Allow negative numbers
|
||||
@@ -54,8 +54,8 @@ bool MatchesDecimal(const std::string &target, size_t start, size_t pos) {
|
||||
} // namespace
|
||||
|
||||
size_t ObjectLibrary::PatternEntry::MatchSeparatorAt(
|
||||
size_t start, Quantifier mode, const std::string &target, size_t tlen,
|
||||
const std::string &separator) const {
|
||||
size_t start, Quantifier mode, const std::string& target, size_t tlen,
|
||||
const std::string& separator) const {
|
||||
size_t slen = separator.size();
|
||||
// See if there is enough space. If so, find the separator
|
||||
if (tlen < start + slen) {
|
||||
@@ -87,9 +87,9 @@ size_t ObjectLibrary::PatternEntry::MatchSeparatorAt(
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjectLibrary::PatternEntry::MatchesTarget(const std::string &name,
|
||||
bool ObjectLibrary::PatternEntry::MatchesTarget(const std::string& name,
|
||||
size_t nlen,
|
||||
const std::string &target,
|
||||
const std::string& target,
|
||||
size_t tlen) const {
|
||||
if (separators_.empty()) {
|
||||
assert(optional_); // If there are no separators, it must be only a name
|
||||
@@ -109,7 +109,7 @@ bool ObjectLibrary::PatternEntry::MatchesTarget(const std::string &name,
|
||||
size_t start = nlen;
|
||||
auto mode = kMatchExact;
|
||||
for (size_t idx = 0; idx < separators_.size(); ++idx) {
|
||||
const auto &separator = separators_[idx];
|
||||
const auto& separator = separators_[idx];
|
||||
start = MatchSeparatorAt(start, mode, target, tlen, separator.first);
|
||||
if (start == std::string::npos) {
|
||||
return false;
|
||||
@@ -132,12 +132,12 @@ bool ObjectLibrary::PatternEntry::MatchesTarget(const std::string &name,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectLibrary::PatternEntry::Matches(const std::string &target) const {
|
||||
bool ObjectLibrary::PatternEntry::Matches(const std::string& target) const {
|
||||
auto tlen = target.size();
|
||||
if (MatchesTarget(name_, nlength_, target, tlen)) {
|
||||
return true;
|
||||
} else if (!names_.empty()) {
|
||||
for (const auto &alt : names_) {
|
||||
for (const auto& alt : names_) {
|
||||
if (MatchesTarget(alt, alt.size(), target, tlen)) {
|
||||
return true;
|
||||
}
|
||||
@@ -146,17 +146,17 @@ bool ObjectLibrary::PatternEntry::Matches(const std::string &target) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t ObjectLibrary::GetFactoryCount(size_t *types) const {
|
||||
size_t ObjectLibrary::GetFactoryCount(size_t* types) const {
|
||||
std::unique_lock<std::mutex> lock(mu_);
|
||||
*types = factories_.size();
|
||||
size_t factories = 0;
|
||||
for (const auto &e : factories_) {
|
||||
for (const auto& e : factories_) {
|
||||
factories += e.second.size();
|
||||
}
|
||||
return factories;
|
||||
}
|
||||
|
||||
size_t ObjectLibrary::GetFactoryCount(const std::string &type) const {
|
||||
size_t ObjectLibrary::GetFactoryCount(const std::string& type) const {
|
||||
std::unique_lock<std::mutex> lock(mu_);
|
||||
auto iter = factories_.find(type);
|
||||
if (iter != factories_.end()) {
|
||||
@@ -166,36 +166,36 @@ size_t ObjectLibrary::GetFactoryCount(const std::string &type) const {
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectLibrary::GetFactoryNames(const std::string &type,
|
||||
std::vector<std::string> *names) const {
|
||||
void ObjectLibrary::GetFactoryNames(const std::string& type,
|
||||
std::vector<std::string>* names) const {
|
||||
assert(names);
|
||||
std::unique_lock<std::mutex> lock(mu_);
|
||||
auto iter = factories_.find(type);
|
||||
if (iter != factories_.end()) {
|
||||
for (const auto &f : iter->second) {
|
||||
for (const auto& f : iter->second) {
|
||||
names->push_back(f->Name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectLibrary::GetFactoryTypes(
|
||||
std::unordered_set<std::string> *types) const {
|
||||
std::unordered_set<std::string>* types) const {
|
||||
assert(types);
|
||||
std::unique_lock<std::mutex> lock(mu_);
|
||||
for (const auto &iter : factories_) {
|
||||
for (const auto& iter : factories_) {
|
||||
types->insert(iter.first);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectLibrary::Dump(Logger *logger) const {
|
||||
void ObjectLibrary::Dump(Logger* logger) const {
|
||||
std::unique_lock<std::mutex> lock(mu_);
|
||||
if (logger != nullptr && !factories_.empty()) {
|
||||
ROCKS_LOG_HEADER(logger, " Registered Library: %s\n", id_.c_str());
|
||||
for (const auto &iter : factories_) {
|
||||
for (const auto& iter : factories_) {
|
||||
ROCKS_LOG_HEADER(logger, " Registered factories for type[%s] ",
|
||||
iter.first.c_str());
|
||||
bool printed_one = false;
|
||||
for (const auto &e : iter.second) {
|
||||
for (const auto& e : iter.second) {
|
||||
ROCKS_LOG_HEADER(logger, "%c %s", (printed_one) ? ',' : ':', e->Name());
|
||||
printed_one = true;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ void ObjectLibrary::Dump(Logger *logger) const {
|
||||
|
||||
// Returns the Default singleton instance of the ObjectLibrary
|
||||
// This instance will contain most of the "standard" registered objects
|
||||
std::shared_ptr<ObjectLibrary> &ObjectLibrary::Default() {
|
||||
std::shared_ptr<ObjectLibrary>& ObjectLibrary::Default() {
|
||||
// Use avoid destruction here so the default ObjectLibrary will not be
|
||||
// statically destroyed and long-lived.
|
||||
STATIC_AVOID_DESTRUCTION(std::shared_ptr<ObjectLibrary>, instance)
|
||||
@@ -213,9 +213,9 @@ std::shared_ptr<ObjectLibrary> &ObjectLibrary::Default() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
ObjectRegistry::ObjectRegistry(const std::shared_ptr<ObjectLibrary> &library) {
|
||||
ObjectRegistry::ObjectRegistry(const std::shared_ptr<ObjectLibrary>& library) {
|
||||
libraries_.push_back(library);
|
||||
for (const auto &b : builtins_) {
|
||||
for (const auto& b : builtins_) {
|
||||
RegisterPlugin(b.first, b.second);
|
||||
}
|
||||
}
|
||||
@@ -233,13 +233,13 @@ std::shared_ptr<ObjectRegistry> ObjectRegistry::NewInstance() {
|
||||
}
|
||||
|
||||
std::shared_ptr<ObjectRegistry> ObjectRegistry::NewInstance(
|
||||
const std::shared_ptr<ObjectRegistry> &parent) {
|
||||
const std::shared_ptr<ObjectRegistry>& parent) {
|
||||
return std::make_shared<ObjectRegistry>(parent);
|
||||
}
|
||||
|
||||
Status ObjectRegistry::SetManagedObject(
|
||||
const std::string &type, const std::string &id,
|
||||
const std::shared_ptr<Customizable> &object) {
|
||||
const std::string& type, const std::string& id,
|
||||
const std::shared_ptr<Customizable>& object) {
|
||||
std::string object_key = ToManagedObjectKey(type, id);
|
||||
std::shared_ptr<Customizable> curr;
|
||||
if (parent_ != nullptr) {
|
||||
@@ -267,7 +267,7 @@ Status ObjectRegistry::SetManagedObject(
|
||||
}
|
||||
|
||||
std::shared_ptr<Customizable> ObjectRegistry::GetManagedObject(
|
||||
const std::string &type, const std::string &id) const {
|
||||
const std::string& type, const std::string& id) const {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(objects_mutex_);
|
||||
auto iter = managed_objects_.find(ToManagedObjectKey(type, id));
|
||||
@@ -283,8 +283,8 @@ std::shared_ptr<Customizable> ObjectRegistry::GetManagedObject(
|
||||
}
|
||||
|
||||
Status ObjectRegistry::ListManagedObjects(
|
||||
const std::string &type, const std::string &name,
|
||||
std::vector<std::shared_ptr<Customizable>> *results) const {
|
||||
const std::string& type, const std::string& name,
|
||||
std::vector<std::shared_ptr<Customizable>>* results) const {
|
||||
{
|
||||
std::string key = ToManagedObjectKey(type, name);
|
||||
std::unique_lock<std::mutex> lock(objects_mutex_);
|
||||
@@ -309,50 +309,50 @@ Status ObjectRegistry::ListManagedObjects(
|
||||
// Returns the number of registered types for this registry.
|
||||
// If specified (not-null), types is updated to include the names of the
|
||||
// registered types.
|
||||
size_t ObjectRegistry::GetFactoryCount(const std::string &type) const {
|
||||
size_t ObjectRegistry::GetFactoryCount(const std::string& type) const {
|
||||
size_t count = 0;
|
||||
if (parent_ != nullptr) {
|
||||
count = parent_->GetFactoryCount(type);
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(library_mutex_);
|
||||
for (const auto &library : libraries_) {
|
||||
for (const auto& library : libraries_) {
|
||||
count += library->GetFactoryCount(type);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void ObjectRegistry::GetFactoryNames(const std::string &type,
|
||||
std::vector<std::string> *names) const {
|
||||
void ObjectRegistry::GetFactoryNames(const std::string& type,
|
||||
std::vector<std::string>* names) const {
|
||||
assert(names);
|
||||
names->clear();
|
||||
if (parent_ != nullptr) {
|
||||
parent_->GetFactoryNames(type, names);
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(library_mutex_);
|
||||
for (const auto &library : libraries_) {
|
||||
for (const auto& library : libraries_) {
|
||||
library->GetFactoryNames(type, names);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectRegistry::GetFactoryTypes(
|
||||
std::unordered_set<std::string> *types) const {
|
||||
std::unordered_set<std::string>* types) const {
|
||||
assert(types);
|
||||
if (parent_ != nullptr) {
|
||||
parent_->GetFactoryTypes(types);
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(library_mutex_);
|
||||
for (const auto &library : libraries_) {
|
||||
for (const auto& library : libraries_) {
|
||||
library->GetFactoryTypes(types);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectRegistry::Dump(Logger *logger) const {
|
||||
void ObjectRegistry::Dump(Logger* logger) const {
|
||||
if (logger != nullptr) {
|
||||
std::unique_lock<std::mutex> lock(library_mutex_);
|
||||
if (!plugins_.empty()) {
|
||||
ROCKS_LOG_HEADER(logger, " Registered Plugins:");
|
||||
bool printed_one = false;
|
||||
for (const auto &plugin : plugins_) {
|
||||
for (const auto& plugin : plugins_) {
|
||||
ROCKS_LOG_HEADER(logger, "%s%s", (printed_one) ? ", " : " ",
|
||||
plugin.c_str());
|
||||
printed_one = true;
|
||||
@@ -368,8 +368,8 @@ void ObjectRegistry::Dump(Logger *logger) const {
|
||||
}
|
||||
}
|
||||
|
||||
int ObjectRegistry::RegisterPlugin(const std::string &name,
|
||||
const RegistrarFunc &func) {
|
||||
int ObjectRegistry::RegisterPlugin(const std::string& name,
|
||||
const RegistrarFunc& func) {
|
||||
if (!name.empty() && func != nullptr) {
|
||||
plugins_.push_back(name);
|
||||
return AddLibrary(name)->Register(func, name);
|
||||
|
||||
@@ -165,9 +165,9 @@ struct WriteBatchIndexEntry {
|
||||
uint32_t column_family; // column family of the entry.
|
||||
// The following three fields are only maintained when the WBWI is created
|
||||
// with overwrite_key = true.
|
||||
uint32_t update_count; // The number of updates (1-based) for this key up to
|
||||
// this entry.
|
||||
bool has_single_del; // whether single del was issued for this key
|
||||
uint32_t update_count; // The number of updates (1-based) for this key up to
|
||||
// this entry.
|
||||
bool has_single_del; // whether single del was issued for this key
|
||||
bool has_overwritten_single_del; // whether a single del for this key was
|
||||
// overwritten by another key
|
||||
// The following two fields are used when search_key is null.
|
||||
|
||||
Reference in New Issue
Block a user