summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cache/cache_test.cc38
-rw-r--r--cache/fast_lru_cache.h1
-rw-r--r--util/aligned_buffer.h43
-rw-r--r--util/autovector.h9
-rw-r--r--util/autovector_test.cc24
-rw-r--r--util/bloom_test.cc20
-rw-r--r--util/coding.cc1
-rw-r--r--util/coding.h32
-rw-r--r--util/coding_test.cc29
-rw-r--r--util/comparator.cc8
-rw-r--r--util/compression_context_cache.cc4
-rw-r--r--util/concurrent_task_limiter_impl.cc13
-rw-r--r--util/concurrent_task_limiter_impl.h2
-rw-r--r--util/crc32c.cc499
-rw-r--r--util/crc32c.h5
-rw-r--r--util/crc32c_test.cc93
-rw-r--r--util/defer.h3
-rw-r--r--util/defer_test.cc3
-rw-r--r--util/duplicate_detector.h3
-rw-r--r--util/dynamic_bloom.cc2
-rw-r--r--util/dynamic_bloom.h6
-rw-r--r--util/dynamic_bloom_test.cc2
-rw-r--r--util/filelock_test.cc53
-rw-r--r--util/filter_bench.cc8
-rw-r--r--util/hash_test.cc4
-rw-r--r--util/heap.h9
-rw-r--r--util/heap_test.cc40
-rw-r--r--util/kv_map.h2
-rw-r--r--util/murmurhash.h7
-rw-r--r--util/mutexlock.h16
-rw-r--r--util/random.cc1
-rw-r--r--util/random.h6
-rw-r--r--util/random_test.cc3
-rw-r--r--util/ribbon_test.cc7
-rw-r--r--util/slice.cc2
-rw-r--r--util/slice_test.cc3
-rw-r--r--util/status.cc2
-rw-r--r--util/string_util.cc2
-rw-r--r--util/thread_list_test.cc140
-rw-r--r--util/thread_local.cc50
-rw-r--r--util/thread_local.h5
-rw-r--r--util/thread_operation.h77
-rw-r--r--util/threadpool_imp.cc127
-rw-r--r--util/threadpool_imp.h36
-rw-r--r--util/timer.h13
-rw-r--r--util/timer_queue.h1
-rw-r--r--util/timer_queue_test.cc1
47 files changed, 619 insertions, 836 deletions
diff --git a/cache/cache_test.cc b/cache/cache_test.cc
index 75c28c2b8..75494f59a 100644
--- a/cache/cache_test.cc
+++ b/cache/cache_test.cc
@@ -202,29 +202,21 @@ class CacheTest : public testing::TestWithParam<std::string> {
cache->Erase(EncodeKey(key));
}
- int Lookup(int key) {
- return Lookup(cache_, key);
- }
+ int Lookup(int key) { return Lookup(cache_, key); }
void Insert(int key, int value, int charge = 1) {
Insert(cache_, key, value, charge);
}
- void Erase(int key) {
- Erase(cache_, key);
- }
+ void Erase(int key) { Erase(cache_, key); }
- int Lookup2(int key) {
- return Lookup(cache2_, key);
- }
+ int Lookup2(int key) { return Lookup(cache2_, key); }
void Insert2(int key, int value, int charge = 1) {
Insert(cache2_, key, value, charge);
}
- void Erase2(int key) {
- Erase(cache2_, key);
- }
+ void Erase2(int key) { Erase(cache2_, key); }
};
CacheTest* CacheTest::current_;
@@ -418,13 +410,13 @@ TEST_P(CacheTest, HitAndMiss) {
Insert(100, 101);
ASSERT_EQ(101, Lookup(100));
- ASSERT_EQ(-1, Lookup(200));
- ASSERT_EQ(-1, Lookup(300));
+ ASSERT_EQ(-1, Lookup(200));
+ ASSERT_EQ(-1, Lookup(300));
Insert(200, 201);
ASSERT_EQ(101, Lookup(100));
ASSERT_EQ(201, Lookup(200));
- ASSERT_EQ(-1, Lookup(300));
+ ASSERT_EQ(-1, Lookup(300));
Insert(100, 102);
if (GetParam() == kHyperClock) {
@@ -434,7 +426,7 @@ TEST_P(CacheTest, HitAndMiss) {
ASSERT_EQ(102, Lookup(100));
}
ASSERT_EQ(201, Lookup(200));
- ASSERT_EQ(-1, Lookup(300));
+ ASSERT_EQ(-1, Lookup(300));
ASSERT_EQ(1U, deleted_keys_.size());
ASSERT_EQ(100, deleted_keys_[0]);
@@ -463,14 +455,14 @@ TEST_P(CacheTest, Erase) {
Insert(100, 101);
Insert(200, 201);
Erase(100);
- ASSERT_EQ(-1, Lookup(100));
+ ASSERT_EQ(-1, Lookup(100));
ASSERT_EQ(201, Lookup(200));
ASSERT_EQ(1U, deleted_keys_.size());
ASSERT_EQ(100, deleted_keys_[0]);
ASSERT_EQ(101, deleted_values_[0]);
Erase(100);
- ASSERT_EQ(-1, Lookup(100));
+ ASSERT_EQ(-1, Lookup(100));
ASSERT_EQ(201, Lookup(200));
ASSERT_EQ(1U, deleted_keys_.size());
}
@@ -515,7 +507,7 @@ TEST_P(CacheTest, EvictionPolicy) {
Insert(200, 201);
// Frequently used entry must be kept around
for (int i = 0; i < 2 * kCacheSize; i++) {
- Insert(1000+i, 2000+i);
+ Insert(1000 + i, 2000 + i);
ASSERT_EQ(101, Lookup(100));
}
ASSERT_EQ(101, Lookup(100));
@@ -686,7 +678,7 @@ TEST_P(CacheTest, HeavyEntries) {
ASSERT_EQ(1000 + i, r);
}
}
- ASSERT_LE(cached_weight, kCacheSize + kCacheSize/10);
+ ASSERT_LE(cached_weight, kCacheSize + kCacheSize / 10);
}
TEST_P(CacheTest, NewId) {
@@ -704,7 +696,7 @@ class Value {
namespace {
void deleter(const Slice& /*key*/, void* value) {
- delete static_cast<Value *>(value);
+ delete static_cast<Value*>(value);
}
} // namespace
@@ -859,7 +851,7 @@ TEST_P(CacheTest, OverCapacity) {
// a LRUCache with n entries and one shard only
std::shared_ptr<Cache> cache = NewCache(n, 0, false);
- std::vector<Cache::Handle*> handles(n+1);
+ std::vector<Cache::Handle*> handles(n + 1);
// Insert n+1 entries, but not releasing.
for (int i = 0; i < static_cast<int>(n + 1); i++) {
@@ -919,7 +911,7 @@ void legacy_callback(void* value, size_t charge) {
legacy_callback_state.push_back(
{DecodeValue(value), static_cast<int>(charge)});
}
-};
+}; // namespace
TEST_P(CacheTest, ApplyToAllCacheEntriesTest) {
std::vector<std::pair<int, int>> inserted;
diff --git a/cache/fast_lru_cache.h b/cache/fast_lru_cache.h
index 3cd55ca86..7e3617de9 100644
--- a/cache/fast_lru_cache.h
+++ b/cache/fast_lru_cache.h
@@ -235,7 +235,6 @@ struct LRUHandle {
}
};
-
class LRUHandleTable {
public:
explicit LRUHandleTable(int hash_bits);
diff --git a/util/aligned_buffer.h b/util/aligned_buffer.h
index eb32c21b4..95ee5dfe8 100644
--- a/util/aligned_buffer.h
+++ b/util/aligned_buffer.h
@@ -9,6 +9,7 @@
#pragma once
#include <algorithm>
+
#include "port/port.h"
namespace ROCKSDB_NAMESPACE {
@@ -30,9 +31,7 @@ inline size_t TruncateToPageBoundary(size_t page_size, size_t s) {
// Example:
// Roundup(13, 5) => 15
// Roundup(201, 16) => 208
-inline size_t Roundup(size_t x, size_t y) {
- return ((x + y - 1) / y) * y;
-}
+inline size_t Roundup(size_t x, size_t y) { return ((x + y - 1) / y) * y; }
// Round down x to a multiple of y.
// Example:
@@ -61,13 +60,9 @@ class AlignedBuffer {
size_t cursize_;
char* bufstart_;
-public:
+ public:
AlignedBuffer()
- : alignment_(),
- capacity_(0),
- cursize_(0),
- bufstart_(nullptr) {
- }
+ : alignment_(), capacity_(0), cursize_(0), bufstart_(nullptr) {}
AlignedBuffer(AlignedBuffer&& o) noexcept { *this = std::move(o); }
@@ -92,27 +87,17 @@ public:
return n % alignment == 0;
}
- size_t Alignment() const {
- return alignment_;
- }
+ size_t Alignment() const { return alignment_; }
- size_t Capacity() const {
- return capacity_;
- }
+ size_t Capacity() const { return capacity_; }
- size_t CurrentSize() const {
- return cursize_;
- }
+ size_t CurrentSize() const { return cursize_; }
- const char* BufferStart() const {
- return bufstart_;
- }
+ const char* BufferStart() const { return bufstart_; }
char* BufferStart() { return bufstart_; }
- void Clear() {
- cursize_ = 0;
- }
+ void Clear() { cursize_ = 0; }
char* Release() {
cursize_ = 0;
@@ -202,7 +187,7 @@ public:
assert(offset < cursize_);
size_t to_read = 0;
- if(offset < cursize_) {
+ if (offset < cursize_) {
to_read = std::min(cursize_ - offset, read_size);
}
if (to_read > 0) {
@@ -242,12 +227,8 @@ public:
// the buffer is modified without using the write APIs or encapsulation
// offered by AlignedBuffer. It is up to the user to guard against such
// errors.
- char* Destination() {
- return bufstart_ + cursize_;
- }
+ char* Destination() { return bufstart_ + cursize_; }
- void Size(size_t cursize) {
- cursize_ = cursize;
- }
+ void Size(size_t cursize) { cursize_ = cursize; }
};
} // namespace ROCKSDB_NAMESPACE
diff --git a/util/autovector.h b/util/autovector.h
index 3242cb4bd..f758473b7 100644
--- a/util/autovector.h
+++ b/util/autovector.h
@@ -73,7 +73,7 @@ class autovector {
using iterator_category = std::random_access_iterator_tag;
iterator_impl(TAutoVector* vect, size_t index)
- : vect_(vect), index_(index) {};
+ : vect_(vect), index_(index){};
iterator_impl(const iterator_impl&) = default;
~iterator_impl() {}
iterator_impl& operator=(const iterator_impl&) = default;
@@ -139,9 +139,7 @@ class autovector {
return &(*vect_)[index_];
}
- reference operator[](difference_type len) const {
- return *(*this + len);
- }
+ reference operator[](difference_type len) const { return *(*this + len); }
// -- Logical Operators
bool operator==(const self_type& other) const {
@@ -303,7 +301,7 @@ class autovector {
reference emplace_back(Args&&... args) {
if (num_stack_items_ < kSize) {
return *(new ((void*)(&values_[num_stack_items_++]))
- value_type(std::forward<Args>(args)...));
+ value_type(std::forward<Args>(args)...));
} else {
return vect_.emplace_back(std::forward<Args>(args)...);
}
@@ -319,7 +317,6 @@ class autovector {
}
#endif
-
void pop_back() {
assert(!empty());
if (!vect_.empty()) {
diff --git a/util/autovector_test.cc b/util/autovector_test.cc
index 9dad69e73..8c7c39ce6 100644
--- a/util/autovector_test.cc
+++ b/util/autovector_test.cc
@@ -3,6 +3,8 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
+#include "util/autovector.h"
+
#include <atomic>
#include <iostream>
#include <string>
@@ -11,7 +13,6 @@
#include "rocksdb/env.h"
#include "test_util/testharness.h"
#include "test_util/testutil.h"
-#include "util/autovector.h"
#include "util/string_util.h"
using std::cout;
@@ -28,8 +29,8 @@ void AssertAutoVectorOnlyInStack(autovector<T, kSize>* vec, bool result) {
#ifndef ROCKSDB_LITE
ASSERT_EQ(vec->only_in_stack(), result);
#else
- (void) vec;
- (void) result;
+ (void)vec;
+ (void)result;
#endif // !ROCKSDB_LITE
}
} // namespace
@@ -109,8 +110,8 @@ TEST_F(AutoVectorTest, Resize) {
}
namespace {
-void AssertEqual(
- const autovector<size_t, kSize>& a, const autovector<size_t, kSize>& b) {
+void AssertEqual(const autovector<size_t, kSize>& a,
+ const autovector<size_t, kSize>& b) {
ASSERT_EQ(a.size(), b.size());
ASSERT_EQ(a.empty(), b.empty());
#ifndef ROCKSDB_LITE
@@ -124,7 +125,7 @@ void AssertEqual(
TEST_F(AutoVectorTest, CopyAndAssignment) {
// Test both heap-allocated and stack-allocated cases.
- for (auto size : { kSize / 2, kSize * 1000 }) {
+ for (auto size : {kSize / 2, kSize * 1000}) {
autovector<size_t, kSize> vec;
for (size_t i = 0; i < size; ++i) {
vec.push_back(i);
@@ -223,7 +224,7 @@ void BenchmarkVectorCreationAndInsertion(
int index = 0;
auto start_time = env->NowNanos();
auto ops_remaining = ops;
- while(ops_remaining--) {
+ while (ops_remaining--) {
TVector v;
for (size_t i = 0; i < item_size; ++i) {
v.push_back(items[index++]);
@@ -283,7 +284,7 @@ TEST_F(AutoVectorTest, PerfBench) {
// pre-generated unique keys
auto string_keys = GetTestKeys(kOps * 2 * kSize);
- for (auto insertions : { 0ul, 1ul, kSize / 2, kSize, 2 * kSize }) {
+ for (auto insertions : {0ul, 1ul, kSize / 2, kSize, 2 * kSize}) {
BenchmarkVectorCreationAndInsertion<std::vector<std::string>>(
"std::vector<std::string>", kOps, insertions, string_keys);
BenchmarkVectorCreationAndInsertion<autovector<std::string, kSize>>(
@@ -300,12 +301,11 @@ TEST_F(AutoVectorTest, PerfBench) {
for (size_t i = 0; i < kOps * 2 * kSize; ++i) {
int_keys[i] = i;
}
- for (auto insertions : { 0ul, 1ul, kSize / 2, kSize, 2 * kSize }) {
+ for (auto insertions : {0ul, 1ul, kSize / 2, kSize, 2 * kSize}) {
BenchmarkVectorCreationAndInsertion<std::vector<uint64_t>>(
"std::vector<uint64_t>", kOps, insertions, int_keys);
BenchmarkVectorCreationAndInsertion<autovector<uint64_t, kSize>>(
- "autovector<uint64_t>", kOps, insertions, int_keys
- );
+ "autovector<uint64_t>", kOps, insertions, int_keys);
cout << "-----------------------------------" << endl;
}
@@ -313,7 +313,7 @@ TEST_F(AutoVectorTest, PerfBench) {
cout << "=====================================================" << endl;
cout << "Sequence Access Test" << endl;
cout << "=====================================================" << endl;
- for (auto elem_size : { kSize / 2, kSize, 2 * kSize }) {
+ for (auto elem_size : {kSize / 2, kSize, 2 * kSize}) {
BenchmarkSequenceAccess<std::vector<std::string>>("std::vector", kOps,
elem_size);
BenchmarkSequenceAccess<autovector<std::string, kSize>>("autovector", kOps,
diff --git a/util/bloom_test.cc b/util/bloom_test.cc
index 4adf522e4..9d509ac3d 100644
--- a/util/bloom_test.cc
+++ b/util/bloom_test.cc
@@ -110,9 +110,7 @@ class FullBloomTest : public testing::TestWithParam<std::string> {
void ResetPolicy() { ResetPolicy(FLAGS_bits_per_key); }
- void Add(const Slice& s) {
- bits_builder_->AddKey(s);
- }
+ void Add(const Slice& s) { bits_builder_->AddKey(s); }
void OpenRaw(const Slice& s) {
bits_reader_.reset(policy_->GetFilterBitsReader(s));
@@ -124,9 +122,7 @@ class FullBloomTest : public testing::TestWithParam<std::string> {
filter_size_ = filter.size();
}
- size_t FilterSize() const {
- return filter_size_;
- }
+ size_t FilterSize() const { return filter_size_; }
Slice FilterData() { return Slice(buf_.get(), filter_size_); }
@@ -319,7 +315,7 @@ TEST_P(FullBloomTest, FullVaryingLengths) {
double rate = FalsePositiveRate();
if (kVerbose >= 1) {
fprintf(stderr, "False positives: %5.2f%% @ length = %6d ; bytes = %6d\n",
- rate*100.0, length, static_cast<int>(FilterSize()));
+ rate * 100.0, length, static_cast<int>(FilterSize()));
}
if (FLAGS_bits_per_key == 10) {
EXPECT_LE(rate, 0.02); // Must not be over 2%
@@ -331,8 +327,8 @@ TEST_P(FullBloomTest, FullVaryingLengths) {
}
}
if (kVerbose >= 1) {
- fprintf(stderr, "Filters: %d good, %d mediocre\n",
- good_filters, mediocre_filters);
+ fprintf(stderr, "Filters: %d good, %d mediocre\n", good_filters,
+ mediocre_filters);
}
EXPECT_LE(mediocre_filters, good_filters / 5);
}
@@ -817,7 +813,7 @@ struct RawFilterTester {
RawFilterTester() : metadata_ptr_(&*(data_.end() - 5)) {}
Slice ResetNoFill(uint32_t len_without_metadata, uint32_t num_lines,
- uint32_t num_probes) {
+ uint32_t num_probes) {
metadata_ptr_[0] = static_cast<char>(num_probes);
EncodeFixed32(metadata_ptr_ + 1, num_lines);
uint32_t len = len_without_metadata + /*metadata*/ 5;
@@ -826,13 +822,13 @@ struct RawFilterTester {
}
Slice Reset(uint32_t len_without_metadata, uint32_t num_lines,
- uint32_t num_probes, bool fill_ones) {
+ uint32_t num_probes, bool fill_ones) {
data_.fill(fill_ones ? 0xff : 0);
return ResetNoFill(len_without_metadata, num_lines, num_probes);
}
Slice ResetWeirdFill(uint32_t len_without_metadata, uint32_t num_lines,
- uint32_t num_probes) {
+ uint32_t num_probes) {
for (uint32_t i = 0; i < data_.size(); ++i) {
data_[i] = static_cast<char>(0x7b7b >> (i % 7));
}
diff --git a/util/coding.cc b/util/coding.cc
index a54324d28..3da8afaa2 100644
--- a/util/coding.cc
+++ b/util/coding.cc
@@ -10,6 +10,7 @@
#include "util/coding.h"
#include <algorithm>
+
#include "rocksdb/slice.h"
#include "rocksdb/slice_transform.h"
diff --git a/util/coding.h b/util/coding.h
index 72f63bc6b..3168fd2fd 100644
--- a/util/coding.h
+++ b/util/coding.h
@@ -25,7 +25,7 @@
// Some processors does not allow unaligned access to memory
#if defined(__sparc)
- #define PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED
+#define PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED
#endif
namespace ROCKSDB_NAMESPACE {
@@ -82,8 +82,10 @@ inline int64_t zigzagToI64(uint64_t n) {
// in *v and return a pointer just past the parsed value, or return
// nullptr on error. These routines only look at bytes in the range
// [p..limit-1]
-extern const char* GetVarint32Ptr(const char* p,const char* limit, uint32_t* v);
-extern const char* GetVarint64Ptr(const char* p,const char* limit, uint64_t* v);
+extern const char* GetVarint32Ptr(const char* p, const char* limit,
+ uint32_t* v);
+extern const char* GetVarint64Ptr(const char* p, const char* limit,
+ uint64_t* v);
inline const char* GetVarsignedint64Ptr(const char* p, const char* limit,
int64_t* value) {
uint64_t u = 0;
@@ -102,11 +104,9 @@ extern char* EncodeVarint32(char* dst, uint32_t value);
extern char* EncodeVarint64(char* dst, uint64_t value);
// Internal routine for use by fallback path of GetVarint32Ptr
-extern const char* GetVarint32PtrFallback(const char* p,
- const char* limit,
+extern const char* GetVarint32PtrFallback(const char* p, const char* limit,
uint32_t* value);
-inline const char* GetVarint32Ptr(const char* p,
- const char* limit,
+inline const char* GetVarint32Ptr(const char* p, const char* limit,
uint32_t* value) {
if (p < limit) {
uint32_t result = *(reinterpret_cast<const unsigned char*>(p));
@@ -133,7 +133,7 @@ inline void PutFixed16(std::string* dst, uint16_t value) {
inline void PutFixed32(std::string* dst, uint32_t value) {
if (port::kLittleEndian) {
dst->append(const_cast<const char*>(reinterpret_cast<char*>(&value)),
- sizeof(value));
+ sizeof(value));
} else {
char buf[sizeof(value)];
EncodeFixed32(buf, value);
@@ -144,7 +144,7 @@ inline void PutFixed32(std::string* dst, uint32_t value) {
inline void PutFixed64(std::string* dst, uint64_t value) {
if (port::kLittleEndian) {
dst->append(const_cast<const char*>(reinterpret_cast<char*>(&value)),
- sizeof(value));
+ sizeof(value));
} else {
char buf[sizeof(value)];
EncodeFixed64(buf, value);
@@ -350,7 +350,7 @@ inline Slice GetSliceUntil(Slice* slice, char delimiter) {
return ret;
}
-template<class T>
+template <class T>
#ifdef ROCKSDB_UBSAN_RUN
#if defined(__clang__)
__attribute__((__no_sanitize__("alignment")))
@@ -358,16 +358,17 @@ __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);
+ char* nonAlignedMemory = reinterpret_cast<char*>(memory);
memcpy(nonAlignedMemory, reinterpret_cast<const char*>(&value), sizeof(T));
#else
*memory = value;
#endif
}
-template<class T>
+template <class T>
#ifdef ROCKSDB_UBSAN_RUN
#if defined(__clang__)
__attribute__((__no_sanitize__("alignment")))
@@ -375,9 +376,10 @@ __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);
+ char* nonAlignedMemory = reinterpret_cast<char*>(value);
memcpy(nonAlignedMemory, reinterpret_cast<const char*>(memory), sizeof(T));
#else
*value = *memory;
diff --git a/util/coding_test.cc b/util/coding_test.cc
index 0f974277d..79dd7b82e 100644
--- a/util/coding_test.cc
+++ b/util/coding_test.cc
@@ -13,7 +13,7 @@
namespace ROCKSDB_NAMESPACE {
-class Coding { };
+class Coding {};
TEST(Coding, Fixed16) {
std::string s;
for (uint16_t v = 0; v < 0xFFFF; v++) {
@@ -56,15 +56,15 @@ TEST(Coding, Fixed64) {
uint64_t v = static_cast<uint64_t>(1) << power;
uint64_t actual = 0;
actual = DecodeFixed64(p);
- ASSERT_EQ(v-1, actual);
+ ASSERT_EQ(v - 1, actual);
p += sizeof(uint64_t);
actual = DecodeFixed64(p);
- ASSERT_EQ(v+0, actual);
+ ASSERT_EQ(v + 0, actual);
p += sizeof(uint64_t);
actual = DecodeFixed64(p);
- ASSERT_EQ(v+1, actual);
+ ASSERT_EQ(v + 1, actual);
p += sizeof(uint64_t);
}
}
@@ -125,8 +125,8 @@ TEST(Coding, Varint64) {
// Test values near powers of two
const uint64_t power = 1ull << k;
values.push_back(power);
- values.push_back(power-1);
- values.push_back(power+1);
+ values.push_back(power - 1);
+ values.push_back(power + 1);
};
std::string s;
@@ -146,14 +146,13 @@ TEST(Coding, Varint64) {
ASSERT_EQ(VarintLength(actual), p - start);
}
ASSERT_EQ(p, limit);
-
}
TEST(Coding, Varint32Overflow) {
uint32_t result;
std::string input("\x81\x82\x83\x84\x85\x11");
- ASSERT_TRUE(GetVarint32Ptr(input.data(), input.data() + input.size(), &result)
- == nullptr);
+ ASSERT_TRUE(GetVarint32Ptr(input.data(), input.data() + input.size(),
+ &result) == nullptr);
}
TEST(Coding, Varint32Truncation) {
@@ -164,16 +163,16 @@ TEST(Coding, Varint32Truncation) {
for (unsigned int len = 0; len + 1 < s.size(); len++) {
ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + len, &result) == nullptr);
}
- ASSERT_TRUE(
- GetVarint32Ptr(s.data(), s.data() + s.size(), &result) != nullptr);
+ ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + s.size(), &result) !=
+ nullptr);
ASSERT_EQ(large_value, result);
}
TEST(Coding, Varint64Overflow) {
uint64_t result;
std::string input("\x81\x82\x83\x84\x85\x81\x82\x83\x84\x85\x11");
- ASSERT_TRUE(GetVarint64Ptr(input.data(), input.data() + input.size(), &result)
- == nullptr);
+ ASSERT_TRUE(GetVarint64Ptr(input.data(), input.data() + input.size(),
+ &result) == nullptr);
}
TEST(Coding, Varint64Truncation) {
@@ -184,8 +183,8 @@ TEST(Coding, Varint64Truncation) {
for (unsigned int len = 0; len + 1 < s.size(); len++) {
ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + len, &result) == nullptr);
}
- ASSERT_TRUE(
- GetVarint64Ptr(s.data(), s.data() + s.size(), &result) != nullptr);
+ ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + s.size(), &result) !=
+ nullptr);
ASSERT_EQ(large_value, result);
}
diff --git a/util/comparator.cc b/util/comparator.cc
index 72584de43..f85ed69ee 100644
--- a/util/comparator.cc
+++ b/util/comparator.cc
@@ -29,7 +29,7 @@ namespace ROCKSDB_NAMESPACE {
namespace {
class BytewiseComparatorImpl : public Comparator {
public:
- BytewiseComparatorImpl() { }
+ BytewiseComparatorImpl() {}
static const char* kClassName() { return "leveldb.BytewiseComparator"; }
const char* Name() const override { return kClassName(); }
@@ -97,7 +97,7 @@ class BytewiseComparatorImpl : public Comparator {
const uint8_t byte = (*key)[i];
if (byte != static_cast<uint8_t>(0xff)) {
(*key)[i] = byte + 1;
- key->resize(i+1);
+ key->resize(i + 1);
return;
}
}
@@ -147,7 +147,7 @@ class BytewiseComparatorImpl : public Comparator {
class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl {
public:
- ReverseBytewiseComparatorImpl() { }
+ ReverseBytewiseComparatorImpl() {}
static const char* kClassName() {
return "rocksdb.ReverseBytewiseComparator";
@@ -298,7 +298,7 @@ class ComparatorWithU64TsImpl : public Comparator {
TComparator cmp_without_ts_;
};
-}// namespace
+} // namespace
const Comparator* BytewiseComparator() {
STATIC_AVOID_DESTRUCTION(BytewiseComparatorImpl, bytewise);
diff --git a/util/compression_context_cache.cc b/util/compression_context_cache.cc
index f62ac0c9b..52c3fac72 100644
--- a/util/compression_context_cache.cc
+++ b/util/compression_context_cache.cc
@@ -9,11 +9,11 @@
#include "util/compression_context_cache.h"
+#include <atomic>
+
#include "util/compression.h"
#include "util/core_local.h"
-#include <atomic>
-
namespace ROCKSDB_NAMESPACE {
namespace compression_cache {
diff --git a/util/concurrent_task_limiter_impl.cc b/util/concurrent_task_limiter_impl.cc
index 2342677d8..a0fc7331f 100644
--- a/util/concurrent_task_limiter_impl.cc
+++ b/util/concurrent_task_limiter_impl.cc
@@ -8,6 +8,7 @@
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "util/concurrent_task_limiter_impl.h"
+
#include "rocksdb/concurrent_task_limiter.h"
namespace ROCKSDB_NAMESPACE {
@@ -16,17 +17,13 @@ ConcurrentTaskLimiterImpl::ConcurrentTaskLimiterImpl(
const std::string& name, int32_t max_outstanding_task)
: name_(name),
max_outstanding_tasks_{max_outstanding_task},
- outstanding_tasks_{0} {
-
-}
+ outstanding_tasks_{0} {}
ConcurrentTaskLimiterImpl::~ConcurrentTaskLimiterImpl() {
assert(outstanding_tasks_ == 0);
}
-const std::string& ConcurrentTaskLimiterImpl::GetName() const {
- return name_;
-}
+const std::string& ConcurrentTaskLimiterImpl::GetName() const { return name_; }
void ConcurrentTaskLimiterImpl::SetMaxOutstandingTask(int32_t limit) {
max_outstanding_tasks_.store(limit, std::memory_order_relaxed);
@@ -54,8 +51,8 @@ std::unique_ptr<TaskLimiterToken> ConcurrentTaskLimiterImpl::GetToken(
return nullptr;
}
-ConcurrentTaskLimiter* NewConcurrentTaskLimiter(
- const std::string& name, int32_t limit) {
+ConcurrentTaskLimiter* NewConcurrentTaskLimiter(const std::string& name,
+ int32_t limit) {
return new ConcurrentTaskLimiterImpl(name, limit);
}
diff --git a/util/concurrent_task_limiter_impl.h b/util/concurrent_task_limiter_impl.h
index d8c1e03cb..4952ae23a 100644
--- a/util/concurrent_task_limiter_impl.h
+++ b/util/concurrent_task_limiter_impl.h
@@ -11,8 +11,8 @@
#include <atomic>
#include <memory>
-#include "rocksdb/env.h"
#include "rocksdb/concurrent_task_limiter.h"
+#include "rocksdb/env.h"
namespace ROCKSDB_NAMESPACE {
diff --git a/util/crc32c.cc b/util/crc32c.cc
index 59acb8c72..9deaf7fc6 100644
--- a/util/crc32c.cc
+++ b/util/crc32c.cc
@@ -64,301 +64,209 @@ static int arch_ppc_crc32 = 0;
#endif
static const uint32_t table0_[256] = {
- 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4,
- 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb,
- 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
- 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24,
- 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b,
- 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
- 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54,
- 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b,
- 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
- 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35,
- 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5,
- 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
- 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45,
- 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a,
- 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
- 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595,
- 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48,
- 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
- 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687,
- 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198,
- 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
- 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38,
- 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8,
- 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
- 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096,
- 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789,
- 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
- 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46,
- 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9,
- 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
- 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36,
- 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829,
- 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
- 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93,
- 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043,
- 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
- 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3,
- 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc,
- 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
- 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033,
- 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652,
- 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
- 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d,
- 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982,
- 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
- 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622,
- 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2,
- 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
- 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530,
- 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f,
- 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
- 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0,
- 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f,
- 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
- 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90,
- 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f,
- 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
- 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1,
- 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321,
- 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
- 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81,
- 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e,
- 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
- 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351
-};
+ 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c,
+ 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
+ 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c,
+ 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
+ 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc,
+ 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
+ 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512,
+ 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
+ 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad,
+ 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
+ 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf,
+ 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
+ 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f,
+ 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
+ 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f,
+ 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
+ 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e,
+ 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
+ 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e,
+ 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
+ 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de,
+ 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
+ 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4,
+ 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
+ 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b,
+ 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
+ 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5,
+ 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
+ 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975,
+ 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
+ 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905,
+ 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
+ 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8,
+ 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
+ 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8,
+ 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
+ 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78,
+ 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
+ 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6,
+ 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
+ 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69,
+ 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
+ 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351};
static const uint32_t table1_[256] = {
- 0x00000000, 0x13a29877, 0x274530ee, 0x34e7a899,
- 0x4e8a61dc, 0x5d28f9ab, 0x69cf5132, 0x7a6dc945,
- 0x9d14c3b8, 0x8eb65bcf, 0xba51f356, 0xa9f36b21,
- 0xd39ea264, 0xc03c3a13, 0xf4db928a, 0xe7790afd,
- 0x3fc5f181, 0x2c6769f6, 0x1880c16f, 0x0b225918,
- 0x714f905d, 0x62ed082a, 0x560aa0b3, 0x45a838c4,
- 0xa2d13239, 0xb173aa4e, 0x859402d7, 0x96369aa0,
- 0xec5b53e5, 0xfff9cb92, 0xcb1e630b, 0xd8bcfb7c,
- 0x7f8be302, 0x6c297b75, 0x58ced3ec, 0x4b6c4b9b,
- 0x310182de, 0x22a31aa9, 0x1644b230, 0x05e62a47,
- 0xe29f20ba, 0xf13db8cd, 0xc5da1054, 0xd6788823,
- 0xac154166, 0xbfb7d911, 0x8b507188, 0x98f2e9ff,
- 0x404e1283, 0x53ec8af4, 0x670b226d, 0x74a9ba1a,
- 0x0ec4735f, 0x1d66eb28, 0x298143b1, 0x3a23dbc6,
- 0xdd5ad13b, 0xcef8494c, 0xfa1fe1d5, 0xe9bd79a2,
- 0x93d0b0e7, 0x80722890, 0xb4958009, 0xa737187e,
- 0xff17c604, 0xecb55e73, 0xd852f6ea, 0xcbf06e9d,
- 0xb19da7d8, 0xa23f3faf, 0x96d89736, 0x857a0f41,
- 0x620305bc, 0x71a19dcb, 0x45463552, 0x56e4ad25,
- 0x2c896460, 0x3f2bfc17, 0x0bcc548e, 0x186eccf9,
- 0xc0d23785, 0xd370aff2, 0xe797076b, 0xf4359f1c,
- 0x8e585659, 0x9dface2e, 0xa91d66b7, 0xbabffec0,
- 0x5dc6f43d, 0x4e646c4a, 0x7a83c4d3, 0x69215ca4,
- 0x134c95e1, 0x00ee0d96, 0x3409a50f, 0x27ab3d78,
- 0x809c2506, 0x933ebd71, 0xa7d915e8, 0xb47b8d9f,
- 0xce1644da, 0xddb4dcad, 0xe9537434, 0xfaf1ec43,
- 0x1d88e6be, 0x0e2a7ec9, 0x3acdd650, 0x296f4e27,
- 0x53028762, 0x40a01f15, 0x7447b78c, 0x67e52ffb,
- 0xbf59d487, 0xacfb4cf0, 0x981ce469, 0x8bbe7c1e,
- 0xf1d3b55b, 0xe2712d2c, 0xd69685b5, 0xc5341dc2,
- 0x224d173f, 0x31ef8f48, 0x050827d1, 0x16aabfa6,
- 0x6cc776e3, 0x7f65ee94, 0x4b82460d, 0x5820de7a,
- 0xfbc3faf9, 0xe861628e, 0xdc86ca17, 0xcf245260,
- 0xb5499b25, 0xa6eb0352, 0x920cabcb, 0x81ae33bc,
- 0x66d73941, 0x7575a136, 0x419209af, 0x523091d8,
- 0x285d589d, 0x3bffc0ea, 0x0f186873, 0x1cbaf004,
- 0xc4060b78, 0xd7a4930f, 0xe3433b96, 0xf0e1a3e1,
- 0x8a8c6aa4, 0x992ef2d3, 0xadc95a4a, 0xbe6bc23d,
- 0x5912c8c0, 0x4ab050b7, 0x7e57f82e, 0x6df56059,
- 0x1798a91c, 0x043a316b, 0x30dd99f2, 0x237f0185,
- 0x844819fb, 0x97ea818c, 0xa30d2915, 0xb0afb162,
- 0xcac27827, 0xd960e050, 0xed8748c9, 0xfe25d0be,
- 0x195cda43, 0x0afe4234, 0x3e19eaad, 0x2dbb72da,
- 0x57d6bb9f, 0x447423e8, 0x70938b71, 0x63311306,
- 0xbb8de87a, 0xa82f700d, 0x9cc8d894, 0x8f6a40e3,
- 0xf50789a6, 0xe6a511d1, 0xd242b948, 0xc1e0213f,
- 0x26992bc2, 0x353bb3b5, 0x01dc1b2c, 0x127e835b,
- 0x68134a1e, 0x7bb1d269, 0x4f567af0, 0x5cf4e287,
- 0x04d43cfd, 0x1776a48a, 0x23910c13, 0x30339464,
- 0x4a5e5d21, 0x59fcc556, 0x6d1b6dcf, 0x7eb9f5b8,
- 0x99c0ff45, 0x8a626732, 0xbe85cfab, 0xad2757dc,
- 0xd74a9e99, 0xc4e806ee, 0xf00fae77, 0xe3ad3600,
- 0x3b11cd7c, 0x28b3550b, 0x1c54fd92, 0x0ff665e5,
- 0x759baca0, 0x663934d7, 0x52de9c4e, 0x417c0439,
- 0xa6050ec4, 0xb5a796b3, 0x81403e2a, 0x92e2a65d,
- 0xe88f6f18, 0xfb2df76f, 0xcfca5ff6, 0xdc68c781,
- 0x7b5fdfff, 0x68fd4788, 0x5c1aef11, 0x4fb87766,
- 0x35d5be23, 0x26772654, 0x12908ecd, 0x013216ba,
- 0xe64b1c47, 0xf5e98430, 0xc10e2ca9, 0xd2acb4de,
- 0xa8c17d9b, 0xbb63e5ec, 0x8f844d75, 0x9c26d502,
- 0x449a2e7e, 0x5738b609, 0x63df1e90, 0x707d86e7,
- 0x0a104fa2, 0x19b2d7d5, 0x2d557f4c, 0x3ef7e73b,
- 0xd98eedc6, 0xca2c75b1, 0xfecbdd28, 0xed69455f,
- 0x97048c1a, 0x84a6146d, 0xb041bcf4, 0xa3e32483
-};
+ 0x00000000, 0x13a29877, 0x274530ee, 0x34e7a899, 0x4e8a61dc, 0x5d28f9ab,
+ 0x69cf5132, 0x7a6dc945, 0x9d14c3b8, 0x8eb65bcf, 0xba51f356, 0xa9f36b21,
+ 0xd39ea264, 0xc03c3a13, 0xf4db928a, 0xe7790afd, 0x3fc5f181, 0x2c6769f6,
+ 0x1880c16f, 0x0b225918, 0x714f905d, 0x62ed082a, 0x560aa0b3, 0x45a838c4,
+ 0xa2d13239, 0xb173aa4e, 0x859402d7, 0x96369aa0, 0xec5b53e5, 0xfff9cb92,
+ 0xcb1e630b, 0xd8bcfb7c, 0x7f8be302, 0x6c297b75, 0x58ced3ec, 0x4b6c4b9b,
+ 0x310182de, 0x22a31aa9, 0x1644b230, 0x05e62a47, 0xe29f20ba, 0xf13db8cd,
+ 0xc5da1054, 0xd6788823, 0xac154166, 0xbfb7d911, 0x8b507188, 0x98f2e9ff,
+ 0x404e1283, 0x53ec8af4, 0x670b226d, 0x74a9ba1a, 0x0ec4735f, 0x1d66eb28,
+ 0x298143b1, 0x3a23dbc6, 0xdd5ad13b, 0xcef8494c, 0xfa1fe1d5, 0xe9bd79a2,
+ 0x93d0b0e7, 0x80722890, 0xb4958009, 0xa737187e, 0xff17c604, 0xecb55e73,
+ 0xd852f6ea, 0xcbf06e9d, 0xb19da7d8, 0xa23f3faf, 0x96d89736, 0x857a0f41,
+ 0x620305bc, 0x71a19dcb, 0x45463552, 0x56e4ad25, 0x2c896460, 0x3f2bfc17,
+ 0x0bcc548e, 0x186eccf9, 0xc0d23785, 0xd370aff2, 0xe797076b, 0xf4359f1c,
+ 0x8e585659, 0x9dface2e, 0xa91d66b7, 0xbabffec0, 0x5dc6f43d, 0x4e646c4a,
+ 0x7a83c4d3, 0x69215ca4, 0x134c95e1, 0x00ee0d96, 0x3409a50f, 0x27ab3d78,
+ 0x809c2506, 0x933ebd71, 0xa7d915e8, 0xb47b8d9f, 0xce1644da, 0xddb4dcad,
+ 0xe9537434, 0xfaf1ec43, 0x1d88e6be, 0x0e2a7ec9, 0x3acdd650, 0x296f4e27,
+ 0x53028762, 0x40a01f15, 0x7447b78c, 0x67e52ffb, 0xbf59d487, 0xacfb4cf0,
+ 0x981ce469, 0x8bbe7c1e, 0xf1d3b55b, 0xe2712d2c, 0xd69685b5, 0xc5341dc2,
+ 0x224d173f, 0x31ef8f48, 0x050827d1, 0x16aabfa6, 0x6cc776e3, 0x7f65ee94,
+ 0x4b82460d, 0x5820de7a, 0xfbc3faf9, 0xe861628e, 0xdc86ca17, 0xcf245260,
+ 0xb5499b25, 0xa6eb0352, 0x920cabcb, 0x81ae33bc, 0x66d73941, 0x7575a136,
+ 0x419209af, 0x523091d8, 0x285d589d, 0x3bffc0ea, 0x0f186873, 0x1cbaf004,
+ 0xc4060b78, 0xd7a4930f, 0xe3433b96, 0xf0e1a3e1, 0x8a8c6aa4, 0x992ef2d3,
+ 0xadc95a4a, 0xbe6bc23d, 0x5912c8c0, 0x4ab050b7, 0x7e57f82e, 0x6df56059,
+ 0x1798a91c, 0x043a316b, 0x30dd99f2, 0x237f0185, 0x844819fb, 0x97ea818c,
+ 0xa30d2915, 0xb0afb162, 0xcac27827, 0xd960e050, 0xed8748c9, 0xfe25d0be,
+ 0x195cda43, 0x0afe4234, 0x3e19eaad, 0x2dbb72da, 0x57d6bb9f, 0x447423e8,
+ 0x70938b71, 0x63311306, 0xbb8de87a, 0xa82f700d, 0x9cc8d894, 0x8f6a40e3,
+ 0xf50789a6, 0xe6a511d1, 0xd242b948, 0xc1e0213f, 0x26992bc2, 0x353bb3b5,
+ 0x01dc1b2c, 0x127e835b, 0x68134a1e, 0x7bb1d269, 0x4f567af0, 0x5cf4e287,
+ 0x04d43cfd, 0x1776a48a, 0x23910c13, 0x30339464, 0x4a5e5d21, 0x59fcc556,
+ 0x6d1b6dcf, 0x7eb9f5b8, 0x99c0ff45, 0x8a626732, 0xbe85cfab, 0xad2757dc,
+ 0xd74a9e99, 0xc4e806ee, 0xf00fae77, 0xe3ad3600, 0x3b11cd7c, 0x28b3550b,
+ 0x1c54fd92, 0x0ff665e5, 0x759baca0, 0x663934d7, 0x52de9c4e, 0x417c0439,
+ 0xa6050ec4, 0xb5a796b3, 0x81403e2a, 0x92e2a65d, 0xe88f6f18, 0xfb2df76f,
+ 0xcfca5ff6, 0xdc68c781, 0x7b5fdfff, 0x68fd4788, 0x5c1aef11, 0x4fb87766,
+ 0x35d5be23, 0x26772654, 0x12908ecd, 0x013216ba, 0xe64b1c47, 0xf5e98430,
+ 0xc10e2ca9, 0xd2acb4de, 0xa8c17d9b, 0xbb63e5ec, 0x8f844d75, 0x9c26d502,
+ 0x449a2e7e, 0x5738b609, 0x63df1e90, 0x707d86e7, 0x0a104fa2, 0x19b2d7d5,
+ 0x2d557f4c, 0x3ef7e73b, 0xd98eedc6, 0xca2c75b1, 0xfecbdd28, 0xed69455f,
+ 0x97048c1a, 0x84a6146d, 0xb041bcf4, 0xa3e32483};
static const uint32_t table2_[256] = {
- 0x00000000, 0xa541927e, 0x4f6f520d, 0xea2ec073,
- 0x9edea41a, 0x3b9f3664, 0xd1b1f617, 0x74f06469,
- 0x38513ec5, 0x9d10acbb, 0x773e6cc8, 0xd27ffeb6,
- 0xa68f9adf, 0x03ce08a1, 0xe9e0c8d2, 0x4ca15aac,
- 0x70a27d8a, 0xd5e3eff4, 0x3fcd2f87, 0x9a8cbdf9,
- 0xee7cd990, 0x4b3d4bee, 0xa1138b9d, 0x045219e3,
- 0x48f3434f, 0xedb2d131, 0x079c1142, 0xa2dd833c,
- 0xd62de755, 0x736c752b, 0x9942b558, 0x3c032726,
- 0xe144fb14, 0x4405696a, 0xae2ba919, 0x0b6a3b67,
- 0x7f9a5f0e, 0xdadbcd70, 0x30f50d03, 0x95b49f7d,
- 0xd915c5d1, 0x7c5457af, 0x967a97dc, 0x333b05a2,
- 0x47cb61cb, 0xe28af3b5, 0x08a433c6, 0xade5a1b8,
- 0x91e6869e, 0x34a714e0, 0xde89d493, 0x7bc846ed,
- 0x0f382284, 0xaa79b0fa, 0x40577089, 0xe516e2f7,
- 0xa9b7b85b, 0x0cf62a25, 0xe6d8ea56, 0x43997828,
- 0x37691c41, 0x92288e3f, 0x78064e4c, 0xdd47dc32,
- 0xc76580d9, 0x622412a7, 0x880ad2d4, 0x2d4b40aa,
- 0x59bb24c3, 0xfcfab6bd, 0x16d476ce, 0xb395e4b0,
- 0xff34be1c, 0x5a752c62, 0xb05bec11, 0x151a7e6f,
- 0x61ea1a06, 0xc4ab8878, 0x2e85480b, 0x8bc4da75,
- 0xb7c7fd53, 0x12866f2d, 0xf8a8af5e, 0x5de93d20,
- 0x29195949, 0x8c58cb37, 0x66760b44, 0xc337993a,
- 0x8f96c396, 0x2ad751e8, 0xc0f9919b, 0x65b803e5,
- 0x1148678c, 0xb409f5f2, 0x5e273581, 0xfb66a7ff,
- 0x26217bcd, 0x8360e9b3, 0x694e29c0, 0xcc0fbbbe,
- 0xb8ffdfd7, 0x1dbe4da9, 0xf7908dda, 0x52d11fa4,
- 0x1e704508, 0xbb31d776, 0x511f1705, 0xf45e857b,
- 0x80aee112, 0x25ef736c, 0xcfc1b31f, 0x6a802161,
- 0x56830647, 0xf3c29439, 0x19ec544a, 0xbcadc634,
- 0xc85da25d, 0x6d1c3023, 0x8732f050, 0x2273622e,
- 0x6ed23882, 0xcb93aafc, 0x21bd6a8f, 0x84fcf8f1,
- 0xf00c9c98, 0x554d0ee6, 0xbf63ce95, 0x1a225ceb,
- 0x8b277743, 0x2e66e53d, 0xc448254e, 0x6109b730,
- 0x15f9d359, 0xb0b84127, 0x5a968154, 0xffd7132a,
- 0xb3764986, 0x1637dbf8, 0xfc191b8b, 0x595889f5,
- 0x2da8ed9c, 0x88e97fe2, 0x62c7bf91, 0xc7862def,
- 0xfb850ac9, 0x5ec498b7, 0xb4ea58c4, 0x11abcaba,
- 0x655baed3, 0xc01a3cad, 0x2a34fcde, 0x8f756ea0,
- 0xc3d4340c, 0x6695a672, 0x8cbb6601, 0x29faf47f,
- 0x5d0a9016, 0xf84b0268, 0x1265c21b, 0xb7245065,
- 0x6a638c57, 0xcf221e29, 0x250cde5a, 0x804d4c24,
- 0xf4bd284d, 0x51fcba33, 0xbbd27a40, 0x1e93e83e,
- 0x5232b292, 0xf77320ec, 0x1d5de09f, 0xb81c72e1,
- 0xccec1688, 0x69ad84f6, 0x83834485, 0x26c2d6fb,
- 0x1ac1f1dd, 0xbf8063a3, 0x55aea3d0, 0xf0ef31ae,
- 0x841f55c7, 0x215ec7b9, 0xcb7007ca, 0x6e3195b4,
- 0x2290cf18, 0x87d15d66, 0x6dff9d15, 0xc8be0f6b,
- 0xbc4e6b02, 0x190ff97c, 0xf321390f, 0x5660ab71,
- 0x4c42f79a, 0xe90365e4, 0x032da597, 0xa66c37e9,
- 0xd29c5380, 0x77ddc1fe, 0x9df3018d, 0x38b293f3,
- 0x7413c95f, 0xd1525b21, 0x3b7c9b52, 0x9e3d092c,
- 0xeacd6d45, 0x4f8cff3b, 0xa5a23f48, 0x00e3ad36,
- 0x3ce08a10, 0x99a1186e, 0x738fd81d, 0xd6ce4a63,
- 0xa23e2e0a, 0x077fbc74, 0xed517c07, 0x4810ee79,
- 0x04b1b4d5, 0xa1f026ab, 0x4bdee6d8, 0xee9f74a6,
- 0x9a6f10cf, 0x3f2e82b1, 0xd50042c2, 0x7041d0bc,
- 0xad060c8e, 0x08479ef0, 0xe2695e83, 0x4728ccfd,
- 0x33d8a894, 0x96993aea, 0x7cb7fa99, 0xd9f668e7,
- 0x9557324b, 0x3016a035, 0xda386046, 0x7f79f238,
- 0x0b899651, 0xaec8042f, 0x44e6c45c, 0xe1a75622,
- 0xdda47104, 0x78e5e37a, 0x92cb2309, 0x378ab177,
- 0x437ad51e, 0xe63b4760, 0x0c158713, 0xa954156d,
- 0xe5f54fc1, 0x40b4ddbf, 0xaa9a1dcc, 0x0fdb8fb2,
- 0x7b2bebdb, 0xde6a79a5, 0x3444b9d6, 0x91052ba8
-};
+ 0x00000000, 0xa541927e, 0x4f6f520d, 0xea2ec073, 0x9edea41a, 0x3b9f3664,
+ 0xd1b1f617, 0x74f06469, 0x38513ec5, 0x9d10acbb, 0x773e6cc8, 0xd27ffeb6,
+ 0xa68f9adf, 0x03ce08a1, 0xe9e0c8d2, 0x4ca15aac, 0x70a27d8a, 0xd5e3eff4,
+ 0x3fcd2f87, 0x9a8cbdf9, 0xee7cd990, 0x4b3d4bee, 0xa1138b9d, 0x045219e3,
+ 0x48f3434f, 0xedb2d131, 0x079c1142, 0xa2dd833c, 0xd62de755, 0x736c752b,
+ 0x9942b558, 0x3c032726, 0xe144fb14, 0x4405696a, 0xae2ba919, 0x0b6a3b67,
+ 0x7f9a5f0e, 0xdadbcd70, 0x30f50d03, 0x95b49f7d, 0xd915c5d1, 0x7c5457af,
+ 0x967a97dc, 0x333b05a2, 0x47cb61cb, 0xe28af3b5, 0x08a433c6, 0xade5a1b8,
+ 0x91e6869e, 0x34a714e0, 0xde89d493, 0x7bc846ed, 0x0f382284, 0xaa79b0fa,
+ 0x40577089, 0xe516e2f7, 0xa9b7b85b, 0x0cf62a25, 0xe6d8ea56, 0x43997828,
+ 0x37691c41, 0x92288e3f, 0x78064e4c, 0xdd47dc32, 0xc76580d9, 0x622412a7,
+ 0x880ad2d4, 0x2d4b40aa, 0x59bb24c3, 0xfcfab6bd, 0x16d476ce, 0xb395e4b0,
+ 0xff34be1c, 0x5a752c62, 0xb05bec11, 0x151a7e6f, 0x61ea1a06, 0xc4ab8878,
+ 0x2e85480b, 0x8bc4da75, 0xb7c7fd53, 0x12866f2d, 0xf8a8af5e, 0x5de93d20,
+ 0x29195949, 0x8c58cb37, 0x66760b44, 0xc337993a, 0x8f96c396, 0x2ad751e8,
+ 0xc0f9919b, 0x65b803e5, 0x1148678c, 0xb409f5f2, 0x5e273581, 0xfb66a7ff,
+ 0x26217bcd, 0x8360e9b3, 0x694e29c0, 0xcc0fbbbe, 0xb8ffdfd7, 0x1dbe4da9,
+ 0xf7908dda, 0x52d11fa4, 0x1e704508, 0xbb31d776, 0x511f1705, 0xf45e857b,
+ 0x80aee112, 0x25ef736c, 0xcfc1b31f, 0x6a802161, 0x56830647, 0xf3c29439,
+ 0x19ec544a, 0xbcadc634, 0xc85da25d, 0x6d1c3023, 0x8732f050, 0x2273622e,
+ 0x6ed23882, 0xcb93aafc, 0x21bd6a8f, 0x84fcf8f1, 0xf00c9c98, 0x554d0ee6,
+ 0xbf63ce95, 0x1a225ceb, 0x8b277743, 0x2e66e53d, 0xc448254e, 0x6109b730,
+ 0x15f9d359, 0xb0b84127, 0x5a968154, 0xffd7132a, 0xb3764986, 0x1637dbf8,
+ 0xfc191b8b, 0x595889f5, 0x2da8ed9c, 0x88e97fe2, 0x62c7bf91, 0xc7862def,
+ 0xfb850ac9, 0x5ec498b7, 0xb4ea58c4, 0x11abcaba, 0x655baed3, 0xc01a3cad,
+ 0x2a34fcde, 0x8f756ea0, 0xc3d4340c, 0x6695a672, 0x8cbb6601, 0x29faf47f,
+ 0x5d0a9016, 0xf84b0268, 0x1265c21b, 0xb7245065, 0x6a638c57, 0xcf221e29,
+ 0x250cde5a, 0x804d4c24, 0xf4bd284d, 0x51fcba33, 0xbbd27a40, 0x1e93e83e,
+ 0x5232b292, 0xf77320ec, 0x1d5de09f, 0xb81c72e1, 0xccec1688, 0x69ad84f6,
+ 0x83834485, 0x26c2d6fb, 0x1ac1f1dd, 0xbf8063a3, 0x55aea3d0, 0xf0ef31ae,
+ 0x841f55c7, 0x215ec7b9, 0xcb7007ca, 0x6e3195b4, 0x2290cf18, 0x87d15d66,
+ 0x6dff9d15, 0xc8be0f6b, 0xbc4e6b02, 0x190ff97c, 0xf321390f, 0x5660ab71,
+ 0x4c42f79a, 0xe90365e4, 0x032da597, 0xa66c37e9, 0xd29c5380, 0x77ddc1fe,
+ 0x9df3018d, 0x38b293f3, 0x7413c95f, 0xd1525b21, 0x3b7c9b52, 0x9e3d092c,
+ 0xeacd6d45, 0x4f8cff3b, 0xa5a23f48, 0x00e3ad36, 0x3ce08a10, 0x99a1186e,
+ 0x738fd81d, 0xd6ce4a63, 0xa23e2e0a, 0x077fbc74, 0xed517c07, 0x4810ee79,
+ 0x04b1b4d5, 0xa1f026ab, 0x4bdee6d8, 0xee9f74a6, 0x9a6f10cf, 0x3f2e82b1,
+ 0xd50042c2, 0x7041d0bc, 0xad060c8e, 0x08479ef0, 0xe2695e83, 0x4728ccfd,
+ 0x33d8a894, 0x96993aea, 0x7cb7fa99, 0xd9f668e7, 0x9557324b, 0x3016a035,
+ 0xda386046, 0x7f79f238, 0x0b899651, 0xaec8042f, 0x44e6c45c, 0xe1a75622,
+ 0xdda47104, 0x78e5e37a, 0x92cb2309, 0x378ab177, 0x437ad51e, 0xe63b4760,
+ 0x0c158713, 0xa954156d, 0xe5f54fc1, 0x40b4ddbf, 0xaa9a1dcc, 0x0fdb8fb2,
+ 0x7b2bebdb, 0xde6a79a5, 0x3444b9d6, 0x91052ba8};
static const uint32_t table3_[256] = {
- 0x00000000, 0xdd45aab8, 0xbf672381, 0x62228939,
- 0x7b2231f3, 0xa6679b4b, 0xc4451272, 0x1900b8ca,
- 0xf64463e6, 0x2b01c95e, 0x49234067, 0x9466eadf,
- 0x8d665215, 0x5023f8ad, 0x32017194, 0xef44db2c,
- 0xe964b13d, 0x34211b85, 0x560392bc, 0x8b463804,
- 0x924680ce, 0x4f032a76, 0x2d21a34f, 0xf06409f7,
- 0x1f20d2db, 0xc2657863, 0xa047f15a, 0x7d025be2,
- 0x6402e328, 0xb9474990, 0xdb65c0a9, 0x06206a11,
- 0xd725148b, 0x0a60be33, 0x6842370a, 0xb5079db2,
- 0xac072578, 0x71428fc0, 0x136006f9, 0xce25ac41,
- 0x2161776d, 0xfc24ddd5, 0x9e0654ec, 0x4343fe54,
- 0x5a43469e, 0x8706ec26, 0xe524651f, 0x3861cfa7,
- 0x3e41a5b6, 0xe3040f0e, 0x81268637, 0x5c632c8f,
- 0x45639445, 0x98263efd, 0xfa04b7c4, 0x27411d7c,
- 0xc805c650, 0x15406ce8, 0x7762e5d1, 0xaa274f69,
- 0xb327f7a3, 0x6e625d1b, 0x0c40d422, 0xd1057e9a,
- 0xaba65fe7, 0x76e3f55f, 0x14c17c66, 0xc984d6de,
- 0xd0846e14, 0x0dc1c4ac, 0x6fe34d95, 0xb2a6e72d,
- 0x5de23c01, 0x80a796b9, 0xe2851f80, 0x3fc0b538,
- 0x26c00df2, 0xfb85a74a, 0x99a72e73, 0x44e284cb,
- 0x42c2eeda, 0x9f874462, 0xfda5cd5b, 0x20e067e3,
- 0x39e0df29, 0xe4a57591, 0x8687fca8, 0x5bc25610,
- 0xb4868d3c, 0x69c32784, 0x0be1aebd, 0xd6a40405,
- 0xcfa4bccf, 0x12e11677, 0x70c39f4e, 0xad8635f6,
- 0x7c834b6c, 0xa1c6e1d4, 0xc3e468ed, 0x1ea1c255,
- 0x07a17a9f, 0xdae4d027, 0xb8c6591e, 0x6583f3a6,
- 0x8ac7288a, 0x57828232, 0x35a00b0b, 0xe8e5a1b3,
- 0xf1e51979, 0x2ca0b3c1, 0x4e823af8, 0x93c79040,
- 0x95e7fa51, 0x48a250e9, 0x2a80d9d0, 0xf7c57368,
- 0xeec5cba2, 0x3380611a, 0x51a2e823, 0x8ce7429b,
- 0x63a399b7, 0xbee6330f, 0xdcc4ba36, 0x0181108e,
- 0x1881a844, 0xc5c402fc, 0xa7e68bc5, 0x7aa3217d,
- 0x52a0c93f, 0x8fe56387, 0xedc7eabe, 0x30824006,
- 0x2982f8cc, 0xf4c75274, 0x96e5db4d, 0x4ba071f5,
- 0xa4e4aad9, 0x79a10061, 0x1b838958, 0xc6c623e0,
- 0xdfc69b2a, 0x02833192, 0x60a1b8ab, 0xbde41213,
- 0xbbc47802, 0x6681d2ba, 0x04a35b83, 0xd9e6f13b,
- 0xc0e649f1, 0x1da3e349, 0x7f816a70, 0xa2c4c0c8,
- 0x4d801be4, 0x90c5b15c, 0xf2e73865, 0x2fa292dd,
- 0x36a22a17, 0xebe780af, 0x89c50996, 0x5480a32e,
- 0x8585ddb4, 0x58c0770c, 0x3ae2fe35, 0xe7a7548d,
- 0xfea7ec47, 0x23e246ff, 0x41c0cfc6, 0x9c85657e,
- 0x73c1be52, 0xae8414ea, 0xcca69dd3, 0x11e3376b,
- 0x08e38fa1, 0xd5a62519, 0xb784ac20, 0x6ac10698,
- 0x6ce16c89, 0xb1a4c631, 0xd3864f08, 0x0ec3e5b0,
- 0x17c35d7a, 0xca86f7c2, 0xa8a47efb, 0x75e1d443,
- 0x9aa50f6f, 0x47e0a5d7, 0x25c22cee, 0xf8878656,
- 0xe1873e9c, 0x3cc29424, 0x5ee01d1d, 0x83a5b7a5,
- 0xf90696d8, 0x24433c60, 0x4661b559, 0x9b241fe1,
- 0x8224a72b, 0x5f610d93, 0x3d4384aa, 0xe0062e12,
- 0x0f42f53e, 0xd2075f86, 0xb025d6bf, 0x6d607c07,
- 0x7460c4cd, 0xa9256e75, 0xcb07e74c, 0x16424df4,
- 0x106227e5, 0xcd278d5d, 0xaf050464, 0x7240aedc,
- 0x6b401616, 0xb605bcae, 0xd4273597, 0x09629f2f,
- 0xe6264403, 0x3b63eebb, 0x59416782, 0x8404cd3a,
- 0x9d0475f0, 0x4041df48, 0x22635671, 0xff26fcc9,
- 0x2e238253, 0xf36628eb, 0x9144a1d2, 0x4c010b6a,
- 0x5501b3a0, 0x88441918, 0xea669021, 0x37233a99,
- 0xd867e1b5, 0x05224b0d, 0x6700c234, 0xba45688c,
- 0xa345d046, 0x7e007afe, 0x1c22f3c7, 0xc167597f,
- 0xc747336e, 0x1a0299d6, 0x782010ef, 0xa565ba57,
- 0xbc65029d, 0x6120a825, 0x0302211c, 0xde478ba4,
- 0x31035088, 0xec46fa30, 0x8e647309, 0x5321d9b1,
- 0x4a21617b, 0x9764cbc3, 0xf54642fa, 0x2803e842
-};
+ 0x00000000, 0xdd45aab8, 0xbf672381, 0x62228939, 0x7b2231f3, 0xa6679b4b,
+ 0xc4451272, 0x1900b8ca, 0xf64463e6, 0x2b01c95e, 0x49234067, 0x9466eadf,
+ 0x8d665215, 0x5023f8ad, 0x32017194, 0xef44db2c, 0xe964b13d, 0x34211b85,
+ 0x560392bc, 0x8b463804, 0x924680ce, 0x4f032a76, 0x2d21a34f, 0xf06409f7,
+ 0x1f20d2db, 0xc2657863, 0xa047f15a, 0x7d025be2, 0x6402e328, 0xb9474990,
+ 0xdb65c0a9, 0x06206a11, 0xd725148b, 0x0a60be33, 0x6842370a, 0xb5079db2,
+ 0xac072578, 0x71428fc0, 0x136006f9, 0xce25ac41, 0x2161776d, 0xfc24ddd5,
+ 0x9e0654ec, 0x4343fe54, 0x5a43469e, 0x8706ec26, 0xe524651f, 0x3861cfa7,
+ 0x3e41a5b6, 0xe3040f0e, 0x81268637, 0x5c632c8f, 0x45639445, 0x98263efd,
+ 0xfa04b7c4, 0x27411d7c, 0xc805c650, 0x15406ce8, 0x7762e5d1, 0xaa274f69,
+ 0xb327f7a3, 0x6e625d1b, 0x0c40d422, 0xd1057e9a, 0xaba65fe7, 0x76e3f55f,
+ 0x14c17c66, 0xc984d6de, 0xd0846e14, 0x0dc1c4ac, 0x6fe34d95, 0xb2a6e72d,
+ 0x5de23c01, 0x80a796b9, 0xe2851f80, 0x3fc0b538, 0x26c00df2, 0xfb85a74a,
+ 0x99a72e73, 0x44e284cb, 0x42c2eeda, 0x9f874462, 0xfda5cd5b, 0x20e067e3,
+ 0x39e0df29, 0xe4a57591, 0x8687fca8, 0x5bc25610, 0xb4868d3c, 0x69c32784,
+ 0x0be1aebd, 0xd6a40405, 0xcfa4bccf, 0x12e11677, 0x70c39f4e, 0xad8635f6,
+ 0x7c834b6c, 0xa1c6e1d4, 0xc3e468ed, 0x1ea1c255, 0x07a17a9f, 0xdae4d027,
+ 0xb8c6591e, 0x6583f3a6, 0x8ac7288a, 0x57828232, 0x35a00b0b, 0xe8e5a1b3,
+ 0xf1e51979, 0x2ca0b3c1, 0x4e823af8, 0x93c79040, 0x95e7fa51, 0x48a250e9,
+ 0x2a80d9d0, 0xf7c57368, 0xeec5cba2, 0x3380611a, 0x51a2e823, 0x8ce7429b,
+ 0x63a399b7, 0xbee6330f, 0xdcc4ba36, 0x0181108e, 0x1881a844, 0xc5c402fc,
+ 0xa7e68bc5, 0x7aa3217d, 0x52a0c93f, 0x8fe56387, 0xedc7eabe, 0x30824006,
+ 0x2982f8cc, 0xf4c75274, 0x96e5db4d, 0x4ba071f5, 0xa4e4aad9, 0x79a10061,
+ 0x1b838958, 0xc6c623e0, 0xdfc69b2a, 0x02833192, 0x60a1b8ab, 0xbde41213,
+ 0xbbc47802, 0x6681d2ba, 0x04a35b83, 0xd9e6f13b, 0xc0e649f1, 0x1da3e349,
+ 0x7f816a70, 0xa2c4c0c8, 0x4d801be4, 0x90c5b15c, 0xf2e73865, 0x2fa292dd,
+ 0x36a22a17, 0xebe780af, 0x89c50996, 0x5480a32e, 0x8585ddb4, 0x58c0770c,
+ 0x3ae2fe35, 0xe7a7548d, 0xfea7ec47, 0x23e246ff, 0x41c0cfc6, 0x9c85657e,
+ 0x73c1be52, 0xae8414ea, 0xcca69dd3, 0x11e3376b, 0x08e38fa1, 0xd5a62519,
+ 0xb784ac20, 0x6ac10698, 0x6ce16c89, 0xb1a4c631, 0xd3864f08, 0x0ec3e5b0,
+ 0x17c35d7a, 0xca86f7c2, 0xa8a47efb, 0x75e1d443, 0x9aa50f6f, 0x47e0a5d7,
+ 0x25c22cee, 0xf8878656, 0xe1873e9c, 0x3cc29424, 0x5ee01d1d, 0x83a5b7a5,
+ 0xf90696d8, 0x24433c60, 0x4661b559, 0x9b241fe1, 0x8224a72b, 0x5f610d93,
+ 0x3d4384aa, 0xe0062e12, 0x0f42f53e, 0xd2075f86, 0xb025d6bf, 0x6d607c07,
+ 0x7460c4cd, 0xa9256e75, 0xcb07e74c, 0x16424df4, 0x106227e5, 0xcd278d5d,
+ 0xaf050464, 0x7240aedc, 0x6b401616, 0xb605bcae, 0xd4273597, 0x09629f2f,
+ 0xe6264403, 0x3b63eebb, 0x59416782, 0x8404cd3a, 0x9d0475f0, 0x4041df48,
+ 0x22635671, 0xff26fcc9, 0x2e238253, 0xf36628eb, 0x9144a1d2, 0x4c010b6a,
+ 0x5501b3a0, 0x88441918, 0xea669021, 0x37233a99, 0xd867e1b5, 0x05224b0d,
+ 0x6700c234, 0xba45688c, 0xa345d046, 0x7e007afe, 0x1c22f3c7, 0xc167597f,
+ 0xc747336e, 0x1a0299d6, 0x782010ef, 0xa565ba57, 0xbc65029d, 0x6120a825,
+ 0x0302211c, 0xde478ba4, 0x31035088, 0xec46fa30, 0x8e647309, 0x5321d9b1,
+ 0x4a21617b, 0x9764cbc3, 0xf54642fa, 0x2803e842};
// Used to fetch a naturally-aligned 32-bit word in little endian byte-order
-static inline uint32_t LE_LOAD32(const uint8_t *p) {
+static inline uint32_t LE_LOAD32(const uint8_t* p) {
return DecodeFixed32(reinterpret_cast<const char*>(p));
}
#if defined(HAVE_SSE42) && (defined(__LP64__) || defined(_WIN64))
-static inline uint64_t LE_LOAD64(const uint8_t *p) {
+static inline uint64_t LE_LOAD64(const uint8_t* p) {
return DecodeFixed64(reinterpret_cast<const char*>(p));
}
#endif
-static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) {
+static inline void Slow_CRC32(uint64_t* l, uint8_t const** p) {
uint32_t c = static_cast<uint32_t>(*l ^ LE_LOAD32(*p));
*p += 4;
- *l = table3_[c & 0xff] ^
- table2_[(c >> 8) & 0xff] ^
- table1_[(c >> 16) & 0xff] ^
- table0_[c >> 24];
+ *l = table3_[c & 0xff] ^ table2_[(c >> 8) & 0xff] ^
+ table1_[(c >> 16) & 0xff] ^ table0_[c >> 24];
// DO it twice.
c = static_cast<uint32_t>(*l ^ LE_LOAD32(*p));
*p += 4;
- *l = table3_[c & 0xff] ^
- table2_[(c >> 8) & 0xff] ^
- table1_[(c >> 16) & 0xff] ^
- table0_[c >> 24];
+ *l = table3_[c & 0xff] ^ table2_[(c >> 8) & 0xff] ^
+ table1_[(c >> 16) & 0xff] ^ table0_[c >> 24];
}
#if (!(defined(HAVE_POWER8) && defined(HAS_ALTIVEC))) && \
(!defined(HAVE_ARM64_CRC)) || \
defined(NO_THREEWAY_CRC32C)
-static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) {
+static inline void Fast_CRC32(uint64_t* l, uint8_t const** p) {
#ifndef HAVE_SSE42
Slow_CRC32(l, p);
#elif defined(__LP64__) || defined(_WIN64)
@@ -373,21 +281,20 @@ static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) {
}
#endif
-template<void (*CRC32)(uint64_t*, uint8_t const**)>
+template <void (*CRC32)(uint64_t*, uint8_t const**)>
uint32_t ExtendImpl(uint32_t crc, const char* buf, size_t size) {
-
- const uint8_t *p = reinterpret_cast<const uint8_t *>(buf);
- const uint8_t *e = p + size;
+ const uint8_t* p = reinterpret_cast<const uint8_t*>(buf);
+ const uint8_t* e = p + size;
uint64_t l = crc ^ 0xffffffffu;
// Align n to (1 << m) byte boundary
-#define ALIGN(n, m) ((n + ((1 << m) - 1)) & ~((1 << m) - 1))
-
-#define STEP1 do { \
- int c = (l & 0xff) ^ *p++; \
- l = table0_[c] ^ (l >> 8); \
-} while (0)
+#define ALIGN(n, m) ((n + ((1 << m) - 1)) & ~((1 << m) - 1))
+#define STEP1 \
+ do { \
+ int c = (l & 0xff) ^ *p++; \
+ l = table0_[c] ^ (l >> 8); \
+ } while (0)
// Point x at first 16-byte aligned byte in string. This might be
// just past the end of the string.
@@ -400,12 +307,12 @@ uint32_t ExtendImpl(uint32_t crc, const char* buf, size_t size) {
}
}
// Process bytes 16 at a time
- while ((e-p) >= 16) {
+ while ((e - p) >= 16) {
CRC32(&l, &p);
CRC32(&l, &p);
}
// Process bytes 8 at a time
- while ((e-p) >= 8) {
+ while ((e - p) >= 8) {
CRC32(&l, &p);
}
// Process the last few bytes
@@ -440,8 +347,8 @@ static bool isSSE42() {
static bool isPCLMULQDQ() {
#ifndef HAVE_SSE42
-// in build_detect_platform we set this macro when both SSE42 and PCLMULQDQ are
-// supported by compiler
+ // in build_detect_platform we set this macro when both SSE42 and PCLMULQDQ
+ // are supported by compiler
return false;
#elif defined(__GNUC__) && defined(__x86_64__) && !defined(IOS_CROSS_COMPILE)
uint32_t c_;
@@ -462,8 +369,8 @@ static bool isPCLMULQDQ() {
using Function = uint32_t (*)(uint32_t, const char*, size_t);
#if defined(HAVE_POWER8) && defined(HAS_ALTIVEC)
-uint32_t ExtendPPCImpl(uint32_t crc, const char *buf, size_t size) {
- return crc32c_ppc(crc, (const unsigned char *)buf, size);
+uint32_t ExtendPPCImpl(uint32_t crc, const char* buf, size_t size) {
+ return crc32c_ppc(crc, (const unsigned char*)buf, size);
}
#if __linux__
@@ -500,8 +407,8 @@ static bool isAltiVec() {
#endif
#if defined(HAVE_ARM64_CRC)
-uint32_t ExtendARMImpl(uint32_t crc, const char *buf, size_t size) {
- return crc32c_arm64(crc, (const unsigned char *)buf, size);
+uint32_t ExtendARMImpl(uint32_t crc, const char* buf, size_t size) {
+ return crc32c_arm64(crc, (const unsigned char*)buf, size);
}
#endif
@@ -534,14 +441,12 @@ std::string IsFastCrc32Supported() {
#endif
if (has_fast_crc) {
fast_zero_msg.append("Supported on " + arch);
- }
- else {
+ } else {
fast_zero_msg.append("Not supported on " + arch);
}
return fast_zero_msg;
}
-
/*
* Copyright 2016 Ferry Toth, Exalon Delft BV, The Netherlands
* This software is provided 'as-is', without any express or implied
@@ -568,9 +473,10 @@ std::string IsFastCrc32Supported() {
* "Fast CRC Computation for iSCSI Polynomial Using CRC32 Instruction"
* https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/crc-iscsi-polynomial-crc32-instruction-paper.pdf
*
- * This version is from the folly library, created by Dave Watson <davejwatson@fb.com>
+ * This version is from the folly library, created by Dave Watson
+ * <davejwatson@fb.com>
*
-*/
+ */
#if defined HAVE_SSE42 && defined HAVE_PCLMUL
#define CRCtriplet(crc, buf, offset) \
@@ -582,10 +488,9 @@ std::string IsFastCrc32Supported() {
crc##0 = _mm_crc32_u64(crc##0, *(buf##0 + offset)); \
crc##1 = _mm_crc32_u64(crc##1, *(buf##1 + offset));
-#define CRCsinglet(crc, buf, offset) \
+#define CRCsinglet(crc, buf, offset) \
crc = _mm_crc32_u64(crc, *(uint64_t*)(buf + offset));
-
// Numbers taken directly from intel whitepaper.
// clang-format off
const uint64_t clmul_constants[] = {
diff --git a/util/crc32c.h b/util/crc32c.h
index d4f397c06..a08ad60af 100644
--- a/util/crc32c.h
+++ b/util/crc32c.h
@@ -10,6 +10,7 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
+
#include <string>
#include "rocksdb/rocksdb_namespace.h"
@@ -31,9 +32,7 @@ extern uint32_t Extend(uint32_t init_crc, const char* data, size_t n);
extern uint32_t Crc32cCombine(uint32_t crc1, uint32_t crc2, size_t crc2len);
// Return the crc32c of data[0,n-1]
-inline uint32_t Value(const char* data, size_t n) {
- return Extend(0, data, n);
-}
+inline uint32_t Value(const char* data, size_t n) { return Extend(0, data, n); }
static const uint32_t kMaskDelta = 0xa282ead8ul;
diff --git a/util/crc32c_test.cc b/util/crc32c_test.cc
index e8929bfe4..715d63e2d 100644
--- a/util/crc32c_test.cc
+++ b/util/crc32c_test.cc
@@ -15,8 +15,7 @@
namespace ROCKSDB_NAMESPACE {
namespace crc32c {
-class CRC { };
-
+class CRC {};
// Tests for 3-way crc32c algorithm. We need these tests because it uses
// different lookup tables than the original Fast_CRC32
@@ -31,42 +30,41 @@ struct ExpectedResult {
ExpectedResult expectedResults[] = {
// Zero-byte input
- { 0, 0, ~0U },
+ {0, 0, ~0U},
// Small aligned inputs to test special cases in SIMD implementations
- { 8, 1, 1543413366 },
- { 8, 2, 523493126 },
- { 8, 3, 1560427360 },
- { 8, 4, 3422504776 },
- { 8, 5, 447841138 },
- { 8, 6, 3910050499 },
- { 8, 7, 3346241981 },
+ {8, 1, 1543413366},
+ {8, 2, 523493126},
+ {8, 3, 1560427360},
+ {8, 4, 3422504776},
+ {8, 5, 447841138},
+ {8, 6, 3910050499},
+ {8, 7, 3346241981},
// Small unaligned inputs
- { 9, 1, 3855826643 },
- { 10, 2, 560880875 },
- { 11, 3, 1479707779 },
- { 12, 4, 2237687071 },
- { 13, 5, 4063855784 },
- { 14, 6, 2553454047 },
- { 15, 7, 1349220140 },
+ {9, 1, 3855826643},
+ {10, 2, 560880875},
+ {11, 3, 1479707779},
+ {12, 4, 2237687071},
+ {13, 5, 4063855784},
+ {14, 6, 2553454047},
+ {15, 7, 1349220140},
// Larger inputs to test leftover chunks at the end of aligned blocks
- { 8, 8, 627613930 },
- { 8, 9, 2105929409 },
- { 8, 10, 2447068514 },
- { 8, 11, 863807079 },
- { 8, 12, 292050879 },
- { 8, 13, 1411837737 },
- { 8, 14, 2614515001 },
- { 8, 15, 3579076296 },
- { 8, 16, 2897079161 },
- { 8, 17, 675168386 },
+ {8, 8, 627613930},
+ {8, 9, 2105929409},
+ {8, 10, 2447068514},
+ {8, 11, 863807079},
+ {8, 12, 292050879},
+ {8, 13, 1411837737},
+ {8, 14, 2614515001},
+ {8, 15, 3579076296},
+ {8, 16, 2897079161},
+ {8, 17, 675168386},
// // Much larger inputs
- { 0, BUFFER_SIZE, 2096790750 },
- { 1, BUFFER_SIZE / 2, 3854797577 },
+ {0, BUFFER_SIZE, 2096790750},
+ {1, BUFFER_SIZE / 2, 3854797577},
};
TEST(CRC, StandardResults) {
-
// Original Fast_CRC32 tests.
// From rfc3720 section B.4.
char buf[32];
@@ -88,18 +86,10 @@ TEST(CRC, StandardResults) {
ASSERT_EQ(0x113fdb5cU, Value(buf, sizeof(buf)));
unsigned char data[48] = {
- 0x01, 0xc0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x14, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x14,
- 0x00, 0x00, 0x00, 0x18,
- 0x28, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x18, 0x28, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
ASSERT_EQ(0xd9963a56, Value(reinterpret_cast<char*>(data), sizeof(data)));
@@ -114,21 +104,17 @@ TEST(CRC, StandardResults) {
for (auto expected : expectedResults) {
size_t partialLength = expected.length / 2;
uint32_t partialChecksum = Value(buffer + expected.offset, partialLength);
- uint32_t result = Extend(partialChecksum,
- buffer + expected.offset + partialLength,
- expected.length - partialLength);
+ uint32_t result =
+ Extend(partialChecksum, buffer + expected.offset + partialLength,
+ expected.length - partialLength);
EXPECT_EQ(~expected.crc32c, result);
}
-
}
-TEST(CRC, Values) {
- ASSERT_NE(Value("a", 1), Value("foo", 3));
-}
+TEST(CRC, Values) { ASSERT_NE(Value("a", 1), Value("foo", 3)); }
TEST(CRC, Extend) {
- ASSERT_EQ(Value("hello world", 11),
- Extend(Value("hello ", 6), "world", 5));
+ ASSERT_EQ(Value("hello world", 11), Extend(Value("hello ", 6), "world", 5));
}
TEST(CRC, Mask) {
@@ -189,15 +175,14 @@ TEST(CRC, Crc32cCombineBigSizeTest) {
// copied from folly
const uint64_t FNV_64_HASH_START = 14695981039346656037ULL;
-inline uint64_t fnv64_buf(const void* buf,
- size_t n,
+inline uint64_t fnv64_buf(const void* buf, size_t n,
uint64_t hash = FNV_64_HASH_START) {
// forcing signed char, since other platforms can use unsigned
const signed char* char_buf = reinterpret_cast<const signed char*>(buf);
for (size_t i = 0; i < n; ++i) {
hash += (hash << 1) + (hash << 4) + (hash << 5) + (hash << 7) +
- (hash << 8) + (hash << 40);
+ (hash << 8) + (hash << 40);
hash ^= char_buf[i];
}
return hash;
diff --git a/util/defer.h b/util/defer.h
index 33c0243e6..f71e67ba9 100644
--- a/util/defer.h
+++ b/util/defer.h
@@ -37,7 +37,8 @@ namespace ROCKSDB_NAMESPACE {
// but sometimes, this might lead to nested blocks of "if (s.ok()) {...}".
//
// With the help of Defer, you can centralize the cleanup logic inside the
-// lambda passed to Defer, and you can return immediately on failure when necessary.
+// lambda passed to Defer, and you can return immediately on failure when
+// necessary.
class Defer final {
public:
explicit Defer(std::function<void()>&& fn) : fn_(std::move(fn)) {}
diff --git a/util/defer_test.cc b/util/defer_test.cc
index 1334e68b2..0e98f68b6 100644
--- a/util/defer_test.cc
+++ b/util/defer_test.cc
@@ -3,10 +3,11 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
+#include "util/defer.h"
+
#include "port/port.h"
#include "port/stack_trace.h"
#include "test_util/testharness.h"
-#include "util/defer.h"
namespace ROCKSDB_NAMESPACE {
diff --git a/util/duplicate_detector.h b/util/duplicate_detector.h
index 02f6d09fa..d778622db 100644
--- a/util/duplicate_detector.h
+++ b/util/duplicate_detector.h
@@ -54,7 +54,8 @@ class DuplicateDetector {
db_->immutable_db_options().info_log,
"Recovering an entry from the dropped column family %" PRIu32
". WAL must must have been emptied before dropping the column "
- "family", cf);
+ "family",
+ cf);
#ifndef ROCKSDB_LITE
throw std::runtime_error(
"Recovering an entry from a dropped column family. "
diff --git a/util/dynamic_bloom.cc b/util/dynamic_bloom.cc
index 60d4b2cf2..0ff3b4a75 100644
--- a/util/dynamic_bloom.cc
+++ b/util/dynamic_bloom.cc
@@ -23,7 +23,7 @@ uint32_t roundUpToPow2(uint32_t x) {
}
return rv;
}
-}
+} // namespace
DynamicBloom::DynamicBloom(Allocator* allocator, uint32_t total_bits,
uint32_t num_probes, size_t huge_page_tlb_size,
diff --git a/util/dynamic_bloom.h b/util/dynamic_bloom.h
index 542183280..40cd29404 100644
--- a/util/dynamic_bloom.h
+++ b/util/dynamic_bloom.h
@@ -6,15 +6,15 @@
#pragma once
#include <array>
+#include <atomic>
+#include <memory>
#include <string>
+
#include "port/port.h"
#include "rocksdb/slice.h"
#include "table/multiget_context.h"
#include "util/hash.h"
-#include <atomic>
-#include <memory>
-
namespace ROCKSDB_NAMESPACE {
class Slice;
diff --git a/util/dynamic_bloom_test.cc b/util/dynamic_bloom_test.cc
index 9f43ce0fd..925c5479a 100644
--- a/util/dynamic_bloom_test.cc
+++ b/util/dynamic_bloom_test.cc
@@ -314,7 +314,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);
diff --git a/util/filelock_test.cc b/util/filelock_test.cc
index e7f4d8ae4..69947a732 100644
--- a/util/filelock_test.cc
+++ b/util/filelock_test.cc
@@ -3,15 +3,16 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
//
-#include "rocksdb/status.h"
-#include "rocksdb/env.h"
-
#include <fcntl.h>
+
+#include "rocksdb/env.h"
+#include "rocksdb/status.h"
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/wait.h>
#endif
#include <vector>
+
#include "test_util/testharness.h"
#include "util/coding.h"
#include "util/string_util.h"
@@ -32,23 +33,19 @@ class LockTest : public testing::Test {
~LockTest() override {}
- Status LockFile(FileLock** db_lock) {
- return env_->LockFile(file_, db_lock);
- }
+ Status LockFile(FileLock** db_lock) { return env_->LockFile(file_, db_lock); }
- Status UnlockFile(FileLock* db_lock) {
- return env_->UnlockFile(db_lock);
- }
+ Status UnlockFile(FileLock* db_lock) { return env_->UnlockFile(db_lock); }
- bool AssertFileIsLocked(){
- return CheckFileLock( /* lock_expected = */ true);
+ bool AssertFileIsLocked() {
+ return CheckFileLock(/* lock_expected = */ true);
}
- bool AssertFileIsNotLocked(){
- return CheckFileLock( /* lock_expected = */ false);
+ bool AssertFileIsNotLocked() {
+ return CheckFileLock(/* lock_expected = */ false);
}
- bool CheckFileLock(bool lock_expected){
+ bool CheckFileLock(bool lock_expected) {
// We need to fork to check the fcntl lock as we need
// to open and close the file from a different process
// to avoid either releasing the lock on close, or not
@@ -63,13 +60,13 @@ class LockTest : public testing::Test {
#else
pid_t pid = fork();
- if ( 0 == pid ) {
+ if (0 == pid) {
// child process
int exit_val = EXIT_FAILURE;
int fd = open(file_.c_str(), O_RDWR | O_CREAT, 0644);
if (fd < 0) {
// could not open file, could not check if it was locked
- fprintf( stderr, "Open on on file %s failed.\n",file_.c_str());
+ fprintf(stderr, "Open on on file %s failed.\n", file_.c_str());
exit(exit_val);
}
@@ -78,23 +75,24 @@ class LockTest : public testing::Test {
f.l_type = (F_WRLCK);
f.l_whence = SEEK_SET;
f.l_start = 0;
- f.l_len = 0; // Lock/unlock entire file
+ f.l_len = 0; // Lock/unlock entire file
int value = fcntl(fd, F_SETLK, &f);
- if( value == -1 ){
- if( lock_expected ){
+ if (value == -1) {
+ if (lock_expected) {
exit_val = EXIT_SUCCESS;
}
} else {
- if( ! lock_expected ){
+ if (!lock_expected) {
exit_val = EXIT_SUCCESS;
}
}
- close(fd); // lock is released for child process
+ close(fd); // lock is released for child process
exit(exit_val);
} else if (pid > 0) {
// parent process
int status;
- while (-1 == waitpid(pid, &status, 0));
+ while (-1 == waitpid(pid, &status, 0))
+ ;
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
// child process exited with non success status
return false;
@@ -102,15 +100,13 @@ class LockTest : public testing::Test {
return true;
}
} else {
- fprintf( stderr, "Fork failed\n" );
+ fprintf(stderr, "Fork failed\n");
return false;
}
return false;
#endif
-
}
-
};
LockTest* LockTest::current_;
@@ -122,7 +118,7 @@ TEST_F(LockTest, LockBySameThread) {
ASSERT_OK(LockFile(&lock1));
// check the file is locked
- ASSERT_TRUE( AssertFileIsLocked() );
+ ASSERT_TRUE(AssertFileIsLocked());
// re-acquire the lock on the same file. This should fail.
Status s = LockFile(&lock2);
@@ -134,14 +130,13 @@ TEST_F(LockTest, LockBySameThread) {
#endif
// check the file is locked
- ASSERT_TRUE( AssertFileIsLocked() );
+ ASSERT_TRUE(AssertFileIsLocked());
// release the lock
ASSERT_OK(UnlockFile(lock1));
// check the file is not locked
- ASSERT_TRUE( AssertFileIsNotLocked() );
-
+ ASSERT_TRUE(AssertFileIsNotLocked());
}
} // namespace ROCKSDB_NAMESPACE
diff --git a/util/filter_bench.cc b/util/filter_bench.cc
index f1cf27115..93186cd08 100644
--- a/util/filter_bench.cc
+++ b/util/filter_bench.cc
@@ -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
@@ -378,9 +378,9 @@ 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
- : FLAGS_quick ? quickTestModes : allTestModes;
+ const std::vector<TestMode> &testModes = FLAGS_best_case ? bestCaseTestModes
+ : FLAGS_quick ? quickTestModes
+ : allTestModes;
m_queries_ = FLAGS_m_queries;
double working_mem_size_mb = FLAGS_working_mem_size_mb;
diff --git a/util/hash_test.cc b/util/hash_test.cc
index 4b1d52238..72112b044 100644
--- a/util/hash_test.cc
+++ b/util/hash_test.cc
@@ -547,7 +547,7 @@ TEST(FastRangeGenericTest, Values) {
uint16_t{6234});
// Not recommended for typical use because for example this could fail on
// some platforms and pass on others:
- //EXPECT_EQ(FastRangeGeneric(static_cast<unsigned long>(0x80000000),
+ // EXPECT_EQ(FastRangeGeneric(static_cast<unsigned long>(0x80000000),
// uint16_t{12468}),
// uint16_t{6234});
}
@@ -843,7 +843,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();
diff --git a/util/heap.h b/util/heap.h
index 3f4cddeb9..f221fc732 100644
--- a/util/heap.h
+++ b/util/heap.h
@@ -8,6 +8,7 @@
#include <algorithm>
#include <cstdint>
#include <functional>
+
#include "port/port.h"
#include "util/autovector.h"
@@ -37,11 +38,11 @@ namespace ROCKSDB_NAMESPACE {
// std::priority_queue: the comparison operator is expected to provide the
// less-than relation, but top() will return the maximum.
-template<typename T, typename Compare = std::less<T>>
+template <typename T, typename Compare = std::less<T>>
class BinaryHeap {
public:
- BinaryHeap() { }
- explicit BinaryHeap(Compare cmp) : cmp_(std::move(cmp)) { }
+ BinaryHeap() {}
+ explicit BinaryHeap(Compare cmp) : cmp_(std::move(cmp)) {}
void push(const T& value) {
data_.push_back(value);
@@ -86,7 +87,7 @@ class BinaryHeap {
}
}
- void swap(BinaryHeap &other) {
+ void swap(BinaryHeap& other) {
std::swap(cmp_, other.cmp_);
data_.swap(other.data_);
std::swap(root_cmp_cache_, other.root_cmp_cache_);
diff --git a/util/heap_test.cc b/util/heap_test.cc
index fd54751e3..bbb93324f 100644
--- a/util/heap_test.cc
+++ b/util/heap_test.cc
@@ -31,8 +31,7 @@ namespace ROCKSDB_NAMESPACE {
using HeapTestValue = uint64_t;
using Params = std::tuple<size_t, HeapTestValue, int64_t>;
-class HeapTest : public ::testing::TestWithParam<Params> {
-};
+class HeapTest : public ::testing::TestWithParam<Params> {};
TEST_P(HeapTest, Test) {
// This test performs the same pseudorandom sequence of operations on a
@@ -54,15 +53,14 @@ TEST_P(HeapTest, Test) {
std::mt19937 rng(static_cast<unsigned int>(RNG_SEED));
std::uniform_int_distribution<HeapTestValue> value_dist(0, MAX_VALUE);
int ndrains = 0;
- bool draining = false; // hit max size, draining until we empty the heap
+ bool draining = false; // hit max size, draining until we empty the heap
size_t size = 0;
for (int64_t i = 0; i < FLAGS_iters; ++i) {
if (size == 0) {
draining = false;
}
- if (!draining &&
- (size == 0 || std::bernoulli_distribution(0.4)(rng))) {
+ if (!draining && (size == 0 || std::bernoulli_distribution(0.4)(rng))) {
// insert
HeapTestValue val = value_dist(rng);
heap.push(val);
@@ -104,30 +102,22 @@ TEST_P(HeapTest, Test) {
}
// Basic test, MAX_VALUE = 3*MAX_HEAP_SIZE (occasional duplicates)
-INSTANTIATE_TEST_CASE_P(
- Basic, HeapTest,
- ::testing::Values(Params(1000, 3000, 0x1b575cf05b708945))
-);
+INSTANTIATE_TEST_CASE_P(Basic, HeapTest,
+ ::testing::Values(Params(1000, 3000,
+ 0x1b575cf05b708945)));
// Mid-size heap with small values (many duplicates)
-INSTANTIATE_TEST_CASE_P(
- SmallValues, HeapTest,
- ::testing::Values(Params(100, 10, 0x5ae213f7bd5dccd0))
-);
+INSTANTIATE_TEST_CASE_P(SmallValues, HeapTest,
+ ::testing::Values(Params(100, 10, 0x5ae213f7bd5dccd0)));
// Small heap, large value range (no duplicates)
-INSTANTIATE_TEST_CASE_P(
- SmallHeap, HeapTest,
- ::testing::Values(Params(10, ULLONG_MAX, 0x3e1fa8f4d01707cf))
-);
+INSTANTIATE_TEST_CASE_P(SmallHeap, HeapTest,
+ ::testing::Values(Params(10, ULLONG_MAX,
+ 0x3e1fa8f4d01707cf)));
// Two-element heap
-INSTANTIATE_TEST_CASE_P(
- TwoElementHeap, HeapTest,
- ::testing::Values(Params(2, 5, 0x4b5e13ea988c6abc))
-);
+INSTANTIATE_TEST_CASE_P(TwoElementHeap, HeapTest,
+ ::testing::Values(Params(2, 5, 0x4b5e13ea988c6abc)));
// One-element heap
-INSTANTIATE_TEST_CASE_P(
- OneElementHeap, HeapTest,
- ::testing::Values(Params(1, 3, 0x176a1019ab0b612e))
-);
+INSTANTIATE_TEST_CASE_P(OneElementHeap, HeapTest,
+ ::testing::Values(Params(1, 3, 0x176a1019ab0b612e)));
} // namespace ROCKSDB_NAMESPACE
diff --git a/util/kv_map.h b/util/kv_map.h
index 89300d7ac..62be6d18e 100644
--- a/util/kv_map.h
+++ b/util/kv_map.h
@@ -29,5 +29,5 @@ struct LessOfComparator {
};
using KVMap = std::map<std::string, std::string, LessOfComparator>;
-}
+} // namespace stl_wrappers
} // namespace ROCKSDB_NAMESPACE
diff --git a/util/murmurhash.h b/util/murmurhash.h
index 5f66c4ebf..7ef4cbbec 100644
--- a/util/murmurhash.h
+++ b/util/murmurhash.h
@@ -11,23 +11,24 @@
*/
#pragma once
#include <stdint.h>
+
#include "rocksdb/slice.h"
#if defined(__x86_64__)
#define MURMUR_HASH MurmurHash64A
-uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed );
+uint64_t MurmurHash64A(const void* key, int len, unsigned int seed);
#define MurmurHash MurmurHash64A
using murmur_t = uint64_t;
#elif defined(__i386__)
#define MURMUR_HASH MurmurHash2
-unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed );
+unsigned int MurmurHash2(const void* key, int len, unsigned int seed);
#define MurmurHash MurmurHash2
using murmur_t = unsigned int;
#else
#define MURMUR_HASH MurmurHashNeutral2
-unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed );
+unsigned int MurmurHashNeutral2(const void* key, int len, unsigned int seed);
#define MurmurHash MurmurHashNeutral2
using murmur_t = unsigned int;
#endif
diff --git a/util/mutexlock.h b/util/mutexlock.h
index 8af29dd78..94066b29e 100644
--- a/util/mutexlock.h
+++ b/util/mutexlock.h
@@ -9,9 +9,11 @@
#pragma once
#include <assert.h>
+
#include <atomic>
#include <mutex>
#include <thread>
+
#include "port/port.h"
namespace ROCKSDB_NAMESPACE {
@@ -28,9 +30,7 @@ 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;
@@ -48,9 +48,7 @@ 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;
@@ -84,9 +82,7 @@ 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;
@@ -152,13 +148,11 @@ class Striped {
public:
Striped(size_t stripes, std::function<uint64_t(const P &)> hash)
: stripes_(stripes), hash_(hash) {
-
locks_ = reinterpret_cast<LockData<T> *>(
port::cacheline_aligned_alloc(sizeof(LockData<T>) * stripes));
for (size_t i = 0; i < stripes; i++) {
new (&locks_[i]) LockData<T>();
}
-
}
virtual ~Striped() {
diff --git a/util/random.cc b/util/random.cc
index 5d9f4bc67..c94c28dfb 100644
--- a/util/random.cc
+++ b/util/random.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <string.h>
+
#include <thread>
#include <utility>
diff --git a/util/random.h b/util/random.h
index 16162f67b..8923bdc4f 100644
--- a/util/random.h
+++ b/util/random.h
@@ -85,9 +85,7 @@ class Random {
// Skewed: pick "base" uniformly from range [0,max_log] and then
// return "base" random bits. The effect is to pick a number in the
// range [0,2^max_log-1] with exponential bias towards smaller numbers.
- uint32_t Skewed(int max_log) {
- return Uniform(1 << Uniform(max_log + 1));
- }
+ uint32_t Skewed(int max_log) { return Uniform(1 << Uniform(max_log + 1)); }
// Returns a random string of length "len"
std::string RandomString(int len);
@@ -153,7 +151,7 @@ class Random64 {
std::mt19937_64 generator_;
public:
- explicit Random64(uint64_t s) : generator_(s) { }
+ explicit Random64(uint64_t s) : generator_(s) {}
// Generates the next random number
uint64_t Next() { return generator_(); }
diff --git a/util/random_test.cc b/util/random_test.cc
index b8c9357e8..1aa62c5da 100644
--- a/util/random_test.cc
+++ b/util/random_test.cc
@@ -7,11 +7,12 @@
// 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 "util/random.h"
+
#include <cstring>
#include <vector>
#include "test_util/testharness.h"
-#include "util/random.h"
using ROCKSDB_NAMESPACE::Random;
diff --git a/util/ribbon_test.cc b/util/ribbon_test.cc
index ae6d1db49..6519df3d5 100644
--- a/util/ribbon_test.cc
+++ b/util/ribbon_test.cc
@@ -836,9 +836,10 @@ TYPED_TEST(RibbonTypeParamTest, CompactnessAndBacktrackAndFpRate) {
double single_failure_rate = 1.0 * total_single_failures / total_singles;
fprintf(stderr, "Add'l single, failure rate: %g\n", single_failure_rate);
// A rough bound (one sided) based on nothing in particular
- double expected_single_failures =
- 1.0 * total_singles /
- (sizeof(CoeffRow) == 16 ? 128 : TypeParam::kUseSmash ? 64 : 32);
+ double expected_single_failures = 1.0 * total_singles /
+ (sizeof(CoeffRow) == 16 ? 128
+ : TypeParam::kUseSmash ? 64
+ : 32);
EXPECT_LE(total_single_failures,
InfrequentPoissonUpperBound(expected_single_failures));
}
diff --git a/util/slice.cc b/util/slice.cc
index f9f4ddd59..1fa21afcb 100644
--- a/util/slice.cc
+++ b/util/slice.cc
@@ -128,7 +128,7 @@ class CappedPrefixTransform : public SliceTransform {
class NoopTransform : public SliceTransform {
public:
- explicit NoopTransform() { }
+ explicit NoopTransform() {}
static const char* kClassName() { return "rocksdb.Noop"; }
const char* Name() const override { return kClassName(); }
diff --git a/util/slice_test.cc b/util/slice_test.cc
index 486590e7b..e1c35d567 100644
--- a/util/slice_test.cc
+++ b/util/slice_test.cc
@@ -32,8 +32,7 @@ void Multiplier(void* arg1, void* arg2) {
class PinnableSliceTest : public testing::Test {
public:
- void AssertSameData(const std::string& expected,
- const PinnableSlice& slice) {
+ void AssertSameData(const std::string& expected, const PinnableSlice& slice) {
std::string got;
got.assign(slice.data(), slice.size());
ASSERT_EQ(expected, got);
diff --git a/util/status.cc b/util/status.cc
index 2c9aa5015..72fdfdbcc 100644
--- a/util/status.cc
+++ b/util/status.cc
@@ -8,11 +8,13 @@
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "rocksdb/status.h"
+
#include <stdio.h>
#ifdef OS_WIN
#include <string.h>
#endif
#include <cstring>
+
#include "port/port.h"
namespace ROCKSDB_NAMESPACE {
diff --git a/util/string_util.cc b/util/string_util.cc
index 94459dac4..324482a4c 100644
--- a/util/string_util.cc
+++ b/util/string_util.cc
@@ -8,6 +8,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+
#include <algorithm>
#include <cinttypes>
#include <cmath>
@@ -15,6 +16,7 @@
#include <string>
#include <utility>
#include <vector>
+
#include "port/port.h"
#include "port/sys_time.h"
#include "rocksdb/slice.h"
diff --git a/util/thread_list_test.cc b/util/thread_list_test.cc
index 51edee020..af4e62355 100644
--- a/util/thread_list_test.cc
+++ b/util/thread_list_test.cc
@@ -3,8 +3,8 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
-#include <mutex>
#include <condition_variable>
+#include <mutex>
#include "monitoring/thread_status_updater.h"
#include "rocksdb/db.h"
@@ -17,16 +17,19 @@ namespace ROCKSDB_NAMESPACE {
class SimulatedBackgroundTask {
public:
SimulatedBackgroundTask(
- const void* db_key, const std::string& db_name,
- const void* cf_key, const std::string& cf_name,
+ const void* db_key, const std::string& db_name, const void* cf_key,
+ const std::string& cf_name,
const ThreadStatus::OperationType operation_type =
ThreadStatus::OP_UNKNOWN,
- const ThreadStatus::StateType state_type =
- ThreadStatus::STATE_UNKNOWN)
- : db_key_(db_key), db_name_(db_name),
- cf_key_(cf_key), cf_name_(cf_name),
- operation_type_(operation_type), state_type_(state_type),
- should_run_(true), running_count_(0) {
+ const ThreadStatus::StateType state_type = ThreadStatus::STATE_UNKNOWN)
+ : db_key_(db_key),
+ db_name_(db_name),
+ cf_key_(cf_key),
+ cf_name_(cf_name),
+ operation_type_(operation_type),
+ state_type_(state_type),
+ should_run_(true),
+ running_count_(0) {
Env::Default()->GetThreadStatusUpdater()->NewColumnFamilyInfo(
db_key_, db_name_, cf_key_, cf_name_);
}
@@ -92,24 +95,22 @@ class SimulatedBackgroundTask {
class ThreadListTest : public testing::Test {
public:
- ThreadListTest() {
- }
+ ThreadListTest() {}
};
TEST_F(ThreadListTest, GlobalTables) {
// verify the global tables for operations and states are properly indexed.
for (int type = 0; type != ThreadStatus::NUM_OP_TYPES; ++type) {
ASSERT_EQ(global_operation_table[type].type, type);
- ASSERT_EQ(global_operation_table[type].name,
- ThreadStatus::GetOperationName(
- ThreadStatus::OperationType(type)));
+ ASSERT_EQ(
+ global_operation_table[type].name,
+ ThreadStatus::GetOperationName(ThreadStatus::OperationType(type)));
}
for (int type = 0; type != ThreadStatus::NUM_STATE_TYPES; ++type) {
ASSERT_EQ(global_state_table[type].type, type);
ASSERT_EQ(global_state_table[type].name,
- ThreadStatus::GetStateName(
- ThreadStatus::StateType(type)));
+ ThreadStatus::GetStateName(ThreadStatus::StateType(type)));
}
for (int stage = 0; stage != ThreadStatus::NUM_OP_STAGES; ++stage) {
@@ -131,18 +132,18 @@ TEST_F(ThreadListTest, SimpleColumnFamilyInfoTest) {
env->SetBackgroundThreads(kLowPriorityThreads, Env::LOW);
// Wait 1 second so that threads start
Env::Default()->SleepForMicroseconds(kDelayMicros);
- SimulatedBackgroundTask running_task(
- reinterpret_cast<void*>(1234), "running",
- reinterpret_cast<void*>(5678), "pikachu");
+ SimulatedBackgroundTask running_task(reinterpret_cast<void*>(1234), "running",
+ reinterpret_cast<void*>(5678),
+ "pikachu");
for (int test = 0; test < kSimulatedHighPriThreads; ++test) {
- env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
- &running_task, Env::Priority::HIGH);
+ env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask, &running_task,
+ Env::Priority::HIGH);
}
for (int test = 0; test < kSimulatedLowPriThreads; ++test) {
- env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
- &running_task, Env::Priority::LOW);
+ env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask, &running_task,
+ Env::Priority::LOW);
}
running_task.WaitUntilScheduled(kSimulatedHighPriThreads +
kSimulatedLowPriThreads);
@@ -168,14 +169,10 @@ TEST_F(ThreadListTest, SimpleColumnFamilyInfoTest) {
ASSERT_EQ(0, env->ReserveThreads(kHighPriorityThreads, Env::Priority::HIGH));
ASSERT_EQ(0, env->ReserveThreads(kLowPriorityThreads, Env::Priority::LOW));
- ASSERT_EQ(
- running_count[ThreadStatus::HIGH_PRIORITY],
- kSimulatedHighPriThreads);
- ASSERT_EQ(
- running_count[ThreadStatus::LOW_PRIORITY],
- kSimulatedLowPriThreads);
- ASSERT_EQ(
- running_count[ThreadStatus::USER], 0);
+ ASSERT_EQ(running_count[ThreadStatus::HIGH_PRIORITY],
+ kSimulatedHighPriThreads);
+ ASSERT_EQ(running_count[ThreadStatus::LOW_PRIORITY], kSimulatedLowPriThreads);
+ ASSERT_EQ(running_count[ThreadStatus::USER], 0);
running_task.FinishAllTasks();
running_task.WaitUntilDone();
@@ -197,37 +194,33 @@ TEST_F(ThreadListTest, SimpleColumnFamilyInfoTest) {
}
}
- ASSERT_EQ(
- running_count[ThreadStatus::HIGH_PRIORITY], 0);
- ASSERT_EQ(
- running_count[ThreadStatus::LOW_PRIORITY], 0);
- ASSERT_EQ(
- running_count[ThreadStatus::USER], 0);
+ ASSERT_EQ(running_count[ThreadStatus::HIGH_PRIORITY], 0);
+ ASSERT_EQ(running_count[ThreadStatus::LOW_PRIORITY], 0);
+ ASSERT_EQ(running_count[ThreadStatus::USER], 0);
}
namespace {
- void UpdateStatusCounts(
- const std::vector<ThreadStatus>& thread_list,
- int operation_counts[], int state_counts[]) {
- for (auto thread_status : thread_list) {
- operation_counts[thread_status.operation_type]++;
- state_counts[thread_status.state_type]++;
- }
+void UpdateStatusCounts(const std::vector<ThreadStatus>& thread_list,
+ int operation_counts[], int state_counts[]) {
+ for (auto thread_status : thread_list) {
+ operation_counts[thread_status.operation_type]++;
+ state_counts[thread_status.state_type]++;
}
+}
- void VerifyAndResetCounts(
- const int correct_counts[], int collected_counts[], int size) {
- for (int i = 0; i < size; ++i) {
- ASSERT_EQ(collected_counts[i], correct_counts[i]);
- collected_counts[i] = 0;
- }
+void VerifyAndResetCounts(const int correct_counts[], int collected_counts[],
+ int size) {
+ for (int i = 0; i < size; ++i) {
+ ASSERT_EQ(collected_counts[i], correct_counts[i]);
+ collected_counts[i] = 0;
}
+}
- void UpdateCount(
- int operation_counts[], int from_event, int to_event, int amount) {
- operation_counts[from_event] -= amount;
- operation_counts[to_event] += amount;
- }
+void UpdateCount(int operation_counts[], int from_event, int to_event,
+ int amount) {
+ operation_counts[from_event] -= amount;
+ operation_counts[to_event] += amount;
+}
} // namespace
TEST_F(ThreadListTest, SimpleEventTest) {
@@ -236,62 +229,57 @@ TEST_F(ThreadListTest, SimpleEventTest) {
// simulated tasks
const int kFlushWriteTasks = 3;
SimulatedBackgroundTask flush_write_task(
- reinterpret_cast<void*>(1234), "running",
- reinterpret_cast<void*>(5678), "pikachu",
- ThreadStatus::OP_FLUSH);
+ reinterpret_cast<void*>(1234), "running", reinterpret_cast<void*>(5678),
+ "pikachu", ThreadStatus::OP_FLUSH);
const int kCompactionWriteTasks = 4;
SimulatedBackgroundTask compaction_write_task(
- reinterpret_cast<void*>(1234), "running",
- reinterpret_cast<void*>(5678), "pikachu",
- ThreadStatus::OP_COMPACTION);
+ reinterpret_cast<void*>(1234), "running", reinterpret_cast<void*>(5678),
+ "pikachu", ThreadStatus::OP_COMPACTION);
const int kCompactionReadTasks = 5;
SimulatedBackgroundTask compaction_read_task(
- reinterpret_cast<void*>(1234), "running",
- reinterpret_cast<void*>(5678), "pikachu",
- ThreadStatus::OP_COMPACTION);
+ reinterpret_cast<void*>(1234), "running", reinterpret_cast<void*>(5678),
+ "pikachu", ThreadStatus::OP_COMPACTION);
const int kCompactionWaitTasks = 6;
SimulatedBackgroundTask compaction_wait_task(
- reinterpret_cast<void*>(1234), "running",
- reinterpret_cast<void*>(5678), "pikachu",
- ThreadStatus::OP_COMPACTION);
+ reinterpret_cast<void*>(1234), "running", reinterpret_cast<void*>(5678),
+ "pikachu", ThreadStatus::OP_COMPACTION);
// setup right answers
int correct_operation_counts[ThreadStatus::NUM_OP_TYPES] = {0};
- correct_operation_counts[ThreadStatus::OP_FLUSH] =
- kFlushWriteTasks;
+ correct_operation_counts[ThreadStatus::OP_FLUSH] = kFlushWriteTasks;
correct_operation_counts[ThreadStatus::OP_COMPACTION] =
kCompactionWriteTasks + kCompactionReadTasks + kCompactionWaitTasks;
- env->SetBackgroundThreads(
- correct_operation_counts[ThreadStatus::OP_FLUSH], Env::HIGH);
+ env->SetBackgroundThreads(correct_operation_counts[ThreadStatus::OP_FLUSH],
+ Env::HIGH);
env->SetBackgroundThreads(
correct_operation_counts[ThreadStatus::OP_COMPACTION], Env::LOW);
// schedule the simulated tasks
for (int t = 0; t < kFlushWriteTasks; ++t) {
- env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
- &flush_write_task, Env::Priority::HIGH);
+ env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask, &flush_write_task,
+ Env::Priority::HIGH);
}
flush_write_task.WaitUntilScheduled(kFlushWriteTasks);
for (int t = 0; t < kCompactionWriteTasks; ++t) {
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
- &compaction_write_task, Env::Priority::LOW);
+ &compaction_write_task, Env::Priority::LOW);
}
compaction_write_task.WaitUntilScheduled(kCompactionWriteTasks);
for (int t = 0; t < kCompactionReadTasks; ++t) {
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
- &compaction_read_task, Env::Priority::LOW);
+ &compaction_read_task, Env::Priority::LOW);
}
compaction_read_task.WaitUntilScheduled(kCompactionReadTasks);
for (int t = 0; t < kCompactionWaitTasks; ++t) {
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
- &compaction_wait_task, Env::Priority::LOW);
+ &compaction_wait_task, Env::Priority::LOW);
}
compaction_wait_task.WaitUntilScheduled(kCompactionWaitTasks);
diff --git a/util/thread_local.cc b/util/thread_local.cc
index 61c5f59dc..969639d9b 100644
--- a/util/thread_local.cc
+++ b/util/thread_local.cc
@@ -8,10 +8,12 @@
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "util/thread_local.h"
-#include "util/mutexlock.h"
-#include "port/likely.h"
+
#include <stdlib.h>
+#include "port/likely.h"
+#include "util/mutexlock.h"
+
namespace ROCKSDB_NAMESPACE {
struct Entry {
@@ -39,10 +41,7 @@ class StaticMeta;
// ---------------------------------------------------
struct ThreadData {
explicit ThreadData(ThreadLocalPtr::StaticMeta* _inst)
- : entries(),
- next(nullptr),
- prev(nullptr),
- inst(_inst) {}
+ : entries(), next(nullptr), prev(nullptr), inst(_inst) {}
std::vector<Entry> entries;
ThreadData* next;
ThreadData* prev;
@@ -50,7 +49,7 @@ struct ThreadData {
};
class ThreadLocalPtr::StaticMeta {
-public:
+ public:
StaticMeta();
// Return the next available Id
@@ -107,7 +106,7 @@ public:
// should be used. One example is OnThreadExit() function.
port::Mutex* MemberMutex() { return &mutex_; }
-private:
+ private:
// Get UnrefHandler for id with acquiring mutex
// REQUIRES: mutex locked
UnrefHandler GetHandler(uint32_t id);
@@ -173,7 +172,7 @@ namespace wintlscleanup {
// This is set to OnThreadExit in StaticMeta singleton constructor
UnrefHandler thread_local_inclass_routine = nullptr;
-pthread_key_t thread_local_key = pthread_key_t (-1);
+pthread_key_t thread_local_key = pthread_key_t(-1);
// Static callback function to call with each thread termination.
void NTAPI WinOnThreadExit(PVOID module, DWORD reason, PVOID reserved) {
@@ -189,7 +188,7 @@ void NTAPI WinOnThreadExit(PVOID module, DWORD reason, PVOID reserved) {
}
}
-} // wintlscleanup
+} // namespace wintlscleanup
// extern "C" suppresses C++ name mangling so we know the symbol name for the
// linker /INCLUDE:symbol pragma above.
@@ -298,9 +297,7 @@ void ThreadLocalPtr::StaticMeta::OnThreadExit(void* ptr) {
}
ThreadLocalPtr::StaticMeta::StaticMeta()
- : next_instance_id_(0),
- head_(this),
- pthread_key_(0) {
+ : next_instance_id_(0), head_(this), pthread_key_(0) {
if (pthread_key_create(&pthread_key_, &OnThreadExit) != 0) {
abort();
}
@@ -345,8 +342,7 @@ void ThreadLocalPtr::StaticMeta::AddThreadData(ThreadData* d) {
head_.prev = d;
}
-void ThreadLocalPtr::StaticMeta::RemoveThreadData(
- ThreadData* d) {
+void ThreadLocalPtr::StaticMeta::RemoveThreadData(ThreadData* d) {
Mutex()->AssertHeld();
d->next->prev = d->prev;
d->prev->next = d->next;
@@ -406,7 +402,7 @@ void* ThreadLocalPtr::StaticMeta::Swap(uint32_t id, void* ptr) {
}
bool ThreadLocalPtr::StaticMeta::CompareAndSwap(uint32_t id, void* ptr,
- void*& expected) {
+ void*& expected) {
auto* tls = GetThreadLocal();
if (UNLIKELY(id >= tls->entries.size())) {
// Need mutex to protect entries access within ReclaimId
@@ -418,7 +414,7 @@ bool ThreadLocalPtr::StaticMeta::CompareAndSwap(uint32_t id, void* ptr,
}
void ThreadLocalPtr::StaticMeta::Scrape(uint32_t id, autovector<void*>* ptrs,
- void* const replacement) {
+ void* const replacement) {
MutexLock l(Mutex());
for (ThreadData* t = head_.next; t != &head_; t = t->next) {
if (id < t->entries.size()) {
@@ -443,9 +439,7 @@ void ThreadLocalPtr::StaticMeta::Fold(uint32_t id, FoldFunc func, void* res) {
}
}
-uint32_t ThreadLocalPtr::TEST_PeekId() {
- return Instance()->PeekId();
-}
+uint32_t ThreadLocalPtr::TEST_PeekId() { return Instance()->PeekId(); }
void ThreadLocalPtr::StaticMeta::SetHandler(uint32_t id, UnrefHandler handler) {
MutexLock l(Mutex());
@@ -504,21 +498,13 @@ ThreadLocalPtr::ThreadLocalPtr(UnrefHandler handler)
}
}
-ThreadLocalPtr::~ThreadLocalPtr() {
- Instance()->ReclaimId(id_);
-}
+ThreadLocalPtr::~ThreadLocalPtr() { Instance()->ReclaimId(id_); }
-void* ThreadLocalPtr::Get() const {
- return Instance()->Get(id_);
-}
+void* ThreadLocalPtr::Get() const { return Instance()->Get(id_); }
-void ThreadLocalPtr::Reset(void* ptr) {
- Instance()->Reset(id_, ptr);
-}
+void ThreadLocalPtr::Reset(void* ptr) { Instance()->Reset(id_, ptr); }
-void* ThreadLocalPtr::Swap(void* ptr) {
- return Instance()->Swap(id_, ptr);
-}
+void* ThreadLocalPtr::Swap(void* ptr) { return Instance()->Swap(id_, ptr); }
bool ThreadLocalPtr::CompareAndSwap(void* ptr, void*& expected) {
return Instance()->CompareAndSwap(id_, ptr, expected);
diff --git a/util/thread_local.h b/util/thread_local.h
index 01790ccc0..fde68f86f 100644
--- a/util/thread_local.h
+++ b/util/thread_local.h
@@ -15,8 +15,8 @@
#include <unordered_map>
#include <vector>
-#include "util/autovector.h"
#include "port/port.h"
+#include "util/autovector.h"
namespace ROCKSDB_NAMESPACE {
@@ -91,8 +91,7 @@ class ThreadLocalPtr {
class StaticMeta;
-private:
-
+ private:
static StaticMeta* Instance();
const uint32_t id_;
diff --git a/util/thread_operation.h b/util/thread_operation.h
index b5d4b6906..c24fccd5c 100644
--- a/util/thread_operation.h
+++ b/util/thread_operation.h
@@ -13,10 +13,10 @@
#pragma once
-#include "rocksdb/thread_status.h"
-
#include <string>
+#include "rocksdb/thread_status.h"
+
namespace ROCKSDB_NAMESPACE {
#ifdef ROCKSDB_USING_THREAD_STATUS
@@ -36,10 +36,9 @@ struct OperationInfo {
// Note that it's not designed to be constant as in the future we
// might consider adding global count to the OperationInfo.
static OperationInfo global_operation_table[] = {
- {ThreadStatus::OP_UNKNOWN, ""},
- {ThreadStatus::OP_COMPACTION, "Compaction"},
- {ThreadStatus::OP_FLUSH, "Flush"}
-};
+ {ThreadStatus::OP_UNKNOWN, ""},
+ {ThreadStatus::OP_COMPACTION, "Compaction"},
+ {ThreadStatus::OP_FLUSH, "Flush"}};
struct OperationStageInfo {
const ThreadStatus::OperationStage stage;
@@ -50,27 +49,22 @@ struct OperationStageInfo {
// Note that the string must be changed accordingly when the
// associated function name changed.
static OperationStageInfo global_op_stage_table[] = {
- {ThreadStatus::STAGE_UNKNOWN, ""},
- {ThreadStatus::STAGE_FLUSH_RUN,
- "FlushJob::Run"},
- {ThreadStatus::STAGE_FLUSH_WRITE_L0,
- "FlushJob::WriteLevel0Table"},
- {ThreadStatus::STAGE_COMPACTION_PREPARE,
- "CompactionJob::Prepare"},
- {ThreadStatus::STAGE_COMPACTION_RUN,
- "CompactionJob::Run"},
- {ThreadStatus::STAGE_COMPACTION_PROCESS_KV,
- "CompactionJob::ProcessKeyValueCompaction"},
- {ThreadStatus::STAGE_COMPACTION_INSTALL,
- "CompactionJob::Install"},
- {ThreadStatus::STAGE_COMPACTION_SYNC_FILE,
- "CompactionJob::FinishCompactionOutputFile"},
- {ThreadStatus::STAGE_PICK_MEMTABLES_TO_FLUSH,
- "MemTableList::PickMemtablesToFlush"},
- {ThreadStatus::STAGE_MEMTABLE_ROLLBACK,
- "MemTableList::RollbackMemtableFlush"},
- {ThreadStatus::STAGE_MEMTABLE_INSTALL_FLUSH_RESULTS,
- "MemTableList::TryInstallMemtableFlushResults"},
+ {ThreadStatus::STAGE_UNKNOWN, ""},
+ {ThreadStatus::STAGE_FLUSH_RUN, "FlushJob::Run"},
+ {ThreadStatus::STAGE_FLUSH_WRITE_L0, "FlushJob::WriteLevel0Table"},
+ {ThreadStatus::STAGE_COMPACTION_PREPARE, "CompactionJob::Prepare"},
+ {ThreadStatus::STAGE_COMPACTION_RUN, "CompactionJob::Run"},
+ {ThreadStatus::STAGE_COMPACTION_PROCESS_KV,
+ "CompactionJob::ProcessKeyValueCompaction"},
+ {ThreadStatus::STAGE_COMPACTION_INSTALL, "CompactionJob::Install"},
+ {ThreadStatus::STAGE_COMPACTION_SYNC_FILE,
+ "CompactionJob::FinishCompactionOutputFile"},
+ {ThreadStatus::STAGE_PICK_MEMTABLES_TO_FLUSH,
+ "MemTableList::PickMemtablesToFlush"},
+ {ThreadStatus::STAGE_MEMTABLE_ROLLBACK,
+ "MemTableList::RollbackMemtableFlush"},
+ {ThreadStatus::STAGE_MEMTABLE_INSTALL_FLUSH_RESULTS,
+ "MemTableList::TryInstallMemtableFlushResults"},
};
// The structure that describes a state.
@@ -85,8 +79,8 @@ struct StateInfo {
// of the current ThreadStatusData will be pointing to one of the
// rows in this global table.
static StateInfo global_state_table[] = {
- {ThreadStatus::STATE_UNKNOWN, ""},
- {ThreadStatus::STATE_MUTEX_WAIT, "Mutex Wait"},
+ {ThreadStatus::STATE_UNKNOWN, ""},
+ {ThreadStatus::STATE_MUTEX_WAIT, "Mutex Wait"},
};
struct OperationProperty {
@@ -95,27 +89,24 @@ struct OperationProperty {
};
static OperationProperty compaction_operation_properties[] = {
- {ThreadStatus::COMPACTION_JOB_ID, "JobID"},
- {ThreadStatus::COMPACTION_INPUT_OUTPUT_LEVEL, "InputOutputLevel"},
- {ThreadStatus::COMPACTION_PROP_FLAGS, "Manual/Deletion/Trivial"},
- {ThreadStatus::COMPACTION_TOTAL_INPUT_BYTES, "TotalInputBytes"},
- {ThreadStatus::COMPACTION_BYTES_READ, "BytesRead"},
- {ThreadStatus::COMPACTION_BYTES_WRITTEN, "BytesWritten"},
+ {ThreadStatus::COMPACTION_JOB_ID, "JobID"},
+ {ThreadStatus::COMPACTION_INPUT_OUTPUT_LEVEL, "InputOutputLevel"},
+ {ThreadStatus::COMPACTION_PROP_FLAGS, "Manual/Deletion/Trivial"},
+ {ThreadStatus::COMPACTION_TOTAL_INPUT_BYTES, "TotalInputBytes"},
+ {ThreadStatus::COMPACTION_BYTES_READ, "BytesRead"},
+ {ThreadStatus::COMPACTION_BYTES_WRITTEN, "BytesWritten"},
};
static OperationProperty flush_operation_properties[] = {
- {ThreadStatus::FLUSH_JOB_ID, "JobID"},
- {ThreadStatus::FLUSH_BYTES_MEMTABLES, "BytesMemtables"},
- {ThreadStatus::FLUSH_BYTES_WRITTEN, "BytesWritten"}
-};
+ {ThreadStatus::FLUSH_JOB_ID, "JobID"},
+ {ThreadStatus::FLUSH_BYTES_MEMTABLES, "BytesMemtables"},
+ {ThreadStatus::FLUSH_BYTES_WRITTEN, "BytesWritten"}};
#else
-struct OperationInfo {
-};
+struct OperationInfo {};
-struct StateInfo {
-};
+struct StateInfo {};
#endif // ROCKSDB_USING_THREAD_STATUS
} // namespace ROCKSDB_NAMESPACE
diff --git a/util/threadpool_imp.cc b/util/threadpool_imp.cc
index e6d88213f..09706cac5 100644
--- a/util/threadpool_imp.cc
+++ b/util/threadpool_imp.cc
@@ -10,12 +10,12 @@
#include "util/threadpool_imp.h"
#ifndef OS_WIN
-# include <unistd.h>
+#include <unistd.h>
#endif
#ifdef OS_LINUX
-# include <sys/syscall.h>
-# include <sys/resource.h>
+#include <sys/resource.h>
+#include <sys/syscall.h>
#endif
#include <stdlib.h>
@@ -44,7 +44,6 @@ void ThreadPoolImpl::PthreadCall(const char* label, int result) {
}
struct ThreadPoolImpl::Impl {
-
Impl();
~Impl();
@@ -61,16 +60,14 @@ struct ThreadPoolImpl::Impl {
void LowerCPUPriority(CpuPriority pri);
- void WakeUpAllThreads() {
- bgsignal_.notify_all();
- }
+ void WakeUpAllThreads() { bgsignal_.notify_all(); }
void BGThread(size_t thread_id);
void StartBGThreads();
void Submit(std::function<void()>&& schedule,
- std::function<void()>&& unschedule, void* tag);
+ std::function<void()>&& unschedule, void* tag);
int UnSchedule(void* arg);
@@ -124,41 +121,41 @@ struct ThreadPoolImpl::Impl {
return released_threads_in_success;
}
-private:
- static void BGThreadWrapper(void* arg);
-
- bool low_io_priority_;
- CpuPriority cpu_priority_;
- Env::Priority priority_;
- Env* env_;
-
- int total_threads_limit_;
- std::atomic_uint queue_len_; // Queue length. Used for stats reporting
- // Number of reserved threads, managed by ReserveThreads(..) and
- // ReleaseThreads(..), if num_waiting_threads_ is no larger than
- // reserved_threads_, its thread will be blocked to ensure the reservation
- // mechanism
- int reserved_threads_;
- // Number of waiting threads (Maximum number of threads that can be
- // reserved), in rare cases, num_waiting_threads_ could be less than
- // reserved_threads due to SetBackgroundThreadInternal or last
- // excessive threads.
- int num_waiting_threads_;
- bool exit_all_threads_;
- bool wait_for_jobs_to_complete_;
-
- // Entry per Schedule()/Submit() call
- struct BGItem {
- void* tag = nullptr;
- std::function<void()> function;
- std::function<void()> unschedFunction;
+ private:
+ static void BGThreadWrapper(void* arg);
+
+ bool low_io_priority_;
+ CpuPriority cpu_priority_;
+ Env::Priority priority_;
+ Env* env_;
+
+ int total_threads_limit_;
+ std::atomic_uint queue_len_; // Queue length. Used for stats reporting
+ // Number of reserved threads, managed by ReserveThreads(..) and
+ // ReleaseThreads(..), if num_waiting_threads_ is no larger than
+ // reserved_threads_, its thread will be blocked to ensure the reservation
+ // mechanism
+ int reserved_threads_;
+ // Number of waiting threads (Maximum number of threads that can be
+ // reserved), in rare cases, num_waiting_threads_ could be less than
+ // reserved_threads due to SetBackgroundThreadInternal or last
+ // excessive threads.
+ int num_waiting_threads_;
+ bool exit_all_threads_;
+ bool wait_for_jobs_to_complete_;
+
+ // Entry per Schedule()/Submit() call
+ struct BGItem {
+ void* tag = nullptr;
+ std::function<void()> function;
+ std::function<void()> unschedFunction;
};
using BGQueue = std::deque<BGItem>;
- BGQueue queue_;
+ BGQueue queue_;
- std::mutex mu_;
- std::condition_variable bgsignal_;
+ std::mutex mu_;
+ std::condition_variable bgsignal_;
std::vector<port::Thread> bgthreads_;
};
@@ -178,11 +175,9 @@ inline ThreadPoolImpl::Impl::Impl()
bgsignal_(),
bgthreads_() {}
-inline
-ThreadPoolImpl::Impl::~Impl() { assert(bgthreads_.size() == 0U); }
+inline ThreadPoolImpl::Impl::~Impl() { assert(bgthreads_.size() == 0U); }
void ThreadPoolImpl::Impl::JoinThreads(bool wait_for_jobs_to_complete) {
-
std::unique_lock<std::mutex> lock(mu_);
assert(!exit_all_threads_);
@@ -208,8 +203,7 @@ void ThreadPoolImpl::Impl::JoinThreads(bool wait_for_jobs_to_complete) {
wait_for_jobs_to_complete_ = false;
}
-inline
-void ThreadPoolImpl::Impl::LowerIOPriority() {
+inline void ThreadPoolImpl::Impl::LowerIOPriority() {
std::lock_guard<std::mutex> lock(mu_);
low_io_priority_ = true;
}
@@ -247,10 +241,9 @@ void ThreadPoolImpl::Impl::BGThread(size_t thread_id) {
if (exit_all_threads_) { // mechanism to let BG threads exit safely
- if (!wait_for_jobs_to_complete_ ||
- queue_.empty()) {
+ if (!wait_for_jobs_to_complete_ || queue_.empty()) {
break;
- }
+ }
} else if (IsLastExcessiveThread(thread_id)) {
// Current thread is the last generated one and is excessive.
// We always terminate excessive thread in the reverse order of
@@ -365,7 +358,7 @@ void ThreadPoolImpl::Impl::BGThreadWrapper(void* arg) {
}
void ThreadPoolImpl::Impl::SetBackgroundThreadsInternal(int num,
- bool allow_reduce) {
+ bool allow_reduce) {
std::lock_guard<std::mutex> lock(mu_);
if (exit_all_threads_) {
return;
@@ -387,7 +380,7 @@ void ThreadPoolImpl::Impl::StartBGThreads() {
// Start background thread if necessary
while ((int)bgthreads_.size() < total_threads_limit_) {
port::Thread p_t(&BGThreadWrapper,
- new BGThreadMetadata(this, bgthreads_.size()));
+ new BGThreadMetadata(this, bgthreads_.size()));
// Set the thread name to aid debugging
#if defined(_GNU_SOURCE) && defined(__GLIBC_PREREQ)
@@ -407,8 +400,8 @@ void ThreadPoolImpl::Impl::StartBGThreads() {
}
void ThreadPoolImpl::Impl::Submit(std::function<void()>&& schedule,
- std::function<void()>&& unschedule, void* tag) {
-
+ std::function<void()>&& unschedule,
+ void* tag) {
std::lock_guard<std::mutex> lock(mu_);
if (exit_all_threads_) {
@@ -426,7 +419,7 @@ void ThreadPoolImpl::Impl::Submit(std::function<void()>&& schedule,
item.unschedFunction = std::move(unschedule);
queue_len_.store(static_cast<unsigned int>(queue_.size()),
- std::memory_order_relaxed);
+ std::memory_order_relaxed);
if (!HasExcessiveThread()) {
// Wake up at least one waiting thread.
@@ -459,11 +452,10 @@ int ThreadPoolImpl::Impl::UnSchedule(void* arg) {
}
}
queue_len_.store(static_cast<unsigned int>(queue_.size()),
- std::memory_order_relaxed);
+ std::memory_order_relaxed);
}
-
- // Run unschedule functions outside the mutex
+ // Run unschedule functions outside the mutex
for (auto& f : candidates) {
f();
}
@@ -471,17 +463,11 @@ int ThreadPoolImpl::Impl::UnSchedule(void* arg) {
return count;
}
-ThreadPoolImpl::ThreadPoolImpl() :
- impl_(new Impl()) {
-}
-
+ThreadPoolImpl::ThreadPoolImpl() : impl_(new Impl()) {}
-ThreadPoolImpl::~ThreadPoolImpl() {
-}
+ThreadPoolImpl::~ThreadPoolImpl() {}
-void ThreadPoolImpl::JoinAllThreads() {
- impl_->JoinThreads(false);
-}
+void ThreadPoolImpl::JoinAllThreads() { impl_->JoinThreads(false); }
void ThreadPoolImpl::SetBackgroundThreads(int num) {
impl_->SetBackgroundThreadsInternal(num, true);
@@ -499,9 +485,7 @@ void ThreadPoolImpl::WaitForJobsAndJoinAllThreads() {
impl_->JoinThreads(true);
}
-void ThreadPoolImpl::LowerIOPriority() {
- impl_->LowerIOPriority();
-}
+void ThreadPoolImpl::LowerIOPriority() { impl_->LowerIOPriority(); }
void ThreadPoolImpl::LowerCPUPriority(CpuPriority pri) {
impl_->LowerCPUPriority(pri);
@@ -516,13 +500,12 @@ void ThreadPoolImpl::SubmitJob(const std::function<void()>& job) {
impl_->Submit(std::move(copy), std::function<void()>(), nullptr);
}
-
void ThreadPoolImpl::SubmitJob(std::function<void()>&& job) {
impl_->Submit(std::move(job), std::function<void()>(), nullptr);
}
-void ThreadPoolImpl::Schedule(void(*function)(void* arg1), void* arg,
- void* tag, void(*unschedFunction)(void* arg)) {
+void ThreadPoolImpl::Schedule(void (*function)(void* arg1), void* arg,
+ void* tag, void (*unschedFunction)(void* arg)) {
if (unschedFunction == nullptr) {
impl_->Submit(std::bind(function, arg), std::function<void()>(), tag);
} else {
@@ -531,9 +514,7 @@ void ThreadPoolImpl::Schedule(void(*function)(void* arg1), void* arg,
}
}
-int ThreadPoolImpl::UnSchedule(void* arg) {
- return impl_->UnSchedule(arg);
-}
+int ThreadPoolImpl::UnSchedule(void* arg) { return impl_->UnSchedule(arg); }
void ThreadPoolImpl::SetHostEnv(Env* env) { impl_->SetHostEnv(env); }
diff --git a/util/threadpool_imp.h b/util/threadpool_imp.h
index e072ae8d3..a5109e38f 100644
--- a/util/threadpool_imp.h
+++ b/util/threadpool_imp.h
@@ -8,11 +8,11 @@
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#pragma once
-#include "rocksdb/threadpool.h"
-#include "rocksdb/env.h"
-
-#include <memory>
#include <functional>
+#include <memory>
+
+#include "rocksdb/env.h"
+#include "rocksdb/threadpool.h"
namespace ROCKSDB_NAMESPACE {
@@ -101,20 +101,20 @@ class ThreadPoolImpl : public ThreadPool {
struct Impl;
private:
-
- // Current public virtual interface does not provide usable
- // functionality and thus can not be used internally to
- // facade different implementations.
- //
- // We propose a pimpl idiom in order to easily replace the thread pool impl
- // w/o touching the header file but providing a different .cc potentially
- // CMake option driven.
- //
- // Another option is to introduce a Env::MakeThreadPool() virtual interface
- // and override the environment. This would require refactoring ThreadPool usage.
- //
- // We can also combine these two approaches
- std::unique_ptr<Impl> impl_;
+ // Current public virtual interface does not provide usable
+ // functionality and thus can not be used internally to
+ // facade different implementations.
+ //
+ // We propose a pimpl idiom in order to easily replace the thread pool impl
+ // w/o touching the header file but providing a different .cc potentially
+ // CMake option driven.
+ //
+ // Another option is to introduce a Env::MakeThreadPool() virtual interface
+ // and override the environment. This would require refactoring ThreadPool
+ // usage.
+ //
+ // We can also combine these two approaches
+ std::unique_ptr<Impl> impl_;
};
} // namespace ROCKSDB_NAMESPACE
diff --git a/util/timer.h b/util/timer.h
index c2fbf869b..db71cefaf 100644
--- a/util/timer.h
+++ b/util/timer.h
@@ -194,7 +194,6 @@ class Timer {
#endif // NDEBUG
private:
-
void Run() {
InstrumentedMutexLock l(&mutex_);
@@ -302,9 +301,7 @@ class Timer {
repeat_every_us(_repeat_every_us),
valid(true) {}
- void Cancel() {
- valid = false;
- }
+ void Cancel() { valid = false; }
bool IsValid() const { return valid; }
};
@@ -318,8 +315,7 @@ class Timer {
}
struct RunTimeOrder {
- bool operator()(const FunctionInfo* f1,
- const FunctionInfo* f2) {
+ bool operator()(const FunctionInfo* f1, const FunctionInfo* f2) {
return f1->next_run_time_us > f2->next_run_time_us;
}
};
@@ -333,9 +329,8 @@ class Timer {
bool running_;
bool executing_task_;
- std::priority_queue<FunctionInfo*,
- std::vector<FunctionInfo*>,
- RunTimeOrder> heap_;
+ std::priority_queue<FunctionInfo*, std::vector<FunctionInfo*>, RunTimeOrder>
+ heap_;
// In addition to providing a mapping from a function name to a function,
// it is also responsible for memory management.
diff --git a/util/timer_queue.h b/util/timer_queue.h
index 3bd517531..36a1744ac 100644
--- a/util/timer_queue.h
+++ b/util/timer_queue.h
@@ -23,6 +23,7 @@
#pragma once
#include <assert.h>
+
#include <chrono>
#include <condition_variable>
#include <functional>
diff --git a/util/timer_queue_test.cc b/util/timer_queue_test.cc
index 5f5f08f21..b3c3768ec 100644
--- a/util/timer_queue_test.cc
+++ b/util/timer_queue_test.cc
@@ -25,6 +25,7 @@
//
#include "util/timer_queue.h"
+
#include <future>
namespace Timing {