"make format" against last 10 commits

Summary: This helps Windows port to format their changes, as discussed. Might have formatted some other codes too becasue last 10 commits include more.

Test Plan: Build it.

Reviewers: anthony, IslamAbdelRahman, kradhakrishnan, yhchiang, igor

Reviewed By: igor

Subscribers: leveldb, dhruba

Differential Revision: https://reviews.facebook.net/D41961
main
sdong 10 years ago
parent 76d3cd3286
commit f9728640f3
  1. 17
      db/c.cc
  2. 3
      db/compaction.cc
  3. 4
      db/compaction.h
  4. 4
      db/compaction_job_stats_test.cc
  5. 7
      db/compaction_job_test.cc
  6. 8
      db/compaction_picker.cc
  7. 4
      db/db_bench.cc
  8. 10
      db/db_impl.cc
  9. 46
      db/db_test.cc
  10. 7
      db/listener_test.cc
  11. 3
      db/transaction_log_impl.h
  12. 835
      include/rocksdb/c.h
  13. 2
      include/rocksdb/thread_status.h
  14. 14
      include/rocksdb/transaction_log.h
  15. 16
      include/rocksdb/utilities/spatial_db.h
  16. 3
      include/utilities/backupable_db.h
  17. 15
      include/utilities/pragma_error.h
  18. 10
      port/dirent.h
  19. 4
      port/port.h
  20. 3
      port/port_posix.h
  21. 11
      port/sys_time.h
  22. 5
      port/util_logger.h
  23. 899
      port/win/env_win.cc
  24. 82
      port/win/port_win.cc
  25. 125
      port/win/port_win.h
  26. 37
      port/win/win_logger.cc
  27. 9
      port/win/win_logger.h
  28. 6
      table/block_based_table_builder.cc
  29. 3
      table/block_based_table_factory.cc
  30. 66
      table/cuckoo_table_builder_test.cc
  31. 4
      table/cuckoo_table_factory.h
  32. 4
      table/format.h
  33. 4
      table/plain_table_index.cc
  34. 2
      third-party/fbson/FbsonDocument.h
  35. 3
      third-party/fbson/FbsonStream.h
  36. 6
      tools/db_repl_stress.cc
  37. 65
      tools/db_stress.cc
  38. 3
      util/auto_roll_logger_test.cc
  39. 3
      util/autovector.h
  40. 3
      util/env_posix.cc
  41. 7
      util/env_test.cc
  42. 12
      util/hash_cuckoo_rep.cc
  43. 4
      util/hash_linklist_rep.cc
  44. 4
      util/histogram.h
  45. 3
      util/ldb_cmd.cc
  46. 6
      util/ldb_cmd.h
  47. 6
      util/mutable_cf_options.cc
  48. 40
      util/options.cc
  49. 9
      util/options_helper.cc
  50. 20
      util/options_test.cc
  51. 3
      util/slice.cc
  52. 35
      util/thread_local.cc
  53. 1
      util/thread_local.h
  54. 19
      utilities/backupable/backupable_db.cc
  55. 6
      utilities/checkpoint/checkpoint_test.cc
  56. 1
      utilities/geodb/geodb_impl.cc
  57. 3
      utilities/merge_operators/uint64add.cc
  58. 4
      utilities/spatialdb/spatial_db.cc
  59. 5
      utilities/ttl/ttl_test.cc

@ -2449,19 +2449,16 @@ extern void rocksdb_livefiles_destroy(
delete lf;
}
void rocksdb_get_options_from_string(
const rocksdb_options_t* base_options,
const char* opts_str, rocksdb_options_t* new_options,
char** errptr){
void rocksdb_get_options_from_string(const rocksdb_options_t* base_options,
const char* opts_str,
rocksdb_options_t* new_options,
char** errptr) {
SaveError(errptr,
GetOptionsFromString(base_options->rep,
std::string(opts_str), &new_options->rep));
GetOptionsFromString(base_options->rep, std::string(opts_str),
&new_options->rep));
}
void rocksdb_free(
void* ptr){
free(ptr);
}
void rocksdb_free(void* ptr) { free(ptr); }
} // end extern "C"

@ -270,7 +270,8 @@ const char* Compaction::InputLevelSummary(
is_first = false;
}
len += snprintf(scratch->buffer + len, sizeof(scratch->buffer) - len,
"%" ROCKSDB_PRIszt "@%d", input_level.size(), input_level.level);
"%" ROCKSDB_PRIszt "@%d", input_level.size(),
input_level.level);
}
snprintf(scratch->buffer + len, sizeof(scratch->buffer) - len,
" files to L%d", output_level());

@ -122,9 +122,7 @@ class Compaction {
bool IsTrivialMove() const;
// If true, then the compaction can be done by simply deleting input files.
bool deletion_compaction() const {
return deletion_compaction_;
}
bool deletion_compaction() const { return deletion_compaction_; }
// Add all inputs to this compaction as delete operations to *edit.
void AddInputDeletions(VersionEdit* edit);

@ -777,7 +777,5 @@ int main(int argc, char** argv) {
#else
int main(int argc, char** argv) {
return 0;
}
int main(int argc, char** argv) { return 0; }
#endif // !defined(IOS_CROSS_COMPILE)

@ -165,8 +165,7 @@ void VerifyInitializationOfCompactionJobStats(
#endif // !defined(IOS_CROSS_COMPILE)
}
void VerifyCompactionJobStats(
const CompactionJobStats& compaction_job_stats,
void VerifyCompactionJobStats(const CompactionJobStats& compaction_job_stats,
const std::vector<FileMetaData*>& files,
size_t num_output_files) {
ASSERT_GE(compaction_job_stats.elapsed_micros, 0U);
@ -219,9 +218,7 @@ TEST_F(CompactionJobTest, Simple) {
ASSERT_OK(s);
mutex_.Unlock();
VerifyCompactionJobStats(
compaction_job_stats,
files, 1);
VerifyCompactionJobStats(compaction_job_stats, files, 1);
mock_table_factory_->AssertLatestFile(expected_results);
ASSERT_EQ(yield_callback_called, 20000);

@ -401,8 +401,9 @@ bool CompactionPicker::SetupOtherInputs(
if (expanded1.size() == output_level_inputs->size() &&
!FilesInCompaction(expanded1)) {
Log(InfoLogLevel::INFO_LEVEL, ioptions_.info_log,
"[%s] Expanding@%d %" ROCKSDB_PRIszt "+%" ROCKSDB_PRIszt "(%" PRIu64 "+%" PRIu64
" bytes) to %" ROCKSDB_PRIszt "+%" ROCKSDB_PRIszt " (%" PRIu64 "+%" PRIu64 "bytes)\n",
"[%s] Expanding@%d %" ROCKSDB_PRIszt "+%" ROCKSDB_PRIszt "(%" PRIu64
"+%" PRIu64 " bytes) to %" ROCKSDB_PRIszt "+%" ROCKSDB_PRIszt
" (%" PRIu64 "+%" PRIu64 "bytes)\n",
cf_name.c_str(), input_level, inputs->size(),
output_level_inputs->size(), inputs0_size, inputs1_size,
expanded0.size(), expanded1.size(), expanded0_size, inputs1_size);
@ -1225,7 +1226,8 @@ Compaction* UniversalCompactionPicker::PickCompaction(
return nullptr;
}
VersionStorageInfo::LevelSummaryStorage tmp;
LogToBuffer(log_buffer, 3072, "[%s] Universal: sorted runs files(%" ROCKSDB_PRIszt "): %s\n",
LogToBuffer(log_buffer, 3072,
"[%s] Universal: sorted runs files(%" ROCKSDB_PRIszt "): %s\n",
cf_name.c_str(), sorted_runs.size(),
vstorage->LevelSummary(&tmp));

@ -3544,8 +3544,8 @@ class Benchmark {
char msg[100];
snprintf(msg, sizeof(msg),
"(reads:%" PRIu64 " merges:%" PRIu64 " total:%" PRIu64 " hits:%" \
PRIu64 " maxlength:%" ROCKSDB_PRIszt ")",
"(reads:%" PRIu64 " merges:%" PRIu64 " total:%" PRIu64
" hits:%" PRIu64 " maxlength:%" ROCKSDB_PRIszt ")",
num_gets, num_merges, readwrites_, num_hits, max_length);
thread->stats.AddMessage(msg);
}

@ -1631,9 +1631,9 @@ Status DBImpl::CompactFilesImpl(
CompactionJob compaction_job(
job_context->job_id, c.get(), db_options_, env_options_, versions_.get(),
&shutting_down_, log_buffer, directories_.GetDbDir(),
directories_.GetDataDir(c->output_path_id()), stats_,
snapshots_.GetAll(), table_cache_, std::move(yield_callback),
&event_logger_, c->mutable_cf_options()->paranoid_file_checks, dbname_,
directories_.GetDataDir(c->output_path_id()), stats_, snapshots_.GetAll(),
table_cache_, std::move(yield_callback), &event_logger_,
c->mutable_cf_options()->paranoid_file_checks, dbname_,
nullptr); // Here we pass a nullptr for CompactionJobStats because
// CompactFiles does not trigger OnCompactionCompleted(),
// which is the only place where CompactionJobStats is
@ -2602,8 +2602,8 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, JobContext* job_context,
versions_.get(), &shutting_down_, log_buffer, directories_.GetDbDir(),
directories_.GetDataDir(c->output_path_id()), stats_,
snapshots_.GetAll(), table_cache_, std::move(yield_callback),
&event_logger_, c->mutable_cf_options()->paranoid_file_checks,
dbname_, &compaction_job_stats);
&event_logger_, c->mutable_cf_options()->paranoid_file_checks, dbname_,
&compaction_job_stats);
compaction_job.Prepare();
mutex_.Unlock();

@ -7,20 +7,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
// Introduction of SyncPoint effectively disabled building and running this test in Release build.
// Introduction of SyncPoint effectively disabled building and running this test
// in Release build.
// which is a pity, it is a good test
#if !(defined NDEBUG) || !defined (OS_WIN)
#if !(defined NDEBUG) || !defined(OS_WIN)
#include <algorithm>
#include <iostream>
#include <set>
#ifndef OS_WIN
# include <unistd.h>
#endif
#include <thread>
#include <unordered_set>
#include <utility>
#include <fcntl.h>
#ifndef OS_WIN
#include <unistd.h>
#endif
#include "db/filename.h"
#include "db/dbformat.h"
@ -8716,7 +8717,6 @@ TEST_F(DBTest, TransactionLogIteratorCorruptedLog) {
//
class RecoveryTestHelper {
public:
// Number of WAL files to generate
static const int kWALFilesCount = 10;
// Starting number for the WAL file name like 00010.log
@ -8727,9 +8727,9 @@ class RecoveryTestHelper {
static const int kValueSize = 10;
// Create WAL files with values filled in
static void FillData(DBTest* test, Options& options,
const size_t wal_count, size_t & count) {
DBOptions & db_options = options;
static void FillData(DBTest* test, Options& options, const size_t wal_count,
size_t& count) {
DBOptions& db_options = options;
count = 0;
@ -8793,9 +8793,9 @@ class RecoveryTestHelper {
}
// Manuall corrupt the specified WAL
static void CorruptWAL(DBTest * test, Options& options,
const double off, const double len,
const int wal_file_id, const bool trunc = false) {
static void CorruptWAL(DBTest* test, Options& options, const double off,
const double len, const int wal_file_id,
const bool trunc = false) {
Env* env = options.env;
std::string fname = LogFileName(test->dbname_, wal_file_id);
uint64_t size;
@ -8849,8 +8849,8 @@ TEST_F(DBTest, kTolerateCorruptedTailRecords) {
Options options = CurrentOptions();
const size_t row_count = RecoveryTestHelper::FillData(this, options);
// test checksum failure or parsing
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/ i * .3,
/*len%=*/ .1, /*wal=*/ j, trunc);
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
/*len%=*/.1, /*wal=*/j, trunc);
if (trunc) {
options.wal_recovery_mode =
@ -8895,7 +8895,7 @@ TEST_F(DBTest, kAbsoluteConsistency) {
// fill with new date
RecoveryTestHelper::FillData(this, options);
// corrupt the wal
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/ i * .3,
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
/*len%=*/.1, j, trunc);
// verify
options.wal_recovery_mode = WALRecoveryMode::kAbsoluteConsistency;
@ -8912,8 +8912,8 @@ TEST_F(DBTest, kAbsoluteConsistency) {
TEST_F(DBTest, kPointInTimeRecovery) {
const int jstart = RecoveryTestHelper::kWALFileOffset;
const int jend = jstart + RecoveryTestHelper::kWALFilesCount;
const int maxkeys = RecoveryTestHelper::kWALFilesCount *
RecoveryTestHelper::kKeysPerWALFile;
const int maxkeys =
RecoveryTestHelper::kWALFilesCount * RecoveryTestHelper::kKeysPerWALFile;
for (auto trunc : {true, false}) { /* Corruption style */
for (int i = 0; i < 4; i++) { /* Offset of corruption */
@ -8923,7 +8923,7 @@ TEST_F(DBTest, kPointInTimeRecovery) {
const size_t row_count = RecoveryTestHelper::FillData(this, options);
// Corrupt the wal
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/ i * .3,
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
/*len%=*/.1, j, trunc);
// Verify
@ -8972,7 +8972,7 @@ TEST_F(DBTest, kSkipAnyCorruptedRecords) {
const size_t row_count = RecoveryTestHelper::FillData(this, options);
// Corrupt the WAL
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/ i * .3,
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
/*len%=*/.1, j, trunc);
// Verify behavior
@ -11228,8 +11228,8 @@ TEST_F(DBTest, DynamicMemtableOptions) {
count++;
}
ASSERT_GT(sleep_count.load(), 0);
// Windows fails this test. Will tune in the future and figure out
// approp number
// Windows fails this test. Will tune in the future and figure out
// approp number
#ifndef OS_WIN
ASSERT_GT(static_cast<double>(count), 512 * 0.8);
ASSERT_LT(static_cast<double>(count), 512 * 1.2);
@ -11254,8 +11254,8 @@ TEST_F(DBTest, DynamicMemtableOptions) {
count++;
}
ASSERT_GT(sleep_count.load(), 0);
// Windows fails this test. Will tune in the future and figure out
// approp number
// Windows fails this test. Will tune in the future and figure out
// approp number
#ifndef OS_WIN
ASSERT_GT(static_cast<double>(count), 256 * 0.8);
ASSERT_LT(static_cast<double>(count), 266 * 1.2);

@ -216,11 +216,8 @@ TEST_F(EventListenerTest, OnSingleDBCompactionTest) {
// This simple Listener can only handle one flush at a time.
class TestFlushListener : public EventListener {
public:
explicit TestFlushListener(Env* env) :
slowdown_count(0),
stop_count(0),
db_closed(),
env_(env) {
explicit TestFlushListener(Env* env)
: slowdown_count(0), stop_count(0), db_closed(), env_(env) {
db_closed = false;
}
void OnTableFileCreated(

@ -90,7 +90,8 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
Env* env;
Logger* info_log;
virtual void Corruption(size_t bytes, const Status& s) override {
Log(InfoLogLevel::ERROR_LEVEL, info_log, "dropping %" ROCKSDB_PRIszt " bytes; %s", bytes,
Log(InfoLogLevel::ERROR_LEVEL, info_log,
"dropping %" ROCKSDB_PRIszt " bytes; %s", bytes,
s.ToString().c_str());
}
virtual void Info(const char* s) {

File diff suppressed because it is too large Load Diff

@ -33,7 +33,7 @@ namespace rocksdb {
// TODO(yhchiang): remove this function once c++14 is available
// as std::max will be able to cover this.
// Current MS compiler does not support constexpr
template<int A, int B>
template <int A, int B>
struct constexpr_max {
static const int result = (A > B) ? A : B;
};

@ -62,21 +62,19 @@ struct BatchResult {
// Add empty __ctor and __dtor for the rule of five
// However, preserve the original semantics and prohibit copying
// as the unique_ptr member does not copy.
BatchResult() {
}
BatchResult() {}
~BatchResult() {
}
~BatchResult() {}
BatchResult(const BatchResult&) = delete;
BatchResult& operator=(const BatchResult&) = delete;
BatchResult(BatchResult && bResult) :
sequence(std::move(bResult.sequence)), writeBatchPtr(std::move(bResult.writeBatchPtr)) {
}
BatchResult(BatchResult&& bResult)
: sequence(std::move(bResult.sequence)),
writeBatchPtr(std::move(bResult.writeBatchPtr)) {}
BatchResult& operator=(BatchResult && bResult) {
BatchResult& operator=(BatchResult&& bResult) {
sequence = std::move(bResult.sequence);
writeBatchPtr = std::move(bResult.writeBatchPtr);
return *this;

@ -57,21 +57,15 @@ struct Variant {
new (&data_.s) std::string(s);
}
Variant(const Variant& v) : type_(v.type_) {
Init(v, data_);
}
Variant(const Variant& v) : type_(v.type_) { Init(v, data_); }
Variant& operator=(const Variant& v);
Variant(Variant&& rhs) : type_(kNull) {
*this = std::move(rhs);
}
Variant(Variant&& rhs) : type_(kNull) { *this = std::move(rhs); }
Variant& operator=(Variant&& v);
~Variant() {
Destroy(type_, data_);
}
~Variant() { Destroy(type_, data_); }
Type type() const { return type_; }
bool get_bool() const { return data_.b; }
@ -83,14 +77,14 @@ struct Variant {
bool operator!=(const Variant& other) const { return !(*this == other); }
private:
Type type_;
union Data {
bool b;
uint64_t i;
double d;
// Current version of MS compiler not C++11 compliant so can not put std::string
// Current version of MS compiler not C++11 compliant so can not put
// std::string
// however, even then we still need the rest of the maintenance.
char s[sizeof(std::string)];
} data_;

@ -11,6 +11,7 @@
#include "pragma_error.h"
ROCKSDB_WARNING("Warning: This file was moved to rocksdb/utilities/backupable_db.h")
ROCKSDB_WARNING(
"Warning: This file was moved to rocksdb/utilities/backupable_db.h")
#include "rocksdb/utilities/backupable_db.h"

@ -13,25 +13,24 @@
#define RDB_STR__(x) #x
#define RDB_STR(x) RDB_STR__(x)
#if defined(ROCKSDB_PLATFORM_POSIX)
// Wrap unportable warning macro
# define ROCKSDB_WARNING(x) _Pragma(RDB_STR(GCC warning(x)))
#define ROCKSDB_WARNING(x) _Pragma(RDB_STR(GCC warning(x)))
#elif defined(OS_WIN)
// Wrap unportable warning macro
#if defined(_MSC_VER)
// format it according to visual studio output (to get source lines and warnings in the IDE)
#define ROCKSDB_WARNING(x) __pragma( message(__FILE__ "(" RDB_STR(__LINE__) ") : warning: " x) )
// format it according to visual studio output (to get source lines and warnings
// in the IDE)
#define ROCKSDB_WARNING(x) \
__pragma(message(__FILE__ "(" RDB_STR(__LINE__) ") : warning: " x))
#else
// make #warning into #pragma GCC warning gcc 4.7+ and clang 3.2+ supported
#define ROCKSDB_WARNING(x) _Pragma(RDB_STR(GCC warning(x)))
// make #warning into #pragma GCC warning gcc 4.7+ and clang 3.2+ supported
#define ROCKSDB_WARNING(x) _Pragma(RDB_STR(GCC warning(x)))
#endif
#endif
#endif // STORAGE_LEVELDB_UTILITIES_PRAGMA_ERROR_H_

@ -13,8 +13,8 @@
#define STORAGE_LEVELDB_PORT_DIRENT_H_
#ifdef ROCKSDB_PLATFORM_POSIX
# include <sys/types.h>
# include <dirent.h>
#include <dirent.h>
#include <sys/types.h>
#elif defined(OS_WIN)
namespace rocksdb {
@ -42,10 +42,6 @@ using port::closedir;
} // namespace rocksdb
#endif
#endif // OS_WIN
#endif // STORAGE_LEVELDB_PORT_DIRENT_H_

@ -15,8 +15,8 @@
// porting to a new platform, see "port_example.h" for documentation
// of what the new port_<platform>.h file must provide.
#if defined(ROCKSDB_PLATFORM_POSIX)
# include "port/port_posix.h"
#include "port/port_posix.h"
#elif defined(OS_WIN)
# include "port/win/port_win.h"
#include "port/win/port_win.h"
#endif

@ -11,7 +11,8 @@
#pragma once
// size_t printf formatting named in the manner of C99 standard formatting strings such as PRIu64
// size_t printf formatting named in the manner of C99 standard formatting
// strings such as PRIu64
// in fact, we could use that one
#define ROCKSDB_PRIszt "zu"

@ -7,7 +7,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
// This file is a portable substitute for sys/time.h which does not exist on Windows
// This file is a portable substitute for sys/time.h which does not exist on
// Windows
#ifndef STORAGE_LEVELDB_PORT_SYS_TIME_H_
#define STORAGE_LEVELDB_PORT_SYS_TIME_H_
@ -28,12 +29,10 @@ typedef struct timeval {
void gettimeofday(struct timeval* tv, struct timezone* tz);
inline
struct tm* localtime_r(const time_t *timep, struct tm *result) {
inline struct tm* localtime_r(const time_t* timep, struct tm* result) {
errno_t ret = localtime_s(result, timep);
return (ret == 0) ? result : NULL;
}
}
using port::timeval;
@ -42,8 +41,8 @@ using port::localtime_r;
}
#else
# include <time.h>
# include <sys/time.h>
#include <time.h>
#include <sys/time.h>
#endif
#endif // STORAGE_LEVELDB_PORT_SYS_TIME_H_

@ -14,11 +14,10 @@
// porting to a new platform, see "port_example.h" for documentation
// of what the new port_<platform>.h file must provide.
#if defined(ROCKSDB_PLATFORM_POSIX)
# include "util/posix_logger.h"
#include "util/posix_logger.h"
#elif defined(OS_WIN)
# include "port/win/win_logger.h"
#include "port/win/win_logger.h"
#endif
#endif // STORAGE_LEVELDB_PORT_UTIL_LOGGER_H_

File diff suppressed because it is too large Load Diff

@ -28,16 +28,14 @@
#include "util/logging.h"
namespace rocksdb
{
namespace port
{
namespace rocksdb {
namespace port {
void gettimeofday(struct timeval* tv, struct timezone* /* tz */) {
using namespace std::chrono;
microseconds usNow (duration_cast<microseconds>(system_clock::now().time_since_epoch()));
microseconds usNow(
duration_cast<microseconds>(system_clock::now().time_since_epoch()));
seconds secNow(duration_cast<seconds>(usNow));
@ -45,15 +43,11 @@ void gettimeofday(struct timeval* tv, struct timezone* /* tz */) {
tv->tv_usec = usNow.count() - duration_cast<microseconds>(secNow).count();
}
Mutex::Mutex(bool adaptive) : lock(m_mutex, std::defer_lock) {}
Mutex::Mutex(bool adaptive) : lock(m_mutex, std::defer_lock) {
}
Mutex::~Mutex() {
}
Mutex::~Mutex() {}
void Mutex::Lock() {
lock.lock();
#ifndef NDEBUG
locked_ = true;
@ -61,7 +55,6 @@ void Mutex::Lock() {
}
void Mutex::Unlock() {
#ifndef NDEBUG
locked_ = false;
#endif
@ -74,11 +67,9 @@ void Mutex::AssertHeld() {
#endif
}
CondVar::CondVar(Mutex* mu) : mu_(mu) {
}
CondVar::CondVar(Mutex* mu) : mu_(mu) {}
CondVar::~CondVar() {
}
CondVar::~CondVar() {}
void CondVar::Wait() {
#ifndef NDEBUG
@ -90,7 +81,6 @@ void CondVar::Wait() {
#endif
}
bool CondVar::TimedWait(uint64_t abs_time_us) {
#ifndef NDEBUG
mu_->locked_ = false;
@ -99,8 +89,10 @@ bool CondVar::TimedWait(uint64_t abs_time_us) {
using namespace std::chrono;
microseconds usAbsTime(abs_time_us);
microseconds usNow(duration_cast<microseconds>(system_clock::now().time_since_epoch()));
microseconds relTimeUs = (usAbsTime > usNow) ? (usAbsTime - usNow) : microseconds::zero();
microseconds usNow(
duration_cast<microseconds>(system_clock::now().time_since_epoch()));
microseconds relTimeUs =
(usAbsTime > usNow) ? (usAbsTime - usNow) : microseconds::zero();
std::_Cv_status cvStatus = cv_.wait_for(mu_->getLock(), relTimeUs);
@ -115,17 +107,11 @@ bool CondVar::TimedWait(uint64_t abs_time_us) {
return false;
}
void CondVar::Signal() {
void CondVar::Signal() { cv_.notify_one(); }
cv_.notify_one();
}
void CondVar::SignalAll() {
cv_.notify_all ();
}
void CondVar::SignalAll() { cv_.notify_all(); }
void InitOnce(OnceType* once, void (*initializer)()) {
std::call_once(*once, initializer);
}
@ -142,16 +128,13 @@ struct DIR {
DIR& operator=(const DIR&) = delete;
~DIR() {
if (-1 != handle_) {
_findclose(handle_);
}
}
};
DIR* opendir(const char* name) {
if (!name || *name == 0) {
errno = ENOENT;
return nullptr;
@ -174,7 +157,6 @@ DIR* opendir(const char* name) {
}
struct dirent* readdir(DIR* dirp) {
if (!dirp || dirp->handle_ == -1) {
errno = EBADF;
return nullptr;
@ -202,7 +184,6 @@ int closedir(DIR* dirp) {
}
int truncate(const char* path, int64_t len) {
if (path == nullptr) {
errno = EFAULT;
return -1;
@ -213,13 +194,12 @@ int truncate(const char* path, int64_t len) {
return -1;
}
HANDLE hFile = CreateFile(path,
GENERIC_READ | GENERIC_WRITE,
HANDLE hFile =
CreateFile(path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, // Security attrs
OPEN_EXISTING, // Truncate existing file only
FILE_ATTRIBUTE_NORMAL,
NULL);
FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == hFile) {
auto lastError = GetLastError();
@ -237,9 +217,7 @@ int truncate(const char* path, int64_t len) {
FILE_END_OF_FILE_INFO end_of_file;
end_of_file.EndOfFile.QuadPart = len;
if (!SetFileInformationByHandle(hFile,
FileEndOfFileInfo,
&end_of_file,
if (!SetFileInformationByHandle(hFile, FileEndOfFileInfo, &end_of_file,
sizeof(FILE_END_OF_FILE_INFO))) {
errno = EIO;
result = -1;
@ -260,8 +238,7 @@ namespace rocksdb {
namespace port {
__declspec(noinline)
void WINAPI InitializeJemalloc() {
__declspec(noinline) void WINAPI InitializeJemalloc() {
je_init();
atexit(je_uninit);
}
@ -275,15 +252,17 @@ extern "C" {
#pragma comment(linker, "/INCLUDE:p_rocksdb_init_jemalloc")
typedef void (WINAPI *CRT_Startup_Routine)(void);
typedef void(WINAPI* CRT_Startup_Routine)(void);
// .CRT section is merged with .rdata on x64 so it must be constant data.
// must be of external linkage
// We put this into XCT since we want to run this earlier than C++ static constructors
// We put this into XCT since we want to run this earlier than C++ static
// constructors
// which are placed into XCU
#pragma const_seg(".CRT$XCT")
extern const CRT_Startup_Routine p_rocksdb_init_jemalloc;
const CRT_Startup_Routine p_rocksdb_init_jemalloc = rocksdb::port::InitializeJemalloc;
const CRT_Startup_Routine p_rocksdb_init_jemalloc =
rocksdb::port::InitializeJemalloc;
#pragma const_seg()
#else // _WIN64
@ -293,8 +272,8 @@ const CRT_Startup_Routine p_rocksdb_init_jemalloc = rocksdb::port::InitializeJem
#pragma comment(linker, "/INCLUDE:_p_rocksdb_init_jemalloc")
#pragma section(".CRT$XCT", read)
JEMALLOC_SECTION(".CRT$XCT") JEMALLOC_ATTR(used)
static const void (WINAPI *p_rocksdb_init_jemalloc)(void) = rocksdb::port::InitializeJemalloc;
JEMALLOC_SECTION(".CRT$XCT") JEMALLOC_ATTR(used) static const void(
WINAPI* p_rocksdb_init_jemalloc)(void) = rocksdb::port::InitializeJemalloc;
#endif // _WIN64
@ -318,13 +297,8 @@ void* operator new[](size_t size) {
return p;
}
void operator delete(void* p) {
je_free(p);
}
void operator delete(void* p) { je_free(p); }
void operator delete[](void* p) {
je_free(p);
}
void operator delete[](void* p) { je_free(p); }
#endif // JEMALLOC

@ -14,7 +14,7 @@
// Always want minimum headers
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
// Assume that for everywhere
@ -42,7 +42,8 @@
typedef SSIZE_T ssize_t;
// size_t printf formatting named in the manner of C99 standard formatting strings such as PRIu64
// size_t printf formatting named in the manner of C99 standard formatting
// strings such as PRIu64
// in fact, we could use that one
#define ROCKSDB_PRIszt "Iu"
@ -77,8 +78,7 @@ namespace rocksdb {
#define PREFETCH(addr, rw, locality)
namespace port
{
namespace port {
// For use at db/file_indexer.h kLevelMaxIndex
const int kMaxInt32 = INT32_MAX;
@ -88,9 +88,8 @@ const bool kLittleEndian = true;
class CondVar;
class Mutex
{
public:
class Mutex {
public:
/* implicit */ Mutex(bool adaptive = false);
~Mutex();
@ -101,11 +100,9 @@ public:
// it does NOT verify that mutex is held by a calling thread
void AssertHeld();
std::unique_lock<std::mutex>& getLock() {
return lock;
}
std::unique_lock<std::mutex>& getLock() { return lock; }
private:
private:
friend class CondVar;
std::mutex m_mutex;
std::unique_lock<std::mutex> lock;
@ -118,52 +115,40 @@ private:
void operator=(const Mutex&);
};
class RWMutex
{
public:
RWMutex() {
InitializeSRWLock(&srwLock_);
}
class RWMutex {
public:
RWMutex() { InitializeSRWLock(&srwLock_); }
void ReadLock() {
AcquireSRWLockShared(&srwLock_);
}
void ReadLock() { AcquireSRWLockShared(&srwLock_); }
void WriteLock() {
AcquireSRWLockExclusive(&srwLock_);
}
void WriteLock() { AcquireSRWLockExclusive(&srwLock_); }
void ReadUnlock() {
ReleaseSRWLockShared(&srwLock_);
}
void ReadUnlock() { ReleaseSRWLockShared(&srwLock_); }
void WriteUnlock() {
ReleaseSRWLockExclusive(&srwLock_);
}
void WriteUnlock() { ReleaseSRWLockExclusive(&srwLock_); }
// Empty as in POSIX
void AssertHeld() { }
private:
void AssertHeld() {}
private:
SRWLOCK srwLock_;
// No copying allowed
RWMutex(const RWMutex&);
void operator=(const RWMutex&);
};
class CondVar
{
public:
class CondVar {
public:
explicit CondVar(Mutex* mu);
~CondVar();
void Wait();
bool TimedWait(uint64_t expiration_time);
void Signal();
void SignalAll();
private:
private:
std::condition_variable cv_;
Mutex * mu_;
Mutex* mu_;
};
typedef std::once_flag OnceType;
@ -171,8 +156,7 @@ typedef std::once_flag OnceType;
extern void InitOnce(OnceType* once, void (*initializer)());
inline bool Snappy_Compress(const CompressionOptions& opts, const char* input,
size_t length, ::std::string* output)
{
size_t length, ::std::string* output) {
#ifdef SNAPPY
output->resize(snappy::MaxCompressedLength(length));
size_t outlen;
@ -192,8 +176,7 @@ inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
#endif
}
inline bool Snappy_Uncompress(const char* input, size_t length,
char* output) {
inline bool Snappy_Uncompress(const char* input, size_t length, char* output) {
#ifdef SNAPPY
return snappy::RawUncompress(input, length, output);
#else
@ -223,14 +206,14 @@ inline bool Zlib_Compress(const CompressionOptions& opts, const char* input,
output->resize(length);
// Compress the input, and put compressed data in output.
_stream.next_in = (Bytef *)input;
_stream.next_in = (Bytef*)input;
_stream.avail_in = length;
// Initialize the output size.
_stream.avail_out = length;
_stream.next_out = (Bytef *)&(*output)[0];
_stream.next_out = (Bytef*)&(*output)[0];
int old_sz =0, new_sz =0, new_sz_delta =0;
int old_sz = 0, new_sz = 0, new_sz_delta = 0;
bool done = false;
while (!done) {
int st = deflate(&_stream, Z_FINISH);
@ -246,7 +229,7 @@ inline bool Zlib_Compress(const CompressionOptions& opts, const char* input,
new_sz = output->size() + (new_sz_delta < 10 ? 10 : new_sz_delta);
output->resize(new_sz);
// Set more output.
_stream.next_out = (Bytef *)&(*output)[old_sz];
_stream.next_out = (Bytef*)&(*output)[old_sz];
_stream.avail_out = new_sz - old_sz;
break;
case Z_BUF_ERROR:
@ -272,13 +255,13 @@ inline char* Zlib_Uncompress(const char* input_data, size_t input_length,
// For raw inflate, the windowBits should be -8..-15.
// If windowBits is bigger than zero, it will use either zlib
// header or gzip header. Adding 32 to it will do automatic detection.
int st = inflateInit2(&_stream,
windowBits > 0 ? windowBits + 32 : windowBits);
int st =
inflateInit2(&_stream, windowBits > 0 ? windowBits + 32 : windowBits);
if (st != Z_OK) {
return nullptr;
}
_stream.next_in = (Bytef *)input_data;
_stream.next_in = (Bytef*)input_data;
_stream.avail_in = input_length;
// Assume the decompressed data size will 5x of compressed size.
@ -286,14 +269,14 @@ inline char* Zlib_Uncompress(const char* input_data, size_t input_length,
char* output = new char[output_len];
int old_sz = output_len;
_stream.next_out = (Bytef *)output;
_stream.next_out = (Bytef*)output;
_stream.avail_out = output_len;
char* tmp = nullptr;
int output_len_delta;
bool done = false;
//while(_stream.next_in != nullptr && _stream.avail_in != 0) {
// while(_stream.next_in != nullptr && _stream.avail_in != 0) {
while (!done) {
int st = inflate(&_stream, Z_SYNC_FLUSH);
switch (st) {
@ -311,7 +294,7 @@ inline char* Zlib_Uncompress(const char* input_data, size_t input_length,
output = tmp;
// Set more output.
_stream.next_out = (Bytef *)(output + old_sz);
_stream.next_out = (Bytef*)(output + old_sz);
_stream.avail_out = output_len - old_sz;
break;
case Z_BUF_ERROR:
@ -349,15 +332,15 @@ inline bool BZip2_Compress(const CompressionOptions& opts, const char* input,
output->resize(length);
// Compress the input, and put compressed data in output.
_stream.next_in = (char *)input;
_stream.next_in = (char*)input;
_stream.avail_in = length;
// Initialize the output size.
_stream.next_out = (char *)&(*output)[0];
_stream.next_out = (char*)&(*output)[0];
_stream.avail_out = length;
int old_sz =0, new_sz =0;
while(_stream.next_in != nullptr && _stream.avail_in != 0) {
int old_sz = 0, new_sz = 0;
while (_stream.next_in != nullptr && _stream.avail_in != 0) {
int st = BZ2_bzCompress(&_stream, BZ_FINISH);
switch (st) {
case BZ_STREAM_END:
@ -369,7 +352,7 @@ inline bool BZip2_Compress(const CompressionOptions& opts, const char* input,
new_sz = (int)(output->size() * 1.2);
output->resize(new_sz);
// Set more output.
_stream.next_out = (char *)&(*output)[old_sz];
_stream.next_out = (char*)&(*output)[old_sz];
_stream.avail_out = new_sz - old_sz;
break;
case BZ_SEQUENCE_ERROR:
@ -397,7 +380,7 @@ inline char* BZip2_Uncompress(const char* input_data, size_t input_length,
return nullptr;
}
_stream.next_in = (char *)input_data;
_stream.next_in = (char*)input_data;
_stream.avail_in = input_length;
// Assume the decompressed data size will be 5x of compressed size.
@ -405,12 +388,12 @@ inline char* BZip2_Uncompress(const char* input_data, size_t input_length,
char* output = new char[output_len];
int old_sz = output_len;
_stream.next_out = (char *)output;
_stream.next_out = (char*)output;
_stream.avail_out = output_len;
char* tmp = nullptr;
while(_stream.next_in != nullptr && _stream.avail_in != 0) {
while (_stream.next_in != nullptr && _stream.avail_in != 0) {
int st = BZ2_bzDecompress(&_stream);
switch (st) {
case BZ_STREAM_END:
@ -425,7 +408,7 @@ inline char* BZip2_Uncompress(const char* input_data, size_t input_length,
output = tmp;
// Set more output.
_stream.next_out = (char *)(output + old_sz);
_stream.next_out = (char*)(output + old_sz);
_stream.avail_out = output_len - old_sz;
break;
default:
@ -442,12 +425,12 @@ inline char* BZip2_Uncompress(const char* input_data, size_t input_length,
return nullptr;
}
inline bool LZ4_Compress(const CompressionOptions &opts, const char *input,
inline bool LZ4_Compress(const CompressionOptions& opts, const char* input,
size_t length, ::std::string* output) {
#ifdef LZ4
int compressBound = LZ4_compressBound(length);
output->resize(8 + compressBound);
char *p = const_cast<char *>(output->c_str());
char* p = const_cast<char*>(output->c_str());
memcpy(p, &length, sizeof(length));
size_t outlen;
outlen = LZ4_compress_limitedOutput(input, p + 8, length, compressBound);
@ -468,7 +451,7 @@ inline char* LZ4_Uncompress(const char* input_data, size_t input_length,
}
int output_len;
memcpy(&output_len, input_data, sizeof(output_len));
char *output = new char[output_len];
char* output = new char[output_len];
*decompress_size = LZ4_decompress_safe_partial(
input_data + 8, output, input_length - 8, output_len, output_len);
if (*decompress_size < 0) {
@ -480,12 +463,12 @@ inline char* LZ4_Uncompress(const char* input_data, size_t input_length,
return nullptr;
}
inline bool LZ4HC_Compress(const CompressionOptions &opts, const char* input,
inline bool LZ4HC_Compress(const CompressionOptions& opts, const char* input,
size_t length, ::std::string* output) {
#ifdef LZ4
int compressBound = LZ4_compressBound(length);
output->resize(8 + compressBound);
char *p = const_cast<char *>(output->c_str());
char* p = const_cast<char*>(output->c_str());
memcpy(p, &length, sizeof(length));
size_t outlen;
#ifdef LZ4_VERSION_MAJOR // they only started defining this since r113
@ -515,8 +498,7 @@ inline bool LZ4HC_Compress(const CompressionOptions &opts, const char* input,
// For Thread Local Storage abstraction
typedef DWORD pthread_key_t;
inline
int pthread_key_create(pthread_key_t *key, void(*destructor)(void*)) {
inline int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)) {
// Not used
(void)destructor;
@ -529,24 +511,21 @@ int pthread_key_create(pthread_key_t *key, void(*destructor)(void*)) {
return 0;
}
inline
int pthread_key_delete(pthread_key_t key) {
inline int pthread_key_delete(pthread_key_t key) {
if (!TlsFree(key)) {
return EINVAL;
}
return 0;
}
inline
int pthread_setspecific(pthread_key_t key, const void *value) {
inline int pthread_setspecific(pthread_key_t key, const void* value) {
if (!TlsSetValue(key, const_cast<void*>(value))) {
return ENOMEM;
}
return 0;
}
inline
void* pthread_getspecific(pthread_key_t key) {
inline void* pthread_getspecific(pthread_key_t key) {
void* result = TlsGetValue(key);
if (!result) {
if (GetLastError() != ERROR_SUCCESS) {

@ -24,15 +24,15 @@
namespace rocksdb {
WinLogger::WinLogger(uint64_t (*gettid)(), Env* env, FILE * file, const InfoLogLevel log_level)
WinLogger::WinLogger(uint64_t (*gettid)(), Env* env, FILE* file,
const InfoLogLevel log_level)
: Logger(log_level),
gettid_(gettid),
log_size_(0),
last_flush_micros_(0),
env_(env),
flush_pending_(false),
file_(file) {
}
file_(file) {}
void WinLogger::DebugWriter(const char* str, int len) {
size_t sz = fwrite(str, 1, len, file_);
@ -41,13 +41,9 @@ void WinLogger::DebugWriter(const char* str, int len) {
}
}
WinLogger::~WinLogger() {
close();
}
WinLogger::~WinLogger() { close(); }
void WinLogger::close() {
fclose(file_);
}
void WinLogger::close() { fclose(file_); }
void WinLogger::Flush() {
if (flush_pending_) {
@ -59,7 +55,6 @@ void WinLogger::Flush() {
}
void WinLogger::Logv(const char* format, va_list ap) {
IOSTATS_TIMER_GUARD(logger_nanos);
const uint64_t thread_id = (*gettid_)();
@ -88,11 +83,9 @@ void WinLogger::Logv(const char* format, va_list ap) {
const time_t seconds = now_tv.tv_sec;
struct tm t;
localtime_s(&t, &seconds);
p += snprintf(p, limit - p, "%04d/%02d/%02d-%02d:%02d:%02d.%06d %llx ", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
t.tm_hour,
t.tm_min,
t.tm_sec,
static_cast<int>(now_tv.tv_usec),
p += snprintf(p, limit - p, "%04d/%02d/%02d-%02d:%02d:%02d.%06d %llx ",
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour,
t.tm_min, t.tm_sec, static_cast<int>(now_tv.tv_usec),
static_cast<long long unsigned int>(thread_id));
// Print the message
@ -100,7 +93,7 @@ void WinLogger::Logv(const char* format, va_list ap) {
va_list backup_ap;
va_copy(backup_ap, ap);
int done = vsnprintf(p, limit - p, format, backup_ap);
if (done > 0){
if (done > 0) {
p += done;
} else {
continue;
@ -110,8 +103,7 @@ void WinLogger::Logv(const char* format, va_list ap) {
// Truncate to available space if necessary
if (p >= limit) {
if (iter == 0)
{
if (iter == 0) {
continue; // Try again with larger buffer
} else {
p = limit - 1;
@ -137,8 +129,8 @@ void WinLogger::Logv(const char* format, va_list ap) {
log_size_ += write_size;
}
uint64_t now_micros = static_cast<uint64_t>(now_tv.tv_sec) * 1000000 +
now_tv.tv_usec;
uint64_t now_micros =
static_cast<uint64_t>(now_tv.tv_sec) * 1000000 + now_tv.tv_usec;
if (now_micros - last_flush_micros_ >= flush_every_seconds_ * 1000000) {
flush_pending_ = false;
fflush(file_);
@ -148,9 +140,6 @@ void WinLogger::Logv(const char* format, va_list ap) {
}
}
size_t WinLogger::GetLogFileSize() const {
return log_size_;
}
size_t WinLogger::GetLogFileSize() const { return log_size_; }
} // namespace rocksdb

@ -23,8 +23,8 @@ class Env;
const int kDebugLogChunkSize = 128 * 1024;
class WinLogger : public rocksdb::Logger {
public:
WinLogger(uint64_t(*gettid)(), Env* env, FILE * file,
public:
WinLogger(uint64_t (*gettid)(), Env* env, FILE* file,
const InfoLogLevel log_level = InfoLogLevel::ERROR_LEVEL);
virtual ~WinLogger();
@ -43,10 +43,9 @@ public:
void DebugWriter(const char* str, int len);
private:
private:
FILE* file_;
uint64_t(*gettid_)(); // Return the thread id for the current thread
uint64_t (*gettid_)(); // Return the thread id for the current thread
std::atomic_size_t log_size_;
std::atomic_uint_fast64_t last_flush_micros_;
Env* env_;

@ -374,8 +374,10 @@ Slice CompressBlock(const Slice& raw,
// kBlockBasedTableMagicNumber was picked by running
// echo rocksdb.table.block_based | sha1sum
// and taking the leading 64 bits.
// Please note that kBlockBasedTableMagicNumber may also be accessed by other .cc files
// for that reason we declare it extern in the header but to get the space allocated
// Please note that kBlockBasedTableMagicNumber may also be accessed by other
// .cc files
// for that reason we declare it extern in the header but to get the space
// allocated
// it must be not extern in one place.
const uint64_t kBlockBasedTableMagicNumber = 0x88e241b785f4cff7ull;
// We also support reading and writing legacy block based table format (for

@ -123,7 +123,8 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const {
table_options_.block_cache_compressed.get());
ret.append(buffer);
if (table_options_.block_cache_compressed) {
snprintf(buffer, kBufferSize, " block_cache_compressed_size: %" ROCKSDB_PRIszt "\n",
snprintf(buffer, kBufferSize,
" block_cache_compressed_size: %" ROCKSDB_PRIszt "\n",
table_options_.block_cache_compressed->GetCapacity());
ret.append(buffer);
}

@ -146,14 +146,13 @@ TEST_F(CuckooBuilderTest, WriteSuccessNoCollisionFullKey) {
uint32_t num_hash_fun = 4;
std::vector<std::string> user_keys = {"key01", "key02", "key03", "key04"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1, 2, 3}},
{user_keys[1], {1, 2, 3, 4}},
{user_keys[2], {2, 3, 4, 5}},
{user_keys[3], {3, 4, 5, 6}}
};
{user_keys[3], {3, 4, 5, 6}}};
hash_map = std::move(hm);
std::vector<uint64_t> expected_locations = {0, 1, 2, 3};
@ -190,9 +189,9 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionFullKey) {
uint32_t num_hash_fun = 4;
std::vector<std::string> user_keys = {"key01", "key02", "key03", "key04"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1, 2, 3}},
{user_keys[1], {0, 1, 2, 3}},
{user_keys[2], {0, 1, 2, 3}},
@ -234,9 +233,9 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionAndCuckooBlock) {
uint32_t num_hash_fun = 4;
std::vector<std::string> user_keys = {"key01", "key02", "key03", "key04"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1, 2, 3}},
{user_keys[1], {0, 1, 2, 3}},
{user_keys[2], {0, 1, 2, 3}},
@ -284,9 +283,9 @@ TEST_F(CuckooBuilderTest, WithCollisionPathFullKey) {
std::vector<std::string> user_keys = {"key01", "key02", "key03",
"key04", "key05"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04", "v05"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1}},
{user_keys[1], {1, 2}},
{user_keys[2], {2, 3}},
@ -330,9 +329,9 @@ TEST_F(CuckooBuilderTest, WithCollisionPathFullKeyAndCuckooBlock) {
std::vector<std::string> user_keys = {"key01", "key02", "key03",
"key04", "key05"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04", "v05"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1}},
{user_keys[1], {1, 2}},
{user_keys[2], {3, 4}},
@ -375,14 +374,13 @@ TEST_F(CuckooBuilderTest, WriteSuccessNoCollisionUserKey) {
uint32_t num_hash_fun = 4;
std::vector<std::string> user_keys = {"key01", "key02", "key03", "key04"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1, 2, 3}},
{user_keys[1], {1, 2, 3, 4}},
{user_keys[2], {2, 3, 4, 5}},
{user_keys[3], {3, 4, 5, 6}}
};
{user_keys[3], {3, 4, 5, 6}}};
hash_map = std::move(hm);
std::vector<uint64_t> expected_locations = {0, 1, 2, 3};
@ -415,9 +413,9 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionUserKey) {
uint32_t num_hash_fun = 4;
std::vector<std::string> user_keys = {"key01", "key02", "key03", "key04"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1, 2, 3}},
{user_keys[1], {0, 1, 2, 3}},
{user_keys[2], {0, 1, 2, 3}},
@ -456,9 +454,9 @@ TEST_F(CuckooBuilderTest, WithCollisionPathUserKey) {
std::vector<std::string> user_keys = {"key01", "key02", "key03",
"key04", "key05"};
std::vector<std::string> values = {"v01", "v02", "v03", "v04", "v05"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1}},
{user_keys[1], {1, 2}},
{user_keys[2], {2, 3}},
@ -500,9 +498,9 @@ TEST_F(CuckooBuilderTest, FailWhenCollisionPathTooLong) {
uint32_t num_hash_fun = 2;
std::vector<std::string> user_keys = {"key01", "key02", "key03",
"key04", "key05"};
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm =
{
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{user_keys[0], {0, 1}},
{user_keys[1], {1, 2}},
{user_keys[2], {2, 3}},
@ -527,8 +525,10 @@ TEST_F(CuckooBuilderTest, FailWhenCollisionPathTooLong) {
}
TEST_F(CuckooBuilderTest, FailWhenSameKeyInserted) {
// Need to have a temporary variable here as VS compiler does not currently support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = { { "repeatedkey", { 0, 1, 2, 3 } } };
// Need to have a temporary variable here as VS compiler does not currently
// support operator= with initializer_list as a parameter
std::unordered_map<std::string, std::vector<uint64_t>> hm = {
{"repeatedkey", {0, 1, 2, 3}}};
hash_map = std::move(hm);
uint32_t num_hash_fun = 4;
std::string user_key = "repeatedkey";

@ -18,9 +18,9 @@ static inline uint64_t CuckooHash(
const Slice& user_key, uint32_t hash_cnt, bool use_module_hash,
uint64_t table_size_, bool identity_as_first_hash,
uint64_t (*get_slice_hash)(const Slice&, uint32_t, uint64_t)) {
#if !defined NDEBUG || defined OS_WIN
// This part is used only in unit tests but we have to keep it for Windows build as we run test in both debug and release modes under Windows.
// This part is used only in unit tests but we have to keep it for Windows
// build as we run test in both debug and release modes under Windows.
if (get_slice_hash != nullptr) {
return get_slice_hash(user_key, hash_cnt, table_size_);
}

@ -192,9 +192,7 @@ struct BlockContents {
compression_type(_compression_type),
allocation(std::move(_data)) {}
BlockContents(BlockContents&& other) {
*this = std::move(other);
}
BlockContents(BlockContents&& other) { *this = std::move(other); }
BlockContents& operator=(BlockContents&& other) {
data = std::move(other.data);

@ -203,8 +203,8 @@ Slice PlainTableIndexBuilder::FillIndexes(
assert(sub_index_offset == sub_index_size_);
Log(InfoLogLevel::DEBUG_LEVEL, ioptions_.info_log,
"hash table size: %d, suffix_map length %" ROCKSDB_PRIszt,
index_size_, sub_index_size_);
"hash table size: %d, suffix_map length %" ROCKSDB_PRIszt, index_size_,
sub_index_size_);
return Slice(allocated, GetTotalSize());
}

@ -472,7 +472,7 @@ class BlobVal : public FbsonValue {
BlobVal();
private:
private:
// Disable as this class can only be allocated dynamically
BlobVal(const BlobVal&) = delete;
BlobVal& operator=(const BlobVal&) = delete;

@ -31,10 +31,9 @@
#endif
#if defined OS_WIN && !defined snprintf
# define snprintf _snprintf
#define snprintf _snprintf
#endif
#include <inttypes.h>
#include <iostream>

@ -137,8 +137,10 @@ int main(int argc, const char** argv) {
replThread.stop.store(true, std::memory_order_release);
if (replThread.no_read < dataPump.no_records) {
// no. read should be => than inserted.
fprintf(stderr, "No. of Record's written and read not same\nRead : %" ROCKSDB_PRIszt
" Written : %" ROCKSDB_PRIszt "\n", replThread.no_read, dataPump.no_records);
fprintf(stderr,
"No. of Record's written and read not same\nRead : %" ROCKSDB_PRIszt
" Written : %" ROCKSDB_PRIszt "\n",
replThread.no_read, dataPump.no_records);
exit(1);
}
fprintf(stderr, "Successful!\n");

@ -770,7 +770,7 @@ class SharedState {
std::vector<std::vector<uint32_t>> values_;
// Has to make it owned by a smart ptr as port::Mutex is not copyable
// and storing it in the container may require copying depending on the impl.
std::vector<std::vector<std::unique_ptr<port::Mutex>>> key_locks_;
std::vector<std::vector<std::unique_ptr<port::Mutex> > > key_locks_;
};
const uint32_t SharedState::SENTINEL = 0xffffffff;
@ -937,36 +937,25 @@ class StressTest {
return true;
}
std::unordered_map<std::string, std::vector<std::string>> options_tbl = {
std::unordered_map<std::string, std::vector<std::string> > options_tbl = {
{"write_buffer_size",
{
ToString(FLAGS_write_buffer_size),
{ToString(FLAGS_write_buffer_size),
ToString(FLAGS_write_buffer_size * 2),
ToString(FLAGS_write_buffer_size * 4)
}
},
ToString(FLAGS_write_buffer_size * 4)}},
{"max_write_buffer_number",
{
ToString(FLAGS_max_write_buffer_number),
{ToString(FLAGS_max_write_buffer_number),
ToString(FLAGS_max_write_buffer_number * 2),
ToString(FLAGS_max_write_buffer_number * 4)
}
},
ToString(FLAGS_max_write_buffer_number * 4)}},
{"arena_block_size",
{
ToString(Options().arena_block_size),
ToString(FLAGS_write_buffer_size / 4),
ToString(FLAGS_write_buffer_size / 8),
}
},
}},
{"memtable_prefix_bloom_bits", {"0", "8", "10"}},
{"memtable_prefix_bloom_probes", {"4", "5", "6"}},
{"memtable_prefix_bloom_huge_page_tlb_size",
{
"0",
ToString(2 * 1024 * 1024)
}
},
{"0", ToString(2 * 1024 * 1024)}},
{"max_successive_merges", {"0", "2", "4"}},
{"filter_deletes", {"0", "1"}},
{"inplace_update_num_locks", {"100", "200", "300"}},
@ -979,71 +968,57 @@ class StressTest {
ToString(FLAGS_level0_file_num_compaction_trigger),
ToString(FLAGS_level0_file_num_compaction_trigger + 2),
ToString(FLAGS_level0_file_num_compaction_trigger + 4),
}
},
}},
{"level0_slowdown_writes_trigger",
{
ToString(FLAGS_level0_slowdown_writes_trigger),
ToString(FLAGS_level0_slowdown_writes_trigger + 2),
ToString(FLAGS_level0_slowdown_writes_trigger + 4),
}
},
}},
{"level0_stop_writes_trigger",
{
ToString(FLAGS_level0_stop_writes_trigger),
ToString(FLAGS_level0_stop_writes_trigger + 2),
ToString(FLAGS_level0_stop_writes_trigger + 4),
}
},
}},
{"max_grandparent_overlap_factor",
{
ToString(Options().max_grandparent_overlap_factor - 5),
ToString(Options().max_grandparent_overlap_factor),
ToString(Options().max_grandparent_overlap_factor + 5),
}
},
}},
{"expanded_compaction_factor",
{
ToString(Options().expanded_compaction_factor - 5),
ToString(Options().expanded_compaction_factor),
ToString(Options().expanded_compaction_factor + 5),
}
},
}},
{"source_compaction_factor",
{
ToString(Options().source_compaction_factor),
ToString(Options().source_compaction_factor * 2),
ToString(Options().source_compaction_factor * 4),
}
},
}},
{"target_file_size_base",
{
ToString(FLAGS_target_file_size_base),
ToString(FLAGS_target_file_size_base * 2),
ToString(FLAGS_target_file_size_base * 4),
}
},
}},
{"target_file_size_multiplier",
{
ToString(FLAGS_target_file_size_multiplier),
"1",
"2",
}
},
ToString(FLAGS_target_file_size_multiplier), "1", "2",
}},
{"max_bytes_for_level_base",
{
ToString(FLAGS_max_bytes_for_level_base / 2),
ToString(FLAGS_max_bytes_for_level_base),
ToString(FLAGS_max_bytes_for_level_base * 2),
}
},
}},
{"max_bytes_for_level_multiplier",
{
ToString(FLAGS_max_bytes_for_level_multiplier),
"1",
"2",
}
},
ToString(FLAGS_max_bytes_for_level_multiplier), "1", "2",
}},
{"max_mem_compaction_level", {"0", "1", "2"}},
{"max_sequential_skip_in_iterations", {"4", "8", "12"}},
};

@ -205,7 +205,8 @@ TEST_F(AutoRollLoggerTest, CompositeRollByTimeAndSizeLogger) {
}
#ifndef OS_WIN
//TODO: does not build for Windows because of PosixLogger use below. Need to port
// TODO: does not build for Windows because of PosixLogger use below. Need to
// port
TEST_F(AutoRollLoggerTest, CreateLoggerFromOptions) {
DBOptions options;
shared_ptr<Logger> logger;

@ -242,8 +242,7 @@ class autovector {
void push_back(const T& item) {
if (num_stack_items_ < kSize) {
values_[num_stack_items_++] = item;
}
else {
} else {
vect_.push_back(item);
}
}

@ -1827,7 +1827,8 @@ class PosixEnv : public Env {
#if defined(_GNU_SOURCE) && defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 12)
char name_buf[16];
snprintf(name_buf, sizeof name_buf, "rocksdb:bg%" ROCKSDB_PRIszt, bgthreads_.size());
snprintf(name_buf, sizeof name_buf, "rocksdb:bg%" ROCKSDB_PRIszt,
bgthreads_.size());
name_buf[sizeof name_buf - 1] = '\0';
pthread_setname_np(t, name_buf);
#endif

@ -7,11 +7,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include <sys/types.h>
#ifndef OS_WIN
# include <sys/ioctl.h>
#include <sys/ioctl.h>
#endif
#include <sys/types.h>
#include <iostream>
#include <unordered_set>
@ -860,7 +859,7 @@ class TestLogger : public Logger {
int n = vsnprintf(new_format, sizeof(new_format) - 1, format, backup_ap);
// 48 bytes for extra information + bytes allocated
// When we have n == -1 there is not a terminating zero expected
// When we have n == -1 there is not a terminating zero expected
#ifdef OS_WIN
if (n < 0) {
char_0_count++;

@ -40,13 +40,9 @@ struct CuckooStep {
CuckooStep() : bucket_id_(-1), prev_step_id_(kNullStep), depth_(1) {}
// MSVC does not support = default yet
CuckooStep(CuckooStep&& o)
{
*this = std::move(o);
}
CuckooStep(CuckooStep&& o) { *this = std::move(o); }
CuckooStep& operator=(CuckooStep&& rhs)
{
CuckooStep& operator=(CuckooStep&& rhs) {
bucket_id_ = std::move(rhs.bucket_id_);
prev_step_id_ = std::move(rhs.prev_step_id_);
depth_ = std::move(rhs.depth_);
@ -411,8 +407,8 @@ bool HashCuckooRep::QuickInsert(const char* internal_key, const Slice& user_key,
}
if (cuckoo_bucket_id != -1) {
cuckoo_array_[cuckoo_bucket_id]
.store(const_cast<char*>(internal_key), std::memory_order_release);
cuckoo_array_[cuckoo_bucket_id].store(const_cast<char*>(internal_key),
std::memory_order_release);
return true;
}

@ -594,8 +594,8 @@ void HashLinkListRep::Insert(KeyHandle handle) {
if (bucket_entries_logging_threshold_ > 0 &&
header->GetNumEntries() ==
static_cast<uint32_t>(bucket_entries_logging_threshold_)) {
Info(logger_,
"HashLinkedList bucket %" ROCKSDB_PRIszt " has more than %d "
Info(logger_, "HashLinkedList bucket %" ROCKSDB_PRIszt
" has more than %d "
"entries. Key to insert: %s",
GetHash(transformed), header->GetNumEntries(),
GetLengthPrefixedSlice(x->key).ToString(true).c_str());

@ -54,9 +54,7 @@ class HistogramBucketMapper {
class HistogramImpl {
public:
HistogramImpl() {
memset(buckets_, 0, sizeof(buckets_));
}
HistogramImpl() { memset(buckets_, 0, sizeof(buckets_)); }
virtual void Clear();
virtual bool Empty();
virtual void Add(uint64_t value);

@ -590,7 +590,8 @@ void ManifestDumpCommand::DoCommand() {
// containing the db for files of the form MANIFEST_[0-9]+
auto CloseDir = [](DIR* p) { closedir(p); };
std::unique_ptr<DIR, decltype(CloseDir)> d(opendir(db_path_.c_str()), CloseDir);
std::unique_ptr<DIR, decltype(CloseDir)> d(opendir(db_path_.c_str()),
CloseDir);
if (d == nullptr) {
exec_state_ =

@ -357,12 +357,8 @@ private:
* Otherwise an exception is thrown.
*/
bool StringToBool(string val) {
std::transform(val.begin(), val.end(), val.begin(),
[](char ch) -> char
{
return ::tolower(ch);
});
[](char ch) -> char { return ::tolower(ch); });
if (val == "true") {
return true;

@ -63,10 +63,12 @@ uint64_t MutableCFOptions::ExpandedCompactionByteSizeLimit(int level) const {
void MutableCFOptions::Dump(Logger* log) const {
// Memtable related options
Log(log, " write_buffer_size: %" ROCKSDB_PRIszt, write_buffer_size);
Log(log, " write_buffer_size: %" ROCKSDB_PRIszt,
write_buffer_size);
Log(log, " max_write_buffer_number: %d",
max_write_buffer_number);
Log(log, " arena_block_size: %" ROCKSDB_PRIszt, arena_block_size);
Log(log, " arena_block_size: %" ROCKSDB_PRIszt,
arena_block_size);
Log(log, " memtable_prefix_bloom_bits: %" PRIu32,
memtable_prefix_bloom_bits);
Log(log, " memtable_prefix_bloom_probes: %" PRIu32,

@ -307,11 +307,14 @@ void DBOptions::Dump(Logger* log) const {
Warn(log, " Options.max_total_wal_size: %" PRIu64, max_total_wal_size);
Warn(log, " Options.disableDataSync: %d", disableDataSync);
Warn(log, " Options.use_fsync: %d", use_fsync);
Warn(log, " Options.max_log_file_size: %" ROCKSDB_PRIszt, max_log_file_size);
Warn(log, "Options.max_manifest_file_size: %lu",
(unsigned long)max_manifest_file_size);
Warn(log, " Options.log_file_time_to_roll: %" ROCKSDB_PRIszt, log_file_time_to_roll);
Warn(log, " Options.keep_log_file_num: %" ROCKSDB_PRIszt, keep_log_file_num);
Warn(log, " Options.max_log_file_size: %" ROCKSDB_PRIszt,
max_log_file_size);
Warn(log, "Options.max_manifest_file_size: %" PRIu64,
max_manifest_file_size);
Warn(log, " Options.log_file_time_to_roll: %" ROCKSDB_PRIszt,
log_file_time_to_roll);
Warn(log, " Options.keep_log_file_num: %" ROCKSDB_PRIszt,
keep_log_file_num);
Warn(log, " Options.allow_os_buffer: %d", allow_os_buffer);
Warn(log, " Options.allow_mmap_reads: %d", allow_mmap_reads);
Warn(log, " Options.allow_mmap_writes: %d", allow_mmap_writes);
@ -333,7 +336,8 @@ void DBOptions::Dump(Logger* log) const {
WAL_ttl_seconds);
Warn(log, " Options.WAL_size_limit_MB: %" PRIu64,
WAL_size_limit_MB);
Warn(log, " Options.manifest_preallocation_size: %" ROCKSDB_PRIszt,
Warn(log,
" Options.manifest_preallocation_size: %" ROCKSDB_PRIszt,
manifest_preallocation_size);
Warn(log, " Options.allow_os_buffer: %d",
allow_os_buffer);
@ -347,7 +351,9 @@ void DBOptions::Dump(Logger* log) const {
stats_dump_period_sec);
Warn(log, " Options.advise_random_on_open: %d",
advise_random_on_open);
Warn(log, " Options.db_write_buffer_size: %" ROCKSDB_PRIszt "d",
Warn(log,
" Options.db_write_buffer_size: %" ROCKSDB_PRIszt
"d",
db_write_buffer_size);
Warn(log, " Options.access_hint_on_compaction_start: %s",
access_hints[access_hint_on_compaction_start]);
@ -384,7 +390,8 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
Warn(log, " Options.table_factory: %s", table_factory->Name());
Warn(log, " table_factory options: %s",
table_factory->GetPrintableTableOptions().c_str());
Warn(log, " Options.write_buffer_size: %" ROCKSDB_PRIszt, write_buffer_size);
Warn(log, " Options.write_buffer_size: %" ROCKSDB_PRIszt,
write_buffer_size);
Warn(log, " Options.max_write_buffer_number: %d", max_write_buffer_number);
if (!compression_per_level.empty()) {
for (unsigned int i = 0; i < compression_per_level.size(); i++) {
@ -430,8 +437,9 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
max_bytes_for_level_multiplier);
for (size_t i = 0; i < max_bytes_for_level_multiplier_additional.size();
i++) {
Warn(log, "Options.max_bytes_for_level_multiplier_addtl[%" ROCKSDB_PRIszt "]: %d", i,
max_bytes_for_level_multiplier_additional[i]);
Warn(log, "Options.max_bytes_for_level_multiplier_addtl[%" ROCKSDB_PRIszt
"]: %d",
i, max_bytes_for_level_multiplier_additional[i]);
}
Warn(log, " Options.max_sequential_skip_in_iterations: %" PRIu64,
max_sequential_skip_in_iterations);
@ -442,7 +450,8 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
Warn(log, " Options.max_grandparent_overlap_factor: %d",
max_grandparent_overlap_factor);
Warn(log, " Options.arena_block_size: %" ROCKSDB_PRIszt,
Warn(log,
" Options.arena_block_size: %" ROCKSDB_PRIszt,
arena_block_size);
Warn(log, " Options.soft_rate_limit: %.2f",
soft_rate_limit);
@ -483,7 +492,8 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
collector_names.c_str());
Warn(log, " Options.inplace_update_support: %d",
inplace_update_support);
Warn(log, " Options.inplace_update_num_locks: %" ROCKSDB_PRIszt,
Warn(log,
" Options.inplace_update_num_locks: %" ROCKSDB_PRIszt,
inplace_update_num_locks);
Warn(log, " Options.min_partial_merge_operands: %u",
min_partial_merge_operands);
@ -493,12 +503,14 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
Warn(log, " Options.memtable_prefix_bloom_probes: %d",
memtable_prefix_bloom_probes);
Warn(log, " Options.memtable_prefix_bloom_huge_page_tlb_size: %" ROCKSDB_PRIszt,
Warn(log,
" Options.memtable_prefix_bloom_huge_page_tlb_size: %" ROCKSDB_PRIszt,
memtable_prefix_bloom_huge_page_tlb_size);
Warn(log, " Options.bloom_locality: %d",
bloom_locality);
Warn(log, " Options.max_successive_merges: %" ROCKSDB_PRIszt,
Warn(log,
" Options.max_successive_merges: %" ROCKSDB_PRIszt,
max_successive_merges);
Warn(log, " Options.optimize_fllters_for_hits: %d",
optimize_filters_for_hits);

@ -277,8 +277,7 @@ Status GetMutableOptionsFromStrings(
namespace {
std::string trim(const std::string& str) {
if (str.empty())
return std::string();
if (str.empty()) return std::string();
size_t start = 0;
size_t end = str.size() - 1;
while (isspace(str[start]) != 0 && start <= end) {
@ -564,8 +563,7 @@ bool ParseDBOption(const std::string& name, const std::string& value,
} else {
return false;
}
}
catch (const std::exception& e) {
} catch (const std::exception& e) {
return false;
}
return true;
@ -680,7 +678,8 @@ Status GetPlainTableOptionsFromMap(
} else if (o.first == "full_scan_mode") {
new_table_options->full_scan_mode = ParseBoolean(o.first, o.second);
} else if (o.first == "store_index_in_file") {
new_table_options->store_index_in_file = ParseBoolean(o.first, o.second);
new_table_options->store_index_in_file =
ParseBoolean(o.first, o.second);
} else {
return Status::InvalidArgument("Unrecognized option: " + o.first);
}

@ -51,8 +51,8 @@ Options PrintAndGetOptions(size_t total_write_buffer_limit,
StderrLogger logger;
if (FLAGS_enable_print) {
printf(
"---- total_write_buffer_limit: %" ROCKSDB_PRIszt " "
printf("---- total_write_buffer_limit: %" ROCKSDB_PRIszt
" "
"read_amplification_threshold: %d write_amplification_threshold: %d "
"target_db_size %" PRIu64 " ----\n",
total_write_buffer_limit, read_amplification_threshold,
@ -337,14 +337,14 @@ TEST_F(OptionsTest, GetColumnFamilyOptionsFromStringTest) {
ASSERT_OK(GetColumnFamilyOptionsFromString(base_cf_opt,
"memtable_prefix_bloom_bits=14k;max_write_buffer_number=-15K",
&new_cf_opt));
ASSERT_EQ(new_cf_opt.memtable_prefix_bloom_bits, 14UL*kilo);
ASSERT_EQ(new_cf_opt.max_write_buffer_number, -15*kilo);
ASSERT_EQ(new_cf_opt.memtable_prefix_bloom_bits, 14UL * kilo);
ASSERT_EQ(new_cf_opt.max_write_buffer_number, -15 * kilo);
// Units (m)
ASSERT_OK(GetColumnFamilyOptionsFromString(base_cf_opt,
"max_write_buffer_number=16m;inplace_update_num_locks=17M",
&new_cf_opt));
ASSERT_EQ(new_cf_opt.max_write_buffer_number, 16*mega);
ASSERT_EQ(new_cf_opt.inplace_update_num_locks, 17*mega);
ASSERT_EQ(new_cf_opt.max_write_buffer_number, 16 * mega);
ASSERT_EQ(new_cf_opt.inplace_update_num_locks, 17 * mega);
// Units (g)
ASSERT_OK(GetColumnFamilyOptionsFromString(
base_cf_opt,
@ -352,8 +352,8 @@ TEST_F(OptionsTest, GetColumnFamilyOptionsFromStringTest) {
"arena_block_size=19G",
&new_cf_opt));
ASSERT_EQ(new_cf_opt.write_buffer_size, 18*giga);
ASSERT_EQ(new_cf_opt.arena_block_size, 19*giga);
ASSERT_EQ(new_cf_opt.write_buffer_size, 18 * giga);
ASSERT_EQ(new_cf_opt.arena_block_size, 19 * giga);
ASSERT_TRUE(new_cf_opt.prefix_extractor.get() != nullptr);
std::string prefix_name(new_cf_opt.prefix_extractor->Name());
ASSERT_EQ(prefix_name, "rocksdb.CappedPrefix.8");
@ -361,8 +361,8 @@ TEST_F(OptionsTest, GetColumnFamilyOptionsFromStringTest) {
// Units (t)
ASSERT_OK(GetColumnFamilyOptionsFromString(base_cf_opt,
"write_buffer_size=20t;arena_block_size=21T", &new_cf_opt));
ASSERT_EQ(new_cf_opt.write_buffer_size, 20*tera);
ASSERT_EQ(new_cf_opt.arena_block_size, 21*tera);
ASSERT_EQ(new_cf_opt.write_buffer_size, 20 * tera);
ASSERT_EQ(new_cf_opt.arena_block_size, 21 * tera);
// Nested block based table options
// Emtpy

@ -96,7 +96,7 @@ class NoopTransform : public SliceTransform {
// Do not want to include the whole /port/port.h here for one define
#ifdef OS_WIN
# define snprintf _snprintf
#define snprintf _snprintf
#endif
// Return a string that contains the copy of the referenced data.
@ -115,7 +115,6 @@ std::string Slice::ToString(bool hex) const {
}
}
const SliceTransform* NewFixedPrefixTransform(size_t prefix_len) {
return new FixedPrefixTransform(prefix_len);
}

@ -25,15 +25,19 @@ __thread ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::tls_ = nullptr;
// See http://www.codeproject.com/Articles/8113/Thread-Local-Storage-The-C-Way
// and http://www.nynaeve.net/?p=183
//
// really we do this to have clear conscience since using TLS with thread-pools is iffy
// although OK within a request. But otherwise, threads have no identity in its modern use.
// really we do this to have clear conscience since using TLS with thread-pools
// is iffy
// although OK within a request. But otherwise, threads have no identity in its
// modern use.
// This runs on windows only called from the System Loader
#ifdef OS_WIN
// Windows cleanup routine is invoked from a System Loader with a different
// signature so we can not directly hookup the original OnThreadExit which is private member
// so we make StaticMeta class share with the us the address of the function so we can invoke it.
// signature so we can not directly hookup the original OnThreadExit which is
// private member
// so we make StaticMeta class share with the us the address of the function so
// we can invoke it.
namespace wintlscleanup {
// This is set to OnThreadExit in StaticMeta singleton constructor
@ -46,7 +50,7 @@ void NTAPI WinOnThreadExit(PVOID module, DWORD reason, PVOID reserved) {
if (DLL_THREAD_DETACH == reason) {
if (thread_local_key != -1 && thread_local_inclass_routine != nullptr) {
void* tls = pthread_getspecific(thread_local_key);
if(tls != nullptr) {
if (tls != nullptr) {
thread_local_inclass_routine(tls);
}
}
@ -55,17 +59,17 @@ void NTAPI WinOnThreadExit(PVOID module, DWORD reason, PVOID reserved) {
} // wintlscleanup
# ifdef _WIN64
#ifdef _WIN64
# pragma comment(linker, "/include:_tls_used")
# pragma comment(linker, "/include:p_thread_callback_on_exit")
#pragma comment(linker, "/include:_tls_used")
#pragma comment(linker, "/include:p_thread_callback_on_exit")
#else // _WIN64
# pragma comment(linker, "/INCLUDE:__tls_used")
# pragma comment(linker, "/INCLUDE:_p_thread_callback_on_exit")
#pragma comment(linker, "/INCLUDE:__tls_used")
#pragma comment(linker, "/INCLUDE:_p_thread_callback_on_exit")
# endif // _WIN64
#endif // _WIN64
// extern "C" suppresses C++ name mangling so we know the symbol name for the
// linker /INCLUDE:symbol pragma above.
@ -81,7 +85,8 @@ extern "C" {
// When defining a const variable, it must have external linkage to be sure the
// linker doesn't discard it.
extern const PIMAGE_TLS_CALLBACK p_thread_callback_on_exit;
const PIMAGE_TLS_CALLBACK p_thread_callback_on_exit = wintlscleanup::WinOnThreadExit;
const PIMAGE_TLS_CALLBACK p_thread_callback_on_exit =
wintlscleanup::WinOnThreadExit;
// Reset the default section.
#pragma const_seg()
@ -136,7 +141,7 @@ ThreadLocalPtr::StaticMeta::StaticMeta() : next_instance_id_(0) {
head_.prev = &head_;
#ifdef OS_WIN
// Share with Windows its cleanup routine and the key
// Share with Windows its cleanup routine and the key
wintlscleanup::thread_local_inclass_routine = OnThreadExit;
wintlscleanup::thread_local_key = pthread_key_;
#endif
@ -160,8 +165,8 @@ void ThreadLocalPtr::StaticMeta::RemoveThreadData(
ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::GetThreadLocal() {
#if defined(OS_MACOSX) || defined(OS_WIN)
// Make this local variable name look like a member variable so that we
// can share all the code below
// Make this local variable name look like a member variable so that we
// can share all the code below
ThreadData* tls_ =
static_cast<ThreadData*>(pthread_getspecific(Instance()->pthread_key_));
#endif

@ -17,7 +17,6 @@
#include "util/autovector.h"
#include "port/port.h"
namespace rocksdb {
// Cleanup function that will be called for a stored thread local

@ -333,9 +333,7 @@ class BackupEngineImpl : public BackupEngine {
CopyWorkItem(const CopyWorkItem&) = delete;
CopyWorkItem& operator=(const CopyWorkItem&) = delete;
CopyWorkItem(CopyWorkItem&& o) {
*this = std::move(o);
}
CopyWorkItem(CopyWorkItem&& o) { *this = std::move(o); }
CopyWorkItem& operator=(CopyWorkItem&& o) {
src_path = std::move(o.src_path);
@ -390,12 +388,9 @@ class BackupEngineImpl : public BackupEngine {
return *this;
}
BackupAfterCopyWorkItem(std::future<CopyResult>&& _result,
bool _shared,
bool _needed_to_copy,
Env* _backup_env,
std::string _dst_path_tmp,
std::string _dst_path,
BackupAfterCopyWorkItem(std::future<CopyResult>&& _result, bool _shared,
bool _needed_to_copy, Env* _backup_env,
std::string _dst_path_tmp, std::string _dst_path,
std::string _dst_relative)
: result(std::move(_result)),
shared(_shared),
@ -412,8 +407,7 @@ class BackupEngineImpl : public BackupEngine {
RestoreAfterCopyWorkItem() {}
RestoreAfterCopyWorkItem(std::future<CopyResult>&& _result,
uint32_t _checksum_value)
: result(std::move(_result)),
checksum_value(_checksum_value) {}
: result(std::move(_result)), checksum_value(_checksum_value) {}
RestoreAfterCopyWorkItem(RestoreAfterCopyWorkItem&& o) {
*this = std::move(o);
}
@ -1561,7 +1555,8 @@ Status BackupEngineImpl::BackupMeta::StoreToFile(bool sync) {
len += snprintf(buf.get(), buf_size, "%" PRId64 "\n", timestamp_);
len += snprintf(buf.get() + len, buf_size - len, "%" PRIu64 "\n",
sequence_number_);
len += snprintf(buf.get() + len, buf_size - len, "%" ROCKSDB_PRIszt "\n", files_.size());
len += snprintf(buf.get() + len, buf_size - len, "%" ROCKSDB_PRIszt "\n",
files_.size());
for (const auto& file : files_) {
// use crc32 for now, switch to something else if needed
len += snprintf(buf.get() + len, buf_size - len, "%s crc32 %u\n",

@ -8,10 +8,10 @@
// found in the LICENSE file. See the AUTHORS file for names of contributors.
// Syncpoint prevents us building and running tests in release
#if !defined(NDEBUG) || !defined (OS_WIN)
#if !defined(NDEBUG) || !defined(OS_WIN)
#ifndef OS_WIN
# include <unistd.h>
#include <unistd.h>
#endif
#include <iostream>
#include <thread>
@ -351,7 +351,7 @@ TEST_F(DBTest, CheckpointCF) {
#endif
int main(int argc, char** argv) {
#if !defined(NDEBUG) || !defined (OS_WIN)
#if !defined(NDEBUG) || !defined(OS_WIN)
rocksdb::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();

@ -42,7 +42,6 @@ const double GeoDBImpl::MaxLatitude = 85.05112878;
const double GeoDBImpl::MinLongitude = -180;
const double GeoDBImpl::MaxLongitude = 180;
GeoDBImpl::GeoDBImpl(DB* db, const GeoDBOptions& options) :
GeoDB(db, options), db_(db), options_(options) {
}

@ -51,7 +51,8 @@ class UInt64AddOperator : public AssociativeMergeOperator {
} else if (logger != nullptr) {
// If value is corrupted, treat it as 0
Log(InfoLogLevel::ERROR_LEVEL, logger,
"uint64 value corruption, size: %" ROCKSDB_PRIszt " > %" ROCKSDB_PRIszt,
"uint64 value corruption, size: %" ROCKSDB_PRIszt
" > %" ROCKSDB_PRIszt,
value.size(), sizeof(uint64_t));
}

@ -87,7 +87,6 @@ void Variant::Init(const Variant& v, Data& d) {
}
Variant& Variant::operator=(const Variant& v) {
// Construct first a temp so exception from a string ctor
// does not change this object
Data tmp;
@ -104,7 +103,6 @@ Variant& Variant::operator=(const Variant& v) {
}
Variant& Variant::operator=(Variant&& rhs) {
Destroy(type_, data_);
if (rhs.type_ == kString) {
new (data_.s) std::string(std::move(*GetStringPtr(rhs.data_)));
@ -116,9 +114,7 @@ Variant& Variant::operator=(Variant&& rhs) {
return *this;
}
bool Variant::operator==(const Variant& rhs) const {
if (type_ != rhs.type_) {
return false;
}

@ -18,10 +18,7 @@ namespace {
typedef std::map<std::string, std::string> KVMap;
enum BatchOperation {
OP_PUT = 0,
OP_DELETE = 1
};
enum BatchOperation { OP_PUT = 0, OP_DELETE = 1 };
}
class SpecialTimeEnv : public EnvWrapper {

Loading…
Cancel
Save