]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Replace most typedef with using= (#8751)
authorPeter Dillinger <peterd@fb.com>
Tue, 7 Sep 2021 18:31:12 +0000 (11:31 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 7 Sep 2021 18:31:59 +0000 (11:31 -0700)
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

59 files changed:
cache/clock_cache.cc
db/compaction/compaction_picker_universal.cc
db/db_impl/db_impl.cc
db/db_impl/db_impl.h
db/db_test.cc
db/forward_iterator.h
db/kv_checksum.h
db/malloc_stats.cc
db/pinned_iterators_manager.h
env/env_basic_test.cc
include/rocksdb/advanced_options.h
include/rocksdb/cache.h
include/rocksdb/cleanable.h
include/rocksdb/db.h
include/rocksdb/listener.h
include/rocksdb/memtablerep.h
include/rocksdb/persistent_cache.h
include/rocksdb/table_properties.h
include/rocksdb/transaction_log.h
include/rocksdb/types.h
include/rocksdb/utilities/backup_engine.h
memory/arena.h
memory/memory_usage.h
memtable/hash_linklist_rep.cc
memtable/hash_skiplist_rep.cc
memtable/inlineskiplist_test.cc
memtable/skiplist_test.cc
memtable/vectorrep.cc
options/cf_options.cc
options/options_settable_test.cc
port/port_example.h
port/port_posix.h
port/sys_time.h
port/win/env_win.cc
port/win/env_win.h
port/win/port_win.h
port/win/win_thread.h
table/block_based/block_based_table_builder.cc
table/block_based/block_based_table_reader.h
table/merging_iterator.cc
table/multiget_context.h
util/autovector.h
util/autovector_test.cc
util/crc32c.cc
util/kv_map.h
util/murmurhash.h
util/thread_local.h
utilities/cassandra/format.h
utilities/env_librados_test.cc
utilities/merge_operators/string_append/stringappend_test.cc
utilities/persistent_cache/block_cache_tier_file.h
utilities/persistent_cache/block_cache_tier_metadata.h
utilities/persistent_cache/hash_table_evictable.h
utilities/persistent_cache/persistent_cache_tier.h
utilities/persistent_cache/volatile_tier_impl.h
utilities/transactions/lock/point/point_lock_manager.h
utilities/transactions/lock/point/point_lock_manager_test.h
utilities/ttl/ttl_test.cc
utilities/write_batch_with_index/write_batch_with_index_internal.h

index 3364e251234a1810329f2b22327a3619a4416584..d2bcab0e26dd9fc753c89b6c53604195e3a9a783 100644 (file)
@@ -260,7 +260,7 @@ struct CleanupContext {
 class ClockCacheShard final : public CacheShard {
  public:
   // Hash map type.
-  typedef tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey> HashTable;
+  using HashTable = tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey>;
 
   ClockCacheShard();
   ~ClockCacheShard() override;
index 211a4f468afc31769918b3d6e462067bf8bf1555..ef3c9589d3e98515dbb04439a3d5a6811629ae14 100644 (file)
@@ -157,9 +157,9 @@ struct SmallestKeyHeapComparator {
   const Comparator* ucmp_;
 };
 
-typedef std::priority_queue<InputFileInfo, std::vector<InputFileInfo>,
-                            SmallestKeyHeapComparator>
-    SmallestKeyHeap;
+using SmallestKeyHeap =
+    std::priority_queue<InputFileInfo, std::vector<InputFileInfo>,
+                        SmallestKeyHeapComparator>;
 
 // This function creates the heap that is used to find if the files are
 // overlapping during universal compaction when the allow_trivial_move
index 2d020fe6ce357e43e536bfa895d9fce2cb447ce0..40df71a75dbd850703c4020b555ff5bdf31bfebf 100644 (file)
@@ -3116,7 +3116,7 @@ SnapshotImpl* DBImpl::GetSnapshotImpl(bool is_write_conflict_boundary,
 }
 
 namespace {
-typedef autovector<ColumnFamilyData*, 2> CfdList;
+using CfdList = autovector<ColumnFamilyData*, 2>;
 bool CfdListContains(const CfdList& list, ColumnFamilyData* cfd) {
   for (const ColumnFamilyData* t : list) {
     if (t == cfd) {
index e558edc656665745022c790981fc7ad5dcdf37ff..c2d7611045386e2fdef8b0cc5b152d71e61117bf 100644 (file)
@@ -1753,7 +1753,7 @@ class DBImpl : public DB {
   // specified value, this flush request is considered to have completed its
   // work of flushing this column family. After completing the work for all
   // 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,
                             FlushRequest* req);
index 9dbc9ecd53370cc4e1009d2c0ed96edf90aebe04..0d8e479f416883c633d48a01cad43bb861bb724c 100644 (file)
@@ -2812,7 +2812,7 @@ TEST_F(DBTest, GroupCommitTest) {
 #endif  // TRAVIS
 
 namespace {
-typedef std::map<std::string, std::string> KVMap;
+using KVMap = std::map<std::string, std::string>;
 }
 
 class ModelDB : public DB {
index e094c66956a1bdfa4b13de46061a315c92c72f53..620d4678106ca421ce6209a826b669a025b07be2 100644 (file)
@@ -39,8 +39,9 @@ class MinIterComparator {
   const Comparator* comparator_;
 };
 
-typedef std::priority_queue<InternalIterator*, std::vector<InternalIterator*>,
-                            MinIterComparator> MinIterHeap;
+using MinIterHeap =
+    std::priority_queue<InternalIterator*, std::vector<InternalIterator*>,
+                        MinIterComparator>;
 
 /**
  * ForwardIterator is a special type of iterator that only supports Seek()
index ba15dca3bb15eb25439748928e69b3c6fbdaa469..725ddc6de488cbb165ad1e8b7ca81d9c7dfaab2d 100644 (file)
@@ -49,10 +49,10 @@ template <typename T>
 class ProtectionInfoKVOTS;
 
 // Aliases for 64-bit protection infos.
-typedef ProtectionInfo<uint64_t> ProtectionInfo64;
-typedef ProtectionInfoKVOT<uint64_t> ProtectionInfoKVOT64;
-typedef ProtectionInfoKVOTC<uint64_t> ProtectionInfoKVOTC64;
-typedef ProtectionInfoKVOTS<uint64_t> ProtectionInfoKVOTS64;
+using ProtectionInfo64 = ProtectionInfo<uint64_t>;
+using ProtectionInfoKVOT64 = ProtectionInfoKVOT<uint64_t>;
+using ProtectionInfoKVOTC64 = ProtectionInfoKVOTC<uint64_t>;
+using ProtectionInfoKVOTS64 = ProtectionInfoKVOTS<uint64_t>;
 
 template <typename T>
 class ProtectionInfo {
index 12824e5163a91f71818ff2c7e3ab02ad274945eb..8f58ab2cfef1cf37f36eda39b3fb9c7f385963ef 100644 (file)
@@ -19,10 +19,10 @@ namespace ROCKSDB_NAMESPACE {
 
 #ifdef ROCKSDB_JEMALLOC
 
-typedef struct {
+struct MallocStatus {
   char* cur;
   char* end;
-} MallocStatus;
+};
 
 static void GetJemallocStatus(void* mstat_arg, const char* status) {
   MallocStatus* mstat = reinterpret_cast<MallocStatus*>(mstat_arg);
index 5e8ad51dd0cd28ca06393090e85a0777df0cc130..1336f542001fa83f4178ec20e94dd492047300d0 100644 (file)
@@ -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) {
     assert(pinning_enabled);
     if (ptr == nullptr) {
index 3d74239444dbf1725cd90fe280ecc5c75bf9370d..9cd8a11e741f2fb2c73f4e1cbb50892bfdb8b671 100644 (file)
@@ -17,8 +17,9 @@
 #include "test_util/testharness.h"
 
 namespace ROCKSDB_NAMESPACE {
-typedef Env* CreateEnvFunc();
 namespace {
+using CreateEnvFunc = Env*();
+
 // 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
 // created without the Env being initialized, thereby eliminating a potential
index 680c46317e089e6a98dda764b016d7d0c5d20e3c..2e6bb7fbc409393182b77e20165675ef568ad6de 100644 (file)
@@ -650,8 +650,8 @@ struct AdvancedColumnFamilyOptions {
   // the tables.
   // Default: empty vector -- no user-defined statistics collection will be
   // performed.
-  typedef std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>
-      TablePropertiesCollectorFactories;
+  using TablePropertiesCollectorFactories =
+      std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>;
   TablePropertiesCollectorFactories table_properties_collector_factories;
 
   // Maximum number of successive merge operations on a key in the memtable.
index c1ce88dbd82bdc1b063d805ecb00d64cc90dee8a..b7ab36dc037a1bb63f1b46ca6adf8c0b6aa30aad 100644 (file)
@@ -202,9 +202,6 @@ class Cache {
   // 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
   // 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,
                                               void** out_obj, size_t* charge)>;
 
index b6a70ea642dc7e485d2919fb3d21c99260180ef8..c325ae20682b7df73d28e7cdaae0ea6912060cff 100644 (file)
@@ -30,7 +30,7 @@ class Cleanable {
   //
   // Note that unlike all of the preceding methods, this method is
   // 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 DelegateCleanupsTo(Cleanable* other);
   // DoCleanup and also resets the pointers for reuse
index 264ff06f40378e7b0252dcd5272df552f0133cfd..d749ea8f5c419eded5b315422fcbe5b1e7ddf8ef 100644 (file)
@@ -136,8 +136,8 @@ struct GetMergeOperandsOptions {
 // A collections of table properties objects, where
 //  key: is the table's file name.
 //  value: the table properties object of the given table.
-typedef std::unordered_map<std::string, std::shared_ptr<const TableProperties>>
-    TablePropertiesCollection;
+using 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 safe for concurrent access from multiple threads without
index 5216e1e24ad9dab65d0694bc638146072d2b3ec6..a70836a272392157b0731a754e8eede413657176 100644 (file)
@@ -21,8 +21,8 @@
 
 namespace ROCKSDB_NAMESPACE {
 
-typedef std::unordered_map<std::string, std::shared_ptr<const TableProperties>>
-    TablePropertiesCollection;
+using TablePropertiesCollection =
+    std::unordered_map<std::string, std::shared_ptr<const TableProperties>>;
 
 class DB;
 class ColumnFamilyHandle;
index 934a0085a2ba7bb5258b2bd2c1d48ef5d4e49a3e..a2eeba0413e6b5b57a6686aeb57e35488141c323 100644 (file)
@@ -51,7 +51,7 @@ class LookupKey;
 class SliceTransform;
 class Logger;
 
-typedef void* KeyHandle;
+using KeyHandle = void*;
 
 extern Slice GetLengthPrefixedSlice(const char* data);
 
@@ -61,7 +61,7 @@ class MemTableRep {
   // concatenated with values.
   class KeyComparator {
    public:
-    typedef ROCKSDB_NAMESPACE::Slice DecodedType;
+    using DecodedType = ROCKSDB_NAMESPACE::Slice;
 
     virtual DecodedType decode_key(const char* key) const {
       // The format of key is frozen and can be treated as a part of the API
index e2dcfcac3ad48dd123c5dd4cb5495842629115e4..cff6c7ecd85ec3b6e2246f565e43955ef8e94a1f 100644 (file)
@@ -24,7 +24,7 @@ namespace ROCKSDB_NAMESPACE {
 // cache interface is specifically designed for persistent read cache.
 class PersistentCache {
  public:
-  typedef std::vector<std::map<std::string, double>> StatsType;
+  using StatsType = std::vector<std::map<std::string, double>>;
 
   virtual ~PersistentCache() {}
 
index 2e605ee8d799708d65aed425d8fe63698ee9f185..1906e7acc29add941c7b7324c9428d3a52af7ef8 100644 (file)
@@ -26,7 +26,7 @@ namespace ROCKSDB_NAMESPACE {
 //      ++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.
 struct TablePropertiesNames {
index 48d0e5c0b8d473a027ef65e9421dbe3b66525020..2519f3a5877ba3279a7fb45124a5f894529cfe49 100644 (file)
@@ -14,7 +14,7 @@
 namespace ROCKSDB_NAMESPACE {
 
 class LogFile;
-typedef std::vector<std::unique_ptr<LogFile>> VectorLogPtr;
+using VectorLogPtr = std::vector<std::unique_ptr<LogFile>>;
 
 enum WalFileType {
   /* Indicates that WAL file is in archive directory. WAL files are moved from
index 3b2d3f6946e33733366ce7d73e1391c523610341..14dc39ea3ae90c4c16bb07a06b1ea36b745a69df 100644 (file)
@@ -15,7 +15,7 @@ namespace ROCKSDB_NAMESPACE {
 using ColumnFamilyId = uint32_t;
 
 // Represents a sequence number in a WAL file.
-typedef uint64_t SequenceNumber;
+using SequenceNumber = uint64_t;
 
 const SequenceNumber kMinUnCommittedSeq = 1;  // 0 is always committed
 
index 8b9426e83ec124a1724fff470b23540be54c38ce..8c2eb20833c35bee7025f566341053f003cc92bd 100644 (file)
@@ -285,7 +285,7 @@ struct BackupFileInfo {
   uint64_t size;
 };
 
-typedef uint32_t BackupID;
+using BackupID = uint32_t;
 
 struct BackupInfo {
   BackupID backup_id = 0U;
index a7ee4c6ab01cff234a6b35c45acd0aced1b2677a..07fc4355966d7fe36ea48dc5ee4e40c889e6bd18 100644 (file)
@@ -86,7 +86,7 @@ class Arena : public Allocator {
   // Number of bytes allocated in one block
   const size_t kBlockSize;
   // Array of new[] allocated memory blocks
-  typedef std::vector<char*> Blocks;
+  using Blocks = std::vector<char*>;
   Blocks blocks_;
 
   struct MmapInfo {
index 15e8b87cdec9d76bd24613f75c7987c6af51a02a..9061d45eb44fc82925faa927c05ed475ca91d4c7 100644 (file)
@@ -14,7 +14,7 @@ namespace ROCKSDB_NAMESPACE {
 template <class Key, class Value, class Hash>
 size_t ApproximateMemoryUsage(
     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) +
          // Size of all items plus a next pointer for each item.
          (sizeof(typename Map::value_type) + sizeof(void*)) * umap.size() +
index 765ca9cbbafd74c9b71398262420339464ab96e5..15bc648a271d815bac0d13074616423a4e822f96 100644 (file)
@@ -22,9 +22,9 @@
 namespace ROCKSDB_NAMESPACE {
 namespace {
 
-typedef const char* Key;
-typedef SkipList<Key, const MemTableRep::KeyComparator&> MemtableSkipList;
-typedef std::atomic<void*> Pointer;
+using Key = const char*;
+using MemtableSkipList = SkipList<Key, const MemTableRep::KeyComparator&>;
+using Pointer = std::atomic<void*>;
 
 // A data structure used as the header of a link list of a hash bucket.
 struct BucketHeader {
index 67a2a6c83c49a272c488a68de42d1e4f17856ebf..72fc391e179bd6e8beffd643b17e9e2c42617324 100644 (file)
@@ -46,7 +46,7 @@ class HashSkipListRep : public MemTableRep {
 
  private:
   friend class DynamicIterator;
-  typedef SkipList<const char*, const MemTableRep::KeyComparator&> Bucket;
+  using Bucket = SkipList<const char*, const MemTableRep::KeyComparator&>;
 
   size_t bucket_size_;
 
index 75b83f46ed4a86b0a9997151aabce82859816022..4523aa77043a11f2b57e907f91be63ec1c0934e8 100644 (file)
@@ -19,7 +19,7 @@
 namespace ROCKSDB_NAMESPACE {
 
 // 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) {
   return reinterpret_cast<const char*>(key);
@@ -32,7 +32,7 @@ static Key Decode(const char* key) {
 }
 
 struct TestComparator {
-  typedef Key DecodedType;
+  using DecodedType = Key;
 
   static DecodedType decode_key(const char* b) {
     return Decode(b);
@@ -59,7 +59,7 @@ struct TestComparator {
   }
 };
 
-typedef InlineSkipList<TestComparator> TestInlineSkipList;
+using TestInlineSkipList = InlineSkipList<TestComparator>;
 
 class InlineSkipTest : public testing::Test {
  public:
index 18990eab5c07803f99bc95164b315f61f0973e90..d35bc856d8be00d875f584226c5019396474c898 100644 (file)
@@ -17,7 +17,7 @@
 
 namespace ROCKSDB_NAMESPACE {
 
-typedef uint64_t Key;
+using Key = uint64_t;
 
 struct TestComparator {
   int operator()(const Key& a, const Key& b) const {
index 3797e46c45bee63bb78250d85c6d6a862290d917..7dde80b229f665b7969afe39c19695cc75bb5177 100644 (file)
@@ -98,7 +98,7 @@ class VectorRep : public MemTableRep {
 
  private:
   friend class Iterator;
-  typedef std::vector<const char*> Bucket;
+  using Bucket = std::vector<const char*>;
   std::shared_ptr<Bucket> bucket_;
   mutable port::RWMutex rwlock_;
   bool immutable_;
index 465413170d0ea450a0022679f03644bfbcfe2ad6..996aefab597e1e61176b95ad320d3f55fc775390 100644 (file)
@@ -479,8 +479,8 @@ static std::unordered_map<std::string, OptionTypeInfo>
         /* not yet supported
         CompressionOptions compression_opts;
         TablePropertiesCollectorFactories table_properties_collector_factories;
-        typedef std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>
-            TablePropertiesCollectorFactories;
+        using TablePropertiesCollectorFactories =
+            std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>;
         UpdateStatus (*inplace_callback)(char* existing_value,
                                          uint34_t* existing_value_size,
                                          Slice delta_value,
index 5c79a024858dd1d559f2bc37c65a0d9fd526f979..f79021374bfca665664a7f60fcb49003fd61ada0 100644 (file)
@@ -41,7 +41,7 @@ class OptionsSettableTest : public testing::Test {
 };
 
 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,
                          const OffsetGap& excluded,
index b906bbec7ab76d75495875c43b225fefd52b9c39..794149a6906d81f198aec6e57efbc3008354bc43 100644 (file)
@@ -70,7 +70,7 @@ class CondVar {
 //      static void Initializer() { ... do something ...; }
 //      ...
 //      port::InitOnce(&init_control, &Initializer);
-typedef intptr_t OnceType;
+using OnceType = intptr_t;
 #define LEVELDB_ONCE_INIT 0
 extern void InitOnce(port::OnceType*, void (*initializer)());
 
index 9bea210397bc4ef36925faa642731d214f0beae2..291139764a55458569f656f546e880ad3a903dd3 100644 (file)
@@ -177,7 +177,7 @@ static inline void AsmVolatilePause() {
 // Returns -1 if not available on this platform
 extern int PhysicalCoreID();
 
-typedef pthread_once_t OnceType;
+using OnceType = pthread_once_t;
 #define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT
 extern void InitOnce(OnceType* once, void (*initializer)());
 
index 1c7d206a79323b3c625a15ce9ca961e563e8e835..8a5440f9554de79befe4192cd2d26fa61079f204 100644 (file)
@@ -23,10 +23,10 @@ namespace ROCKSDB_NAMESPACE {
 namespace port {
 
 // Avoid including winsock2.h for this definition
-typedef struct timeval {
+struct timeval {
   long tv_sec;
   long tv_usec;
-} timeval;
+};
 
 void gettimeofday(struct timeval* tv, struct timezone* tz);
 
index 2b141c55d6576c7496bb8070ff8da5cbbd600d86..53c32ed2d32a3d6f732f99a853e760b30e6c46c2 100644 (file)
@@ -53,10 +53,10 @@ static const size_t kSectorSize = 512;
 
 // RAII helpers for HANDLEs
 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); };
-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) {
   if (0 != result.value()) {
index d0fd78ebbf3a63c00cf560719bdb6979ef891132..82902d73c485f20ae0cf1b3a64a0b81dd5b3fbde 100644 (file)
@@ -96,7 +96,7 @@ class WinClock : public SystemClock {
   uint64_t GetPerfCounterFrequency() const { return perf_counter_frequency_; }
 
  private:
-  typedef VOID(WINAPI* FnGetSystemTimePreciseAsFileTime)(LPFILETIME);
+  using FnGetSystemTimePreciseAsFileTime = VOID(WINAPI*)(LPFILETIME);
 
   uint64_t perf_counter_frequency_;
   uint64_t nano_seconds_per_period_;
index 2de75179d654ef61015fa5ecb9505edd47adfd48..d188612cd731f9dbbbad6ef28f03012e348c3863 100644 (file)
@@ -47,7 +47,7 @@
 #undef DeleteFile
 
 #ifndef _SSIZE_T_DEFINED
-typedef SSIZE_T ssize_t;
+using ssize_t = SSIZE_T;
 #endif
 
 // size_t printf formatting named in the manner of C99 standard formatting
@@ -292,7 +292,7 @@ static inline void AsmVolatilePause() {
 extern int PhysicalCoreID();
 
 // 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*)) {
   // Not used
index ffdfdc11b6c600b2eef72ead315116e293b1aa03..89cfd02217ff371758d689fe014f2d37d5aa225f 100644 (file)
@@ -25,11 +25,10 @@ namespace port {
 //  -- is that it dynamically allocates its internals that are automatically
 //     freed when  the thread terminates and not on the destruction of the
 //     object. This makes it difficult to control the source of memory
-//     allocation 
+//     allocation
 //  -  This implements Pimpl so we can easily replace the guts of the
 //      object in our private version if necessary.
 class WindowsThread {
-
   struct Data;
 
   std::shared_ptr<Data>  data_;
@@ -37,15 +36,14 @@ class WindowsThread {
 
   void Init(std::function<void()>&&);
 
-public:
-
-  typedef void* native_handle_type;
+ public:
+  using native_handle_type = void*;
 
   // Construct with no thread
   WindowsThread();
 
   // Template constructor
-  // 
+  //
   // This templated constructor accomplishes several things
   //
   // - Allows the class as whole to be not a template
@@ -68,17 +66,12 @@ public:
   //   dependent type that both checks the signature conformance to ensure
   //   that all of the necessary arguments are provided and allows pimpl
   //   implementation.
-  template<class Fn,
-    class... Args,
-    class = typename std::enable_if<
-      !std::is_same<typename std::decay<Fn>::type,
-                    WindowsThread>::value>::type>
-  explicit WindowsThread(Fn&& fx, Args&&... ax) :
-      WindowsThread() {
-
+  template <class Fn, class... Args,
+            class = typename std::enable_if<!std::is_same<
+                typename std::decay<Fn>::type, WindowsThread>::value>::type>
+  explicit WindowsThread(Fn&& fx, Args&&... ax) : WindowsThread() {
     // Use binder to create a single callable entity
-    auto binder = std::bind(std::forward<Fn>(fx),
-      std::forward<Args>(ax)...);
+    auto binder = std::bind(std::forward<Fn>(fx), std::forward<Args>(ax)...);
     // Use std::function to take advantage of the type erasure
     // so we can still hide implementation within pimpl
     // This also makes sure that the binder signature is compliant
@@ -87,7 +80,6 @@ public:
     Init(std::move(target));
   }
 
-
   ~WindowsThread();
 
   WindowsThread(const WindowsThread&) = delete;
index d2b30443e0dfaf132f7a75808bbe80a31da42800..be2cae968cbc69518819d4c6371336a75365f290 100644 (file)
@@ -589,11 +589,11 @@ struct BlockBasedTableBuilder::ParallelCompressionRep {
   // Use a vector of BlockRep as a buffer for a determined number
   // of BlockRep structures. All data referenced by pointers in
   // BlockRep will be freed when this vector is destructed.
-  typedef std::vector<BlockRep> BlockRepBuffer;
+  using BlockRepBuffer = std::vector<BlockRep>;
   BlockRepBuffer block_rep_buf;
   // Use a thread-safe queue for concurrent access from block
   // building thread and writer thread.
-  typedef WorkQueue<BlockRep*> BlockRepPool;
+  using BlockRepPool = WorkQueue<BlockRep*>;
   BlockRepPool block_rep_pool;
 
   // 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,
   // and those references are always valid before the destruction of
   // block_rep_buf.
-  typedef WorkQueue<BlockRep*> CompressQueue;
+  using CompressQueue = WorkQueue<BlockRep*>;
   CompressQueue compress_queue;
   std::vector<port::Thread> compress_thread_pool;
 
@@ -625,7 +625,7 @@ struct BlockBasedTableBuilder::ParallelCompressionRep {
   // and those references are always valid before the corresponding
   // BlockRep::slot is destructed, which is before the destruction of
   // block_rep_buf.
-  typedef WorkQueue<BlockRepSlot*> WriteQueue;
+  using WriteQueue = WorkQueue<BlockRepSlot*>;
   WriteQueue write_queue;
   std::unique_ptr<port::Thread> write_thread;
 
index e64d09d209edad501fbcf6d12ca215b74f737d85..287b60fd248a288970f3feb627d1a3f08a5dd44e 100644 (file)
@@ -41,7 +41,7 @@ struct EnvOptions;
 struct ReadOptions;
 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.
 // For the format of BlockBasedTable refer to
index fdd1a4910d7cb032234166ebbabd646ef1c85a01..ee938e93c328b5bab8e7c75ed4e1db6d8df7906c 100644 (file)
@@ -28,8 +28,8 @@
 namespace ROCKSDB_NAMESPACE {
 // Without anonymous namespace here, we fail the warning -Wmissing-prototypes
 namespace {
-typedef BinaryHeap<IteratorWrapper*, MaxIteratorComparator> MergerMaxIterHeap;
-typedef BinaryHeap<IteratorWrapper*, MinIteratorComparator> MergerMinIterHeap;
+using MergerMaxIterHeap = BinaryHeap<IteratorWrapper*, MaxIteratorComparator>;
+using MergerMinIterHeap = BinaryHeap<IteratorWrapper*, MinIteratorComparator>;
 }  // namespace
 
 const size_t kNumIterReserve = 4;
index 1c9f8da940bd00edcfce68a89ba55d25d5a0a970..3872353d2ff2e28d6f878ec6e4a5ec6b0b50422d 100644 (file)
@@ -158,12 +158,12 @@ class MultiGetContext {
     class Iterator {
      public:
       // -- iterator traits
-      typedef Iterator self_type;
-      typedef KeyContext value_type;
-      typedef KeyContext& reference;
-      typedef KeyContext* pointer;
-      typedef int difference_type;
-      typedef std::forward_iterator_tag iterator_category;
+      using self_type = Iterator;
+      using value_type = KeyContext;
+      using reference = KeyContext&;
+      using pointer = KeyContext*;
+      using difference_type = int;
+      using iterator_category = std::forward_iterator_tag;
 
       Iterator(const Range* range, size_t idx)
           : range_(range), ctx_(range->ctx_), index_(idx) {
index 7e33e5ca87ecd93f4fa2de7f6a7038de81b0ef15..e2506a5ad2d66e7260a9b230c98bb772682da957 100644 (file)
@@ -51,25 +51,25 @@ template <class T, size_t kSize = 8>
 class autovector {
  public:
   // General STL-style container member types.
-  typedef T value_type;
-  typedef typename std::vector<T>::difference_type difference_type;
-  typedef typename std::vector<T>::size_type size_type;
-  typedef value_type& reference;
-  typedef const value_type& const_reference;
-  typedef value_type* pointer;
-  typedef const value_type* const_pointer;
+  using value_type = T;
+  using difference_type = typename std::vector<T>::difference_type;
+  using size_type = typename std::vector<T>::size_type;
+  using reference = value_type&;
+  using const_reference = const value_type&;
+  using pointer = value_type*;
+  using const_pointer = const value_type*;
 
   // This class is the base for regular/const iterator
   template <class TAutoVector, class TValueType>
   class iterator_impl {
    public:
     // -- iterator traits
-    typedef iterator_impl<TAutoVector, TValueType> self_type;
-    typedef TValueType value_type;
-    typedef TValueType& reference;
-    typedef TValueType* pointer;
-    typedef typename TAutoVector::difference_type difference_type;
-    typedef std::random_access_iterator_tag iterator_category;
+    using self_type = iterator_impl<TAutoVector, TValueType>;
+    using value_type = TValueType;
+    using reference = TValueType&;
+    using pointer = TValueType*;
+    using difference_type = typename TAutoVector::difference_type;
+    using iterator_category = std::random_access_iterator_tag;
 
     iterator_impl(TAutoVector* vect, size_t index)
         : vect_(vect), index_(index) {};
@@ -175,10 +175,10 @@ class autovector {
     size_t index_ = 0;
   };
 
-  typedef iterator_impl<autovector, value_type> iterator;
-  typedef iterator_impl<const autovector, const value_type> const_iterator;
-  typedef std::reverse_iterator<iterator> reverse_iterator;
-  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+  using iterator = iterator_impl<autovector, value_type>;
+  using const_iterator = iterator_impl<const autovector, const value_type>;
+  using reverse_iterator = std::reverse_iterator<iterator>;
+  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
 
   autovector() : values_(reinterpret_cast<pointer>(buf_)) {}
 
index adddd1b028df65182619fcf95ced2643db877915..d73b1ee6abe1f60b590a36243b880655ca88df6f 100644 (file)
@@ -64,7 +64,7 @@ TEST_F(AutoVectorTest, PushBackAndPopBack) {
 }
 
 TEST_F(AutoVectorTest, EmplaceBack) {
-  typedef std::pair<size_t, std::string> ValType;
+  using ValType = std::pair<size_t, std::string>;
   autovector<ValType, kSize> vec;
 
   for (size_t i = 0; i < 1000 * kSize; ++i) {
index 87fbb9f84fd88d4f274951b22f9996d51734b810..59acb8c72b015fa57225d3b76b48521faeeb6d58 100644 (file)
@@ -459,7 +459,7 @@ static bool isPCLMULQDQ() {
 #endif  // HAVE_POWER8
 #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)
 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>
 struct integer_sequence {
-  typedef T value_type;
+  using value_type = T;
   static constexpr size_t size() { return sizeof...(Ints); }
 };
 
index 0f713ccea17aa91188c4a1b5017dc6d7ff6b6e4a..89300d7ac82bc098fc793eb4b1ac359721e731f4 100644 (file)
@@ -28,6 +28,6 @@ struct LessOfComparator {
   const Comparator* cmp;
 };
 
-typedef std::map<std::string, std::string, LessOfComparator> KVMap;
+using KVMap = std::map<std::string, std::string, LessOfComparator>;
 }
 }  // namespace ROCKSDB_NAMESPACE
index 1dbb5739812063e499f1939ac666de348cb0d3ea..5f66c4ebf04710ad7746e462f07b9df08f75f2a9 100644 (file)
 #define MURMUR_HASH MurmurHash64A
 uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed );
 #define MurmurHash MurmurHash64A
-typedef uint64_t murmur_t;
+using murmur_t = uint64_t;
 
 #elif defined(__i386__)
 #define MURMUR_HASH MurmurHash2
 unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed );
 #define MurmurHash MurmurHash2
-typedef unsigned int murmur_t;
+using murmur_t = unsigned int;
 
 #else
 #define MURMUR_HASH MurmurHashNeutral2
 unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed );
 #define MurmurHash MurmurHashNeutral2
-typedef unsigned int murmur_t;
+using murmur_t = unsigned int;
 #endif
 
 // Allow slice to be hashable by murmur hash.
index c4b762ab6ff490128fef83a84ff744f504af4bbf..01790ccc087440dbcd48d6b8c746fd46700e3bdd 100644 (file)
@@ -31,7 +31,7 @@ namespace ROCKSDB_NAMESPACE {
 // is needed to avoid deadlocks. In particular, the handler shouldn't lock any
 // mutexes and shouldn't call any methods of any ThreadLocalPtr instances,
 // 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
 // the usual thread-local-storage, ThreadLocalPtr has the ability to
@@ -69,7 +69,7 @@ class ThreadLocalPtr {
   // data for all existing threads
   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
   // prevents unref handler from running during this call, but clients must
   // still provide external synchronization since the owning thread can
index 325ebb4e6935336da45ecbc0e5161663bd8c0645..2aca9d3f939dbb60b9a5c51cfe4b8ea0e9aa50db 100644 (file)
@@ -142,7 +142,7 @@ private:
   std::chrono::seconds Ttl() const;
 };
 
-typedef std::vector<std::shared_ptr<ColumnBase>> Columns;
+using Columns = std::vector<std::shared_ptr<ColumnBase>>;
 
 class RowValue {
 public:
index d5167acc0066ff87350203d49655ba2474095f1c..3b86881ac15781142229d9f176eacffbd7e885b5 100644 (file)
 #include "rocksdb/utilities/transaction_db.h"
 
 class Timer {
-  typedef std::chrono::high_resolution_clock high_resolution_clock;
-  typedef std::chrono::milliseconds milliseconds;
-public:
+  using high_resolution_clock = std::chrono::high_resolution_clock;
+  using milliseconds = std::chrono::milliseconds;
+
+ public:
   explicit Timer(bool run = false)
   {
     if (run)
index f7d8d7bff7efbca1bbe878dedc4055327d43ddd2..e7963364e1339bd7462515396abc5052ce4b73a0 100644 (file)
@@ -149,7 +149,7 @@ class StringAppendOperatorTest : public testing::Test,
     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.
   // e.g.: Can open a DB or a TtlDB, etc.
index 95be4ec3cc6697393d15a15d48d30c1238d3f936..123f91e6c21f7204ccda6fdd5d8a681cef3bd202 100644 (file)
@@ -65,7 +65,7 @@ struct LogicalBlockAddress {
   uint32_t size_ = 0;
 };
 
-typedef LogicalBlockAddress LBA;
+using LBA = LogicalBlockAddress;
 
 // class Writer
 //
index 92adae2bf8abbe267e73948d94cd0232aa858c62..6735ce290a916865eb24dfabf2108bc23156382a 100644 (file)
@@ -95,9 +95,9 @@ class BlockCacheTierMetadata {
     }
   };
 
-  typedef EvictableHashTable<BlockCacheFile, BlockCacheFileHash,
-                             BlockCacheFileEqual>
-      CacheFileIndexType;
+  using CacheFileIndexType =
+      EvictableHashTable<BlockCacheFile, BlockCacheFileHash,
+                         BlockCacheFileEqual>;
 
   // 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_;
   BlockIndexType block_index_;
index d27205d088cb786d8850a5cf9feafaf9f1375409..e10939b2f7dba2ed80e0676d1b45157201c8cfea 100644 (file)
@@ -24,7 +24,7 @@ namespace ROCKSDB_NAMESPACE {
 template <class T, class Hash, class Equal>
 class EvictableHashTable : private HashTable<T*, Hash, Equal> {
  public:
-  typedef HashTable<T*, Hash, Equal> hash_table;
+  using hash_table = HashTable<T*, Hash, Equal>;
 
   explicit EvictableHashTable(const size_t capacity = 1024 * 1024,
                               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); }
 
  private:
-  typedef LRUList<T> LRUListType;
+  using LRUListType = LRUList<T>;
 
   typename hash_table::Bucket& GetBucket(const uint64_t h) {
     const uint32_t bucket_idx = h % hash_table::nbuckets_;
index 286436da071c2af359173eade2debb2907f8fbc4..65aadcd3f4f52941f431e9608a7120df351682df 100644 (file)
@@ -235,7 +235,7 @@ struct PersistentCacheConfig {
 // to enable management and stacking of tiers.
 class PersistentCacheTier : public PersistentCache {
  public:
-  typedef std::shared_ptr<PersistentCacheTier> Tier;
+  using Tier = std::shared_ptr<PersistentCacheTier>;
 
   virtual ~PersistentCacheTier() {}
 
index 6116e894bf48e8f798c970077e79229957b87ef2..d6dbcdef4e3a292eb45404294cde6b6a15da5dbc 100644 (file)
@@ -124,8 +124,8 @@ class VolatileCacheTier : public PersistentCacheTier {
     }
   };
 
-  typedef EvictableHashTable<CacheData, CacheDataHash, CacheDataEqual>
-      IndexType;
+  using IndexType =
+      EvictableHashTable<CacheData, CacheDataHash, CacheDataEqual>;
 
   // Evict LRU tail
   bool Evict();
index 3c541eb3afbe8c7b171494a590b26350ccf4bdd2..c861061fcdbb937c36ab79c912aa88f7edb150ca 100644 (file)
@@ -98,7 +98,7 @@ class DeadlockInfoBufferTempl {
   }
 };
 
-typedef DeadlockInfoBufferTempl<DeadlockPath> DeadlockInfoBuffer;
+using DeadlockInfoBuffer = DeadlockInfoBufferTempl<DeadlockPath>;
 
 struct TrackedTrxInfo {
   autovector<TransactionID> m_neighbors;
index d4011c02419641cde27730dfcf3c6b6cf23b9983..50b268ab16643cdbbe7c37ee0ac56eebdd242784 100644 (file)
@@ -78,7 +78,7 @@ class PointLockManagerTest : public testing::Test {
   TransactionDB* db_;
 };
 
-typedef void (*init_func_t)(PointLockManagerTest*);
+using init_func_t = void (*)(PointLockManagerTest*);
 
 class AnyLockManagerTest : public PointLockManagerTest,
                            public testing::WithParamInterface<init_func_t> {
index c657dfe2b54caf590ed04f937a7442d8653c951d..e0b5ee00b1aba619981123ec1e35f84ed18721bc 100644 (file)
@@ -25,7 +25,7 @@ namespace ROCKSDB_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 };
 }
index b3360140bf2d8689626100024640f19871acd470..8085f5f50d1253346a056c039fbce58172a48fea 100644 (file)
@@ -174,8 +174,8 @@ class WriteBatchEntryComparator {
   const ReadableWriteBatch* write_batch_;
 };
 
-typedef SkipList<WriteBatchIndexEntry*, const WriteBatchEntryComparator&>
-    WriteBatchEntrySkipList;
+using WriteBatchEntrySkipList =
+    SkipList<WriteBatchIndexEntry*, const WriteBatchEntryComparator&>;
 
 class WBWIIteratorImpl : public WBWIIterator {
  public: