Replace most typedef with using= (#8751)

Summary:
Old typedef syntax is confusing

Most but not all changes with

    perl -pi -e 's/typedef (.*) ([a-zA-Z0-9_]+);/using $2 = $1;/g' list_of_files
    make format

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8751

Test Plan: existing

Reviewed By: zhichao-cao

Differential Revision: D30745277

Pulled By: pdillinger

fbshipit-source-id: 6f65f0631c3563382d43347896020413cc2366d9
main
Peter Dillinger 3 years ago committed by Facebook GitHub Bot
parent 55ef8972fc
commit 4750421ece
  1. 2
      cache/clock_cache.cc
  2. 6
      db/compaction/compaction_picker_universal.cc
  3. 2
      db/db_impl/db_impl.cc
  4. 2
      db/db_impl/db_impl.h
  5. 2
      db/db_test.cc
  6. 5
      db/forward_iterator.h
  7. 8
      db/kv_checksum.h
  8. 4
      db/malloc_stats.cc
  9. 2
      db/pinned_iterators_manager.h
  10. 3
      env/env_basic_test.cc
  11. 4
      include/rocksdb/advanced_options.h
  12. 3
      include/rocksdb/cache.h
  13. 2
      include/rocksdb/cleanable.h
  14. 4
      include/rocksdb/db.h
  15. 4
      include/rocksdb/listener.h
  16. 4
      include/rocksdb/memtablerep.h
  17. 2
      include/rocksdb/persistent_cache.h
  18. 2
      include/rocksdb/table_properties.h
  19. 2
      include/rocksdb/transaction_log.h
  20. 2
      include/rocksdb/types.h
  21. 2
      include/rocksdb/utilities/backup_engine.h
  22. 2
      memory/arena.h
  23. 2
      memory/memory_usage.h
  24. 6
      memtable/hash_linklist_rep.cc
  25. 2
      memtable/hash_skiplist_rep.cc
  26. 6
      memtable/inlineskiplist_test.cc
  27. 2
      memtable/skiplist_test.cc
  28. 2
      memtable/vectorrep.cc
  29. 4
      options/cf_options.cc
  30. 2
      options/options_settable_test.cc
  31. 2
      port/port_example.h
  32. 2
      port/port_posix.h
  33. 4
      port/sys_time.h
  34. 4
      port/win/env_win.cc
  35. 2
      port/win/env_win.h
  36. 4
      port/win/port_win.h
  37. 22
      port/win/win_thread.h
  38. 8
      table/block_based/block_based_table_builder.cc
  39. 2
      table/block_based/block_based_table_reader.h
  40. 4
      table/merging_iterator.cc
  41. 12
      table/multiget_context.h
  42. 34
      util/autovector.h
  43. 2
      util/autovector_test.cc
  44. 4
      util/crc32c.cc
  45. 2
      util/kv_map.h
  46. 6
      util/murmurhash.h
  47. 4
      util/thread_local.h
  48. 2
      utilities/cassandra/format.h
  49. 7
      utilities/env_librados_test.cc
  50. 2
      utilities/merge_operators/string_append/stringappend_test.cc
  51. 2
      utilities/persistent_cache/block_cache_tier_file.h
  52. 8
      utilities/persistent_cache/block_cache_tier_metadata.h
  53. 4
      utilities/persistent_cache/hash_table_evictable.h
  54. 2
      utilities/persistent_cache/persistent_cache_tier.h
  55. 4
      utilities/persistent_cache/volatile_tier_impl.h
  56. 2
      utilities/transactions/lock/point/point_lock_manager.h
  57. 2
      utilities/transactions/lock/point/point_lock_manager_test.h
  58. 2
      utilities/ttl/ttl_test.cc
  59. 4
      utilities/write_batch_with_index/write_batch_with_index_internal.h

@ -260,7 +260,7 @@ struct CleanupContext {
class ClockCacheShard final : public CacheShard { class ClockCacheShard final : public CacheShard {
public: public:
// Hash map type. // Hash map type.
typedef tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey> HashTable; using HashTable = tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey>;
ClockCacheShard(); ClockCacheShard();
~ClockCacheShard() override; ~ClockCacheShard() override;

@ -157,9 +157,9 @@ struct SmallestKeyHeapComparator {
const Comparator* ucmp_; const Comparator* ucmp_;
}; };
typedef std::priority_queue<InputFileInfo, std::vector<InputFileInfo>, using SmallestKeyHeap =
SmallestKeyHeapComparator> std::priority_queue<InputFileInfo, std::vector<InputFileInfo>,
SmallestKeyHeap; SmallestKeyHeapComparator>;
// This function creates the heap that is used to find if the files are // This function creates the heap that is used to find if the files are
// overlapping during universal compaction when the allow_trivial_move // overlapping during universal compaction when the allow_trivial_move

@ -3116,7 +3116,7 @@ SnapshotImpl* DBImpl::GetSnapshotImpl(bool is_write_conflict_boundary,
} }
namespace { namespace {
typedef autovector<ColumnFamilyData*, 2> CfdList; using CfdList = autovector<ColumnFamilyData*, 2>;
bool CfdListContains(const CfdList& list, ColumnFamilyData* cfd) { bool CfdListContains(const CfdList& list, ColumnFamilyData* cfd) {
for (const ColumnFamilyData* t : list) { for (const ColumnFamilyData* t : list) {
if (t == cfd) { if (t == cfd) {

@ -1753,7 +1753,7 @@ class DBImpl : public DB {
// specified value, this flush request is considered to have completed its // specified value, this flush request is considered to have completed its
// work of flushing this column family. After completing the work for all // work of flushing this column family. After completing the work for all
// column families in this request, this flush is considered complete. // column families in this request, this flush is considered complete.
typedef std::vector<std::pair<ColumnFamilyData*, uint64_t>> FlushRequest; using FlushRequest = std::vector<std::pair<ColumnFamilyData*, uint64_t>>;
void GenerateFlushRequest(const autovector<ColumnFamilyData*>& cfds, void GenerateFlushRequest(const autovector<ColumnFamilyData*>& cfds,
FlushRequest* req); FlushRequest* req);

@ -2812,7 +2812,7 @@ TEST_F(DBTest, GroupCommitTest) {
#endif // TRAVIS #endif // TRAVIS
namespace { namespace {
typedef std::map<std::string, std::string> KVMap; using KVMap = std::map<std::string, std::string>;
} }
class ModelDB : public DB { class ModelDB : public DB {

@ -39,8 +39,9 @@ class MinIterComparator {
const Comparator* comparator_; const Comparator* comparator_;
}; };
typedef std::priority_queue<InternalIterator*, std::vector<InternalIterator*>, using MinIterHeap =
MinIterComparator> MinIterHeap; std::priority_queue<InternalIterator*, std::vector<InternalIterator*>,
MinIterComparator>;
/** /**
* ForwardIterator is a special type of iterator that only supports Seek() * ForwardIterator is a special type of iterator that only supports Seek()

@ -49,10 +49,10 @@ template <typename T>
class ProtectionInfoKVOTS; class ProtectionInfoKVOTS;
// Aliases for 64-bit protection infos. // Aliases for 64-bit protection infos.
typedef ProtectionInfo<uint64_t> ProtectionInfo64; using ProtectionInfo64 = ProtectionInfo<uint64_t>;
typedef ProtectionInfoKVOT<uint64_t> ProtectionInfoKVOT64; using ProtectionInfoKVOT64 = ProtectionInfoKVOT<uint64_t>;
typedef ProtectionInfoKVOTC<uint64_t> ProtectionInfoKVOTC64; using ProtectionInfoKVOTC64 = ProtectionInfoKVOTC<uint64_t>;
typedef ProtectionInfoKVOTS<uint64_t> ProtectionInfoKVOTS64; using ProtectionInfoKVOTS64 = ProtectionInfoKVOTS<uint64_t>;
template <typename T> template <typename T>
class ProtectionInfo { class ProtectionInfo {

@ -19,10 +19,10 @@ namespace ROCKSDB_NAMESPACE {
#ifdef ROCKSDB_JEMALLOC #ifdef ROCKSDB_JEMALLOC
typedef struct { struct MallocStatus {
char* cur; char* cur;
char* end; char* end;
} MallocStatus; };
static void GetJemallocStatus(void* mstat_arg, const char* status) { static void GetJemallocStatus(void* mstat_arg, const char* status) {
MallocStatus* mstat = reinterpret_cast<MallocStatus*>(mstat_arg); MallocStatus* mstat = reinterpret_cast<MallocStatus*>(mstat_arg);

@ -43,7 +43,7 @@ class PinnedIteratorsManager : public Cleanable {
} }
} }
typedef void (*ReleaseFunction)(void* arg1); using ReleaseFunction = void (*)(void* arg1);
void PinPtr(void* ptr, ReleaseFunction release_func) { void PinPtr(void* ptr, ReleaseFunction release_func) {
assert(pinning_enabled); assert(pinning_enabled);
if (ptr == nullptr) { if (ptr == nullptr) {

@ -17,8 +17,9 @@
#include "test_util/testharness.h" #include "test_util/testharness.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
typedef Env* CreateEnvFunc();
namespace { namespace {
using CreateEnvFunc = Env*();
// These functions are used to create the various environments under which this // These functions are used to create the various environments under which this
// test can execute. These functions are used to allow the test cases to be // test can execute. These functions are used to allow the test cases to be
// created without the Env being initialized, thereby eliminating a potential // created without the Env being initialized, thereby eliminating a potential

@ -650,8 +650,8 @@ struct AdvancedColumnFamilyOptions {
// the tables. // the tables.
// Default: empty vector -- no user-defined statistics collection will be // Default: empty vector -- no user-defined statistics collection will be
// performed. // performed.
typedef std::vector<std::shared_ptr<TablePropertiesCollectorFactory>> using TablePropertiesCollectorFactories =
TablePropertiesCollectorFactories; std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>;
TablePropertiesCollectorFactories table_properties_collector_factories; TablePropertiesCollectorFactories table_properties_collector_factories;
// Maximum number of successive merge operations on a key in the memtable. // Maximum number of successive merge operations on a key in the memtable.

@ -202,9 +202,6 @@ class Cache {
// takes in a buffer from the NVM cache and constructs an object using // takes in a buffer from the NVM cache and constructs an object using
// it. The callback doesn't have ownership of the buffer and should // it. The callback doesn't have ownership of the buffer and should
// copy the contents into its own buffer. // copy the contents into its own buffer.
// typedef std::function<Status(void* buf, size_t size, void** out_obj,
// size_t* charge)>
// CreateCallback;
using CreateCallback = std::function<Status(void* buf, size_t size, using CreateCallback = std::function<Status(void* buf, size_t size,
void** out_obj, size_t* charge)>; void** out_obj, size_t* charge)>;

@ -30,7 +30,7 @@ class Cleanable {
// //
// Note that unlike all of the preceding methods, this method is // Note that unlike all of the preceding methods, this method is
// not abstract and therefore clients should not override it. // not abstract and therefore clients should not override it.
typedef void (*CleanupFunction)(void* arg1, void* arg2); using CleanupFunction = void (*)(void* arg1, void* arg2);
void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2); void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2);
void DelegateCleanupsTo(Cleanable* other); void DelegateCleanupsTo(Cleanable* other);
// DoCleanup and also resets the pointers for reuse // DoCleanup and also resets the pointers for reuse

@ -136,8 +136,8 @@ struct GetMergeOperandsOptions {
// A collections of table properties objects, where // A collections of table properties objects, where
// key: is the table's file name. // key: is the table's file name.
// value: the table properties object of the given table. // value: the table properties object of the given table.
typedef std::unordered_map<std::string, std::shared_ptr<const TableProperties>> using TablePropertiesCollection =
TablePropertiesCollection; std::unordered_map<std::string, std::shared_ptr<const TableProperties>>;
// A DB is a persistent, versioned ordered map from keys to values. // A DB is a persistent, versioned ordered map from keys to values.
// A DB is safe for concurrent access from multiple threads without // A DB is safe for concurrent access from multiple threads without

@ -21,8 +21,8 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
typedef std::unordered_map<std::string, std::shared_ptr<const TableProperties>> using TablePropertiesCollection =
TablePropertiesCollection; std::unordered_map<std::string, std::shared_ptr<const TableProperties>>;
class DB; class DB;
class ColumnFamilyHandle; class ColumnFamilyHandle;

@ -51,7 +51,7 @@ class LookupKey;
class SliceTransform; class SliceTransform;
class Logger; class Logger;
typedef void* KeyHandle; using KeyHandle = void*;
extern Slice GetLengthPrefixedSlice(const char* data); extern Slice GetLengthPrefixedSlice(const char* data);
@ -61,7 +61,7 @@ class MemTableRep {
// concatenated with values. // concatenated with values.
class KeyComparator { class KeyComparator {
public: public:
typedef ROCKSDB_NAMESPACE::Slice DecodedType; using DecodedType = ROCKSDB_NAMESPACE::Slice;
virtual DecodedType decode_key(const char* key) const { virtual DecodedType decode_key(const char* key) const {
// The format of key is frozen and can be treated as a part of the API // The format of key is frozen and can be treated as a part of the API

@ -24,7 +24,7 @@ namespace ROCKSDB_NAMESPACE {
// cache interface is specifically designed for persistent read cache. // cache interface is specifically designed for persistent read cache.
class PersistentCache { class PersistentCache {
public: public:
typedef std::vector<std::map<std::string, double>> StatsType; using StatsType = std::vector<std::map<std::string, double>>;
virtual ~PersistentCache() {} virtual ~PersistentCache() {}

@ -26,7 +26,7 @@ namespace ROCKSDB_NAMESPACE {
// ++pos) { // ++pos) {
// ... // ...
// } // }
typedef std::map<std::string, std::string> UserCollectedProperties; using UserCollectedProperties = std::map<std::string, std::string>;
// table properties' human-readable names in the property block. // table properties' human-readable names in the property block.
struct TablePropertiesNames { struct TablePropertiesNames {

@ -14,7 +14,7 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
class LogFile; class LogFile;
typedef std::vector<std::unique_ptr<LogFile>> VectorLogPtr; using VectorLogPtr = std::vector<std::unique_ptr<LogFile>>;
enum WalFileType { enum WalFileType {
/* Indicates that WAL file is in archive directory. WAL files are moved from /* Indicates that WAL file is in archive directory. WAL files are moved from

@ -15,7 +15,7 @@ namespace ROCKSDB_NAMESPACE {
using ColumnFamilyId = uint32_t; using ColumnFamilyId = uint32_t;
// Represents a sequence number in a WAL file. // Represents a sequence number in a WAL file.
typedef uint64_t SequenceNumber; using SequenceNumber = uint64_t;
const SequenceNumber kMinUnCommittedSeq = 1; // 0 is always committed const SequenceNumber kMinUnCommittedSeq = 1; // 0 is always committed

@ -285,7 +285,7 @@ struct BackupFileInfo {
uint64_t size; uint64_t size;
}; };
typedef uint32_t BackupID; using BackupID = uint32_t;
struct BackupInfo { struct BackupInfo {
BackupID backup_id = 0U; BackupID backup_id = 0U;

@ -86,7 +86,7 @@ class Arena : public Allocator {
// Number of bytes allocated in one block // Number of bytes allocated in one block
const size_t kBlockSize; const size_t kBlockSize;
// Array of new[] allocated memory blocks // Array of new[] allocated memory blocks
typedef std::vector<char*> Blocks; using Blocks = std::vector<char*>;
Blocks blocks_; Blocks blocks_;
struct MmapInfo { struct MmapInfo {

@ -14,7 +14,7 @@ namespace ROCKSDB_NAMESPACE {
template <class Key, class Value, class Hash> template <class Key, class Value, class Hash>
size_t ApproximateMemoryUsage( size_t ApproximateMemoryUsage(
const std::unordered_map<Key, Value, Hash>& umap) { const std::unordered_map<Key, Value, Hash>& umap) {
typedef std::unordered_map<Key, Value, Hash> Map; using Map = std::unordered_map<Key, Value, Hash>;
return sizeof(umap) + return sizeof(umap) +
// Size of all items plus a next pointer for each item. // Size of all items plus a next pointer for each item.
(sizeof(typename Map::value_type) + sizeof(void*)) * umap.size() + (sizeof(typename Map::value_type) + sizeof(void*)) * umap.size() +

@ -22,9 +22,9 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
typedef const char* Key; using Key = const char*;
typedef SkipList<Key, const MemTableRep::KeyComparator&> MemtableSkipList; using MemtableSkipList = SkipList<Key, const MemTableRep::KeyComparator&>;
typedef std::atomic<void*> Pointer; using Pointer = std::atomic<void*>;
// A data structure used as the header of a link list of a hash bucket. // A data structure used as the header of a link list of a hash bucket.
struct BucketHeader { struct BucketHeader {

@ -46,7 +46,7 @@ class HashSkipListRep : public MemTableRep {
private: private:
friend class DynamicIterator; friend class DynamicIterator;
typedef SkipList<const char*, const MemTableRep::KeyComparator&> Bucket; using Bucket = SkipList<const char*, const MemTableRep::KeyComparator&>;
size_t bucket_size_; size_t bucket_size_;

@ -19,7 +19,7 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
// Our test skip list stores 8-byte unsigned integers // Our test skip list stores 8-byte unsigned integers
typedef uint64_t Key; using Key = uint64_t;
static const char* Encode(const uint64_t* key) { static const char* Encode(const uint64_t* key) {
return reinterpret_cast<const char*>(key); return reinterpret_cast<const char*>(key);
@ -32,7 +32,7 @@ static Key Decode(const char* key) {
} }
struct TestComparator { struct TestComparator {
typedef Key DecodedType; using DecodedType = Key;
static DecodedType decode_key(const char* b) { static DecodedType decode_key(const char* b) {
return Decode(b); return Decode(b);
@ -59,7 +59,7 @@ struct TestComparator {
} }
}; };
typedef InlineSkipList<TestComparator> TestInlineSkipList; using TestInlineSkipList = InlineSkipList<TestComparator>;
class InlineSkipTest : public testing::Test { class InlineSkipTest : public testing::Test {
public: public:

@ -17,7 +17,7 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
typedef uint64_t Key; using Key = uint64_t;
struct TestComparator { struct TestComparator {
int operator()(const Key& a, const Key& b) const { int operator()(const Key& a, const Key& b) const {

@ -98,7 +98,7 @@ class VectorRep : public MemTableRep {
private: private:
friend class Iterator; friend class Iterator;
typedef std::vector<const char*> Bucket; using Bucket = std::vector<const char*>;
std::shared_ptr<Bucket> bucket_; std::shared_ptr<Bucket> bucket_;
mutable port::RWMutex rwlock_; mutable port::RWMutex rwlock_;
bool immutable_; bool immutable_;

@ -479,8 +479,8 @@ static std::unordered_map<std::string, OptionTypeInfo>
/* not yet supported /* not yet supported
CompressionOptions compression_opts; CompressionOptions compression_opts;
TablePropertiesCollectorFactories table_properties_collector_factories; TablePropertiesCollectorFactories table_properties_collector_factories;
typedef std::vector<std::shared_ptr<TablePropertiesCollectorFactory>> using TablePropertiesCollectorFactories =
TablePropertiesCollectorFactories; std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>;
UpdateStatus (*inplace_callback)(char* existing_value, UpdateStatus (*inplace_callback)(char* existing_value,
uint34_t* existing_value_size, uint34_t* existing_value_size,
Slice delta_value, Slice delta_value,

@ -41,7 +41,7 @@ class OptionsSettableTest : public testing::Test {
}; };
const char kSpecialChar = 'z'; const char kSpecialChar = 'z';
typedef std::vector<std::pair<size_t, size_t>> OffsetGap; using OffsetGap = std::vector<std::pair<size_t, size_t>>;
void FillWithSpecialChar(char* start_ptr, size_t total_size, void FillWithSpecialChar(char* start_ptr, size_t total_size,
const OffsetGap& excluded, const OffsetGap& excluded,

@ -70,7 +70,7 @@ class CondVar {
// static void Initializer() { ... do something ...; } // static void Initializer() { ... do something ...; }
// ... // ...
// port::InitOnce(&init_control, &Initializer); // port::InitOnce(&init_control, &Initializer);
typedef intptr_t OnceType; using OnceType = intptr_t;
#define LEVELDB_ONCE_INIT 0 #define LEVELDB_ONCE_INIT 0
extern void InitOnce(port::OnceType*, void (*initializer)()); extern void InitOnce(port::OnceType*, void (*initializer)());

@ -177,7 +177,7 @@ static inline void AsmVolatilePause() {
// Returns -1 if not available on this platform // Returns -1 if not available on this platform
extern int PhysicalCoreID(); extern int PhysicalCoreID();
typedef pthread_once_t OnceType; using OnceType = pthread_once_t;
#define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT #define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT
extern void InitOnce(OnceType* once, void (*initializer)()); extern void InitOnce(OnceType* once, void (*initializer)());

@ -23,10 +23,10 @@ namespace ROCKSDB_NAMESPACE {
namespace port { namespace port {
// Avoid including winsock2.h for this definition // Avoid including winsock2.h for this definition
typedef struct timeval { struct timeval {
long tv_sec; long tv_sec;
long tv_usec; long tv_usec;
} timeval; };
void gettimeofday(struct timeval* tv, struct timezone* tz); void gettimeofday(struct timeval* tv, struct timezone* tz);

@ -53,10 +53,10 @@ static const size_t kSectorSize = 512;
// RAII helpers for HANDLEs // RAII helpers for HANDLEs
const auto CloseHandleFunc = [](HANDLE h) { ::CloseHandle(h); }; const auto CloseHandleFunc = [](HANDLE h) { ::CloseHandle(h); };
typedef std::unique_ptr<void, decltype(CloseHandleFunc)> UniqueCloseHandlePtr; using UniqueCloseHandlePtr = std::unique_ptr<void, decltype(CloseHandleFunc)>;
const auto FindCloseFunc = [](HANDLE h) { ::FindClose(h); }; const auto FindCloseFunc = [](HANDLE h) { ::FindClose(h); };
typedef std::unique_ptr<void, decltype(FindCloseFunc)> UniqueFindClosePtr; using UniqueFindClosePtr = std::unique_ptr<void, decltype(FindCloseFunc)>;
void WinthreadCall(const char* label, std::error_code result) { void WinthreadCall(const char* label, std::error_code result) {
if (0 != result.value()) { if (0 != result.value()) {

@ -96,7 +96,7 @@ class WinClock : public SystemClock {
uint64_t GetPerfCounterFrequency() const { return perf_counter_frequency_; } uint64_t GetPerfCounterFrequency() const { return perf_counter_frequency_; }
private: private:
typedef VOID(WINAPI* FnGetSystemTimePreciseAsFileTime)(LPFILETIME); using FnGetSystemTimePreciseAsFileTime = VOID(WINAPI*)(LPFILETIME);
uint64_t perf_counter_frequency_; uint64_t perf_counter_frequency_;
uint64_t nano_seconds_per_period_; uint64_t nano_seconds_per_period_;

@ -47,7 +47,7 @@
#undef DeleteFile #undef DeleteFile
#ifndef _SSIZE_T_DEFINED #ifndef _SSIZE_T_DEFINED
typedef SSIZE_T ssize_t; using ssize_t = SSIZE_T;
#endif #endif
// size_t printf formatting named in the manner of C99 standard formatting // size_t printf formatting named in the manner of C99 standard formatting
@ -292,7 +292,7 @@ static inline void AsmVolatilePause() {
extern int PhysicalCoreID(); extern int PhysicalCoreID();
// For Thread Local Storage abstraction // For Thread Local Storage abstraction
typedef DWORD pthread_key_t; using pthread_key_t = DWORD;
inline int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)) { inline int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)) {
// Not used // Not used

@ -29,7 +29,6 @@ namespace port {
// - This implements Pimpl so we can easily replace the guts of the // - This implements Pimpl so we can easily replace the guts of the
// object in our private version if necessary. // object in our private version if necessary.
class WindowsThread { class WindowsThread {
struct Data; struct Data;
std::shared_ptr<Data> data_; std::shared_ptr<Data> data_;
@ -37,9 +36,8 @@ class WindowsThread {
void Init(std::function<void()>&&); void Init(std::function<void()>&&);
public: public:
using native_handle_type = void*;
typedef void* native_handle_type;
// Construct with no thread // Construct with no thread
WindowsThread(); WindowsThread();
@ -68,17 +66,12 @@ public:
// dependent type that both checks the signature conformance to ensure // dependent type that both checks the signature conformance to ensure
// that all of the necessary arguments are provided and allows pimpl // that all of the necessary arguments are provided and allows pimpl
// implementation. // implementation.
template<class Fn, template <class Fn, class... Args,
class... Args, class = typename std::enable_if<!std::is_same<
class = typename std::enable_if< typename std::decay<Fn>::type, WindowsThread>::value>::type>
!std::is_same<typename std::decay<Fn>::type, explicit WindowsThread(Fn&& fx, Args&&... ax) : WindowsThread() {
WindowsThread>::value>::type>
explicit WindowsThread(Fn&& fx, Args&&... ax) :
WindowsThread() {
// Use binder to create a single callable entity // Use binder to create a single callable entity
auto binder = std::bind(std::forward<Fn>(fx), auto binder = std::bind(std::forward<Fn>(fx), std::forward<Args>(ax)...);
std::forward<Args>(ax)...);
// Use std::function to take advantage of the type erasure // Use std::function to take advantage of the type erasure
// so we can still hide implementation within pimpl // so we can still hide implementation within pimpl
// This also makes sure that the binder signature is compliant // This also makes sure that the binder signature is compliant
@ -87,7 +80,6 @@ public:
Init(std::move(target)); Init(std::move(target));
} }
~WindowsThread(); ~WindowsThread();
WindowsThread(const WindowsThread&) = delete; WindowsThread(const WindowsThread&) = delete;

@ -589,11 +589,11 @@ struct BlockBasedTableBuilder::ParallelCompressionRep {
// Use a vector of BlockRep as a buffer for a determined number // Use a vector of BlockRep as a buffer for a determined number
// of BlockRep structures. All data referenced by pointers in // of BlockRep structures. All data referenced by pointers in
// BlockRep will be freed when this vector is destructed. // BlockRep will be freed when this vector is destructed.
typedef std::vector<BlockRep> BlockRepBuffer; using BlockRepBuffer = std::vector<BlockRep>;
BlockRepBuffer block_rep_buf; BlockRepBuffer block_rep_buf;
// Use a thread-safe queue for concurrent access from block // Use a thread-safe queue for concurrent access from block
// building thread and writer thread. // building thread and writer thread.
typedef WorkQueue<BlockRep*> BlockRepPool; using BlockRepPool = WorkQueue<BlockRep*>;
BlockRepPool block_rep_pool; BlockRepPool block_rep_pool;
// Use BlockRepSlot to keep block order in write thread. // Use BlockRepSlot to keep block order in write thread.
@ -617,7 +617,7 @@ struct BlockBasedTableBuilder::ParallelCompressionRep {
// Compression queue will pass references to BlockRep in block_rep_buf, // Compression queue will pass references to BlockRep in block_rep_buf,
// and those references are always valid before the destruction of // and those references are always valid before the destruction of
// block_rep_buf. // block_rep_buf.
typedef WorkQueue<BlockRep*> CompressQueue; using CompressQueue = WorkQueue<BlockRep*>;
CompressQueue compress_queue; CompressQueue compress_queue;
std::vector<port::Thread> compress_thread_pool; std::vector<port::Thread> compress_thread_pool;
@ -625,7 +625,7 @@ struct BlockBasedTableBuilder::ParallelCompressionRep {
// and those references are always valid before the corresponding // and those references are always valid before the corresponding
// BlockRep::slot is destructed, which is before the destruction of // BlockRep::slot is destructed, which is before the destruction of
// block_rep_buf. // block_rep_buf.
typedef WorkQueue<BlockRepSlot*> WriteQueue; using WriteQueue = WorkQueue<BlockRepSlot*>;
WriteQueue write_queue; WriteQueue write_queue;
std::unique_ptr<port::Thread> write_thread; std::unique_ptr<port::Thread> write_thread;

@ -41,7 +41,7 @@ struct EnvOptions;
struct ReadOptions; struct ReadOptions;
class GetContext; class GetContext;
typedef std::vector<std::pair<std::string, std::string>> KVPairBlock; using KVPairBlock = std::vector<std::pair<std::string, std::string>>;
// Reader class for BlockBasedTable format. // Reader class for BlockBasedTable format.
// For the format of BlockBasedTable refer to // For the format of BlockBasedTable refer to

@ -28,8 +28,8 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
// Without anonymous namespace here, we fail the warning -Wmissing-prototypes // Without anonymous namespace here, we fail the warning -Wmissing-prototypes
namespace { namespace {
typedef BinaryHeap<IteratorWrapper*, MaxIteratorComparator> MergerMaxIterHeap; using MergerMaxIterHeap = BinaryHeap<IteratorWrapper*, MaxIteratorComparator>;
typedef BinaryHeap<IteratorWrapper*, MinIteratorComparator> MergerMinIterHeap; using MergerMinIterHeap = BinaryHeap<IteratorWrapper*, MinIteratorComparator>;
} // namespace } // namespace
const size_t kNumIterReserve = 4; const size_t kNumIterReserve = 4;

@ -158,12 +158,12 @@ class MultiGetContext {
class Iterator { class Iterator {
public: public:
// -- iterator traits // -- iterator traits
typedef Iterator self_type; using self_type = Iterator;
typedef KeyContext value_type; using value_type = KeyContext;
typedef KeyContext& reference; using reference = KeyContext&;
typedef KeyContext* pointer; using pointer = KeyContext*;
typedef int difference_type; using difference_type = int;
typedef std::forward_iterator_tag iterator_category; using iterator_category = std::forward_iterator_tag;
Iterator(const Range* range, size_t idx) Iterator(const Range* range, size_t idx)
: range_(range), ctx_(range->ctx_), index_(idx) { : range_(range), ctx_(range->ctx_), index_(idx) {

@ -51,25 +51,25 @@ template <class T, size_t kSize = 8>
class autovector { class autovector {
public: public:
// General STL-style container member types. // General STL-style container member types.
typedef T value_type; using value_type = T;
typedef typename std::vector<T>::difference_type difference_type; using difference_type = typename std::vector<T>::difference_type;
typedef typename std::vector<T>::size_type size_type; using size_type = typename std::vector<T>::size_type;
typedef value_type& reference; using reference = value_type&;
typedef const value_type& const_reference; using const_reference = const value_type&;
typedef value_type* pointer; using pointer = value_type*;
typedef const value_type* const_pointer; using const_pointer = const value_type*;
// This class is the base for regular/const iterator // This class is the base for regular/const iterator
template <class TAutoVector, class TValueType> template <class TAutoVector, class TValueType>
class iterator_impl { class iterator_impl {
public: public:
// -- iterator traits // -- iterator traits
typedef iterator_impl<TAutoVector, TValueType> self_type; using self_type = iterator_impl<TAutoVector, TValueType>;
typedef TValueType value_type; using value_type = TValueType;
typedef TValueType& reference; using reference = TValueType&;
typedef TValueType* pointer; using pointer = TValueType*;
typedef typename TAutoVector::difference_type difference_type; using difference_type = typename TAutoVector::difference_type;
typedef std::random_access_iterator_tag iterator_category; using iterator_category = std::random_access_iterator_tag;
iterator_impl(TAutoVector* vect, size_t index) iterator_impl(TAutoVector* vect, size_t index)
: vect_(vect), index_(index) {}; : vect_(vect), index_(index) {};
@ -175,10 +175,10 @@ class autovector {
size_t index_ = 0; size_t index_ = 0;
}; };
typedef iterator_impl<autovector, value_type> iterator; using iterator = iterator_impl<autovector, value_type>;
typedef iterator_impl<const autovector, const value_type> const_iterator; using const_iterator = iterator_impl<const autovector, const value_type>;
typedef std::reverse_iterator<iterator> reverse_iterator; using reverse_iterator = std::reverse_iterator<iterator>;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; using const_reverse_iterator = std::reverse_iterator<const_iterator>;
autovector() : values_(reinterpret_cast<pointer>(buf_)) {} autovector() : values_(reinterpret_cast<pointer>(buf_)) {}

@ -64,7 +64,7 @@ TEST_F(AutoVectorTest, PushBackAndPopBack) {
} }
TEST_F(AutoVectorTest, EmplaceBack) { TEST_F(AutoVectorTest, EmplaceBack) {
typedef std::pair<size_t, std::string> ValType; using ValType = std::pair<size_t, std::string>;
autovector<ValType, kSize> vec; autovector<ValType, kSize> vec;
for (size_t i = 0; i < 1000 * kSize; ++i) { for (size_t i = 0; i < 1000 * kSize; ++i) {

@ -459,7 +459,7 @@ static bool isPCLMULQDQ() {
#endif // HAVE_POWER8 #endif // HAVE_POWER8
#endif // HAVE_ARM64_CRC #endif // HAVE_ARM64_CRC
typedef uint32_t (*Function)(uint32_t, const char*, size_t); using Function = uint32_t (*)(uint32_t, const char*, size_t);
#if defined(HAVE_POWER8) && defined(HAS_ALTIVEC) #if defined(HAVE_POWER8) && defined(HAS_ALTIVEC)
uint32_t ExtendPPCImpl(uint32_t crc, const char *buf, size_t size) { uint32_t ExtendPPCImpl(uint32_t crc, const char *buf, size_t size) {
@ -1320,7 +1320,7 @@ struct gf_powers_memo<0, m> {
template <typename T, T... Ints> template <typename T, T... Ints>
struct integer_sequence { struct integer_sequence {
typedef T value_type; using value_type = T;
static constexpr size_t size() { return sizeof...(Ints); } static constexpr size_t size() { return sizeof...(Ints); }
}; };

@ -28,6 +28,6 @@ struct LessOfComparator {
const Comparator* cmp; const Comparator* cmp;
}; };
typedef std::map<std::string, std::string, LessOfComparator> KVMap; using KVMap = std::map<std::string, std::string, LessOfComparator>;
} }
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

@ -17,19 +17,19 @@
#define MURMUR_HASH MurmurHash64A #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 #define MurmurHash MurmurHash64A
typedef uint64_t murmur_t; using murmur_t = uint64_t;
#elif defined(__i386__) #elif defined(__i386__)
#define MURMUR_HASH MurmurHash2 #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 #define MurmurHash MurmurHash2
typedef unsigned int murmur_t; using murmur_t = unsigned int;
#else #else
#define MURMUR_HASH MurmurHashNeutral2 #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 #define MurmurHash MurmurHashNeutral2
typedef unsigned int murmur_t; using murmur_t = unsigned int;
#endif #endif
// Allow slice to be hashable by murmur hash. // Allow slice to be hashable by murmur hash.

@ -31,7 +31,7 @@ namespace ROCKSDB_NAMESPACE {
// is needed to avoid deadlocks. In particular, the handler shouldn't lock any // is needed to avoid deadlocks. In particular, the handler shouldn't lock any
// mutexes and shouldn't call any methods of any ThreadLocalPtr instances, // mutexes and shouldn't call any methods of any ThreadLocalPtr instances,
// unless you know what you're doing. // unless you know what you're doing.
typedef void (*UnrefHandler)(void* ptr); using UnrefHandler = void (*)(void* ptr);
// ThreadLocalPtr stores only values of pointer type. Different from // ThreadLocalPtr stores only values of pointer type. Different from
// the usual thread-local-storage, ThreadLocalPtr has the ability to // the usual thread-local-storage, ThreadLocalPtr has the ability to
@ -69,7 +69,7 @@ class ThreadLocalPtr {
// data for all existing threads // data for all existing threads
void Scrape(autovector<void*>* ptrs, void* const replacement); void Scrape(autovector<void*>* ptrs, void* const replacement);
typedef std::function<void(void*, void*)> FoldFunc; using FoldFunc = std::function<void(void*, void*)>;
// Update res by applying func on each thread-local value. Holds a lock that // Update res by applying func on each thread-local value. Holds a lock that
// prevents unref handler from running during this call, but clients must // prevents unref handler from running during this call, but clients must
// still provide external synchronization since the owning thread can // still provide external synchronization since the owning thread can

@ -142,7 +142,7 @@ private:
std::chrono::seconds Ttl() const; std::chrono::seconds Ttl() const;
}; };
typedef std::vector<std::shared_ptr<ColumnBase>> Columns; using Columns = std::vector<std::shared_ptr<ColumnBase>>;
class RowValue { class RowValue {
public: public:

@ -20,9 +20,10 @@
#include "rocksdb/utilities/transaction_db.h" #include "rocksdb/utilities/transaction_db.h"
class Timer { class Timer {
typedef std::chrono::high_resolution_clock high_resolution_clock; using high_resolution_clock = std::chrono::high_resolution_clock;
typedef std::chrono::milliseconds milliseconds; using milliseconds = std::chrono::milliseconds;
public:
public:
explicit Timer(bool run = false) explicit Timer(bool run = false)
{ {
if (run) if (run)

@ -149,7 +149,7 @@ class StringAppendOperatorTest : public testing::Test,
StringAppendOperatorTest::SetOpenDbFunction(&OpenNormalDb); StringAppendOperatorTest::SetOpenDbFunction(&OpenNormalDb);
} }
typedef std::shared_ptr<DB> (*OpenFuncPtr)(const std::string&); using OpenFuncPtr = std::shared_ptr<DB> (*)(const std::string&);
// Allows user to open databases with different configurations. // Allows user to open databases with different configurations.
// e.g.: Can open a DB or a TtlDB, etc. // e.g.: Can open a DB or a TtlDB, etc.

@ -65,7 +65,7 @@ struct LogicalBlockAddress {
uint32_t size_ = 0; uint32_t size_ = 0;
}; };
typedef LogicalBlockAddress LBA; using LBA = LogicalBlockAddress;
// class Writer // class Writer
// //

@ -95,9 +95,9 @@ class BlockCacheTierMetadata {
} }
}; };
typedef EvictableHashTable<BlockCacheFile, BlockCacheFileHash, using CacheFileIndexType =
BlockCacheFileEqual> EvictableHashTable<BlockCacheFile, BlockCacheFileHash,
CacheFileIndexType; BlockCacheFileEqual>;
// Block Lookup Index // Block Lookup Index
// //
@ -114,7 +114,7 @@ class BlockCacheTierMetadata {
} }
}; };
typedef HashTable<BlockInfo*, Hash, Equal> BlockIndexType; using BlockIndexType = HashTable<BlockInfo*, Hash, Equal>;
CacheFileIndexType cache_file_index_; CacheFileIndexType cache_file_index_;
BlockIndexType block_index_; BlockIndexType block_index_;

@ -24,7 +24,7 @@ namespace ROCKSDB_NAMESPACE {
template <class T, class Hash, class Equal> template <class T, class Hash, class Equal>
class EvictableHashTable : private HashTable<T*, Hash, Equal> { class EvictableHashTable : private HashTable<T*, Hash, Equal> {
public: public:
typedef HashTable<T*, Hash, Equal> hash_table; using hash_table = HashTable<T*, Hash, Equal>;
explicit EvictableHashTable(const size_t capacity = 1024 * 1024, explicit EvictableHashTable(const size_t capacity = 1024 * 1024,
const float load_factor = 2.0, const float load_factor = 2.0,
@ -141,7 +141,7 @@ class EvictableHashTable : private HashTable<T*, Hash, Equal> {
port::RWMutex* GetMutex(T* t) { return hash_table::GetMutex(t); } port::RWMutex* GetMutex(T* t) { return hash_table::GetMutex(t); }
private: private:
typedef LRUList<T> LRUListType; using LRUListType = LRUList<T>;
typename hash_table::Bucket& GetBucket(const uint64_t h) { typename hash_table::Bucket& GetBucket(const uint64_t h) {
const uint32_t bucket_idx = h % hash_table::nbuckets_; const uint32_t bucket_idx = h % hash_table::nbuckets_;

@ -235,7 +235,7 @@ struct PersistentCacheConfig {
// to enable management and stacking of tiers. // to enable management and stacking of tiers.
class PersistentCacheTier : public PersistentCache { class PersistentCacheTier : public PersistentCache {
public: public:
typedef std::shared_ptr<PersistentCacheTier> Tier; using Tier = std::shared_ptr<PersistentCacheTier>;
virtual ~PersistentCacheTier() {} virtual ~PersistentCacheTier() {}

@ -124,8 +124,8 @@ class VolatileCacheTier : public PersistentCacheTier {
} }
}; };
typedef EvictableHashTable<CacheData, CacheDataHash, CacheDataEqual> using IndexType =
IndexType; EvictableHashTable<CacheData, CacheDataHash, CacheDataEqual>;
// Evict LRU tail // Evict LRU tail
bool Evict(); bool Evict();

@ -98,7 +98,7 @@ class DeadlockInfoBufferTempl {
} }
}; };
typedef DeadlockInfoBufferTempl<DeadlockPath> DeadlockInfoBuffer; using DeadlockInfoBuffer = DeadlockInfoBufferTempl<DeadlockPath>;
struct TrackedTrxInfo { struct TrackedTrxInfo {
autovector<TransactionID> m_neighbors; autovector<TransactionID> m_neighbors;

@ -78,7 +78,7 @@ class PointLockManagerTest : public testing::Test {
TransactionDB* db_; TransactionDB* db_;
}; };
typedef void (*init_func_t)(PointLockManagerTest*); using init_func_t = void (*)(PointLockManagerTest*);
class AnyLockManagerTest : public PointLockManagerTest, class AnyLockManagerTest : public PointLockManagerTest,
public testing::WithParamInterface<init_func_t> { public testing::WithParamInterface<init_func_t> {

@ -25,7 +25,7 @@ namespace ROCKSDB_NAMESPACE {
namespace { namespace {
typedef std::map<std::string, std::string> KVMap; using KVMap = std::map<std::string, std::string>;
enum BatchOperation { OP_PUT = 0, OP_DELETE = 1 }; enum BatchOperation { OP_PUT = 0, OP_DELETE = 1 };
} }

@ -174,8 +174,8 @@ class WriteBatchEntryComparator {
const ReadableWriteBatch* write_batch_; const ReadableWriteBatch* write_batch_;
}; };
typedef SkipList<WriteBatchIndexEntry*, const WriteBatchEntryComparator&> using WriteBatchEntrySkipList =
WriteBatchEntrySkipList; SkipList<WriteBatchIndexEntry*, const WriteBatchEntryComparator&>;
class WBWIIteratorImpl : public WBWIIterator { class WBWIIteratorImpl : public WBWIIterator {
public: public:

Loading…
Cancel
Save