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
This commit is contained in:
Peter Dillinger 2021-09-07 11:31:12 -07:00 committed by Facebook GitHub Bot
parent 55ef8972fc
commit 4750421ece
59 changed files with 125 additions and 133 deletions

View 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;

View 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

View 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) {

View 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);

View 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 {

View 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()

View 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 {

View 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);

View 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) {

View 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

View 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.

View 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)>;

View 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

View 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

View 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;

View 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

View 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() {}

View 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 {

View 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

View 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

View File

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

View 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 {

View 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() +

View 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 {

View 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_;

View 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:

View 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 {

View 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_;

View 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,

View 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,

View 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)());

View 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)());

View 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);

View 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()) {

View 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_;

View 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

View File

@ -29,7 +29,6 @@ namespace port {
// - 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,9 +36,8 @@ class WindowsThread {
void Init(std::function<void()>&&);
public:
typedef void* native_handle_type;
public:
using native_handle_type = void*;
// Construct with no thread
WindowsThread();
@ -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;

View 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;

View 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

View 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;

View 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) {

View 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_)) {}

View 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) {

View 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); }
};

View 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

View File

@ -17,19 +17,19 @@
#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.

View 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

View 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:

View File

@ -20,9 +20,10 @@
#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)

View 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.

View File

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

View 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_;

View 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_;

View 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() {}

View 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();

View File

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

View 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> {

View 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 };
}

View 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: