Skip to content

Commit

Permalink
Remove some "using std::..." from header files. (#5113)
Browse files Browse the repository at this point in the history
Summary:
The code convention we are following, Google C++ Style, discourage
alias in header files, especially public headers:
https://google.github.io/styleguide/cppguide.html#Aliases
Remove some of them. Might removed some from .cc files as well to be consistent.
Pull Request resolved: #5113

Differential Revision: D14633030

Pulled By: siying

fbshipit-source-id: b990edc919d5de60295992284f980195e501d424
  • Loading branch information
siying authored and facebook-github-bot committed Mar 27, 2019
1 parent 9358178 commit 2b4d5ce
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 46 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* statistics.stats_level_ becomes atomic. It is preferred to use statistics.set_stats_level() and statistics.get_stats_level() to access it.
* Introduce a new IOError subcode, PathNotFound, to indicate trying to open a nonexistent file or directory for read.
* Add initial support for multiple db instances sharing the same data in single-writer, multi-reader mode.
* Removed some "using std::xxx" from public headers.

### Bug Fixes
* Fix JEMALLOC_CXX_THROW macro missing from older Jemalloc versions, causing build failures on some platforms.
* Fix SstFileReader not able to open file ingested with write_glbal_seqno=true.
Expand Down
11 changes: 6 additions & 5 deletions cache/cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
return nullptr;
}

int Lookup(shared_ptr<Cache> cache, int key) {
int Lookup(std::shared_ptr<Cache> cache, int key) {
Cache::Handle* handle = cache->Lookup(EncodeKey(key));
const int r = (handle == nullptr) ? -1 : DecodeValue(cache->Value(handle));
if (handle != nullptr) {
Expand All @@ -107,16 +107,16 @@ class CacheTest : public testing::TestWithParam<std::string> {
return r;
}

void Insert(shared_ptr<Cache> cache, int key, int value, int charge = 1) {
void Insert(std::shared_ptr<Cache> cache, int key, int value,
int charge = 1) {
cache->Insert(EncodeKey(key), EncodeValue(value), charge,
&CacheTest::Deleter);
}

void Erase(shared_ptr<Cache> cache, int key) {
void Erase(std::shared_ptr<Cache> cache, int key) {
cache->Erase(EncodeKey(key));
}


int Lookup(int key) {
return Lookup(cache_, key);
}
Expand Down Expand Up @@ -687,7 +687,8 @@ TEST_P(CacheTest, DefaultShardBits) {
}

#ifdef SUPPORT_CLOCK_CACHE
shared_ptr<Cache> (*new_clock_cache_func)(size_t, int, bool) = NewClockCache;
std::shared_ptr<Cache> (*new_clock_cache_func)(size_t, int,
bool) = NewClockCache;
INSTANTIATE_TEST_CASE_P(CacheTestInstance, CacheTest,
testing::Values(kLRU, kClock));
#else
Expand Down
2 changes: 1 addition & 1 deletion db/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,7 @@ void DBImpl::BuildCompactionJobInfo(
fmd->fd.GetNumber(), fmd->fd.GetPathId());
compaction_job_info->input_files.push_back(fn);
if (compaction_job_info->table_properties.count(fn) == 0) {
shared_ptr<const TableProperties> tp;
std::shared_ptr<const TableProperties> tp;
auto s = current->GetTableProperties(&tp, fmd, &fn);
if (s.ok()) {
compaction_job_info->table_properties[fn] = tp;
Expand Down
1 change: 0 additions & 1 deletion db/log_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace rocksdb {

class SequentialFileReader;
class Logger;
using std::unique_ptr;

namespace log {

Expand Down
2 changes: 1 addition & 1 deletion db/log_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace rocksdb {
namespace log {

Writer::Writer(unique_ptr<WritableFileWriter>&& dest, uint64_t log_number,
Writer::Writer(std::unique_ptr<WritableFileWriter>&& dest, uint64_t log_number,
bool recycle_log_files, bool manual_flush)
: dest_(std::move(dest)),
block_offset_(0),
Expand Down
7 changes: 3 additions & 4 deletions db/log_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace rocksdb {

class WritableFileWriter;

using std::unique_ptr;

namespace log {

/**
Expand Down Expand Up @@ -72,8 +70,9 @@ class Writer {
// Create a writer that will append data to "*dest".
// "*dest" must be initially empty.
// "*dest" must remain live while this Writer is in use.
explicit Writer(unique_ptr<WritableFileWriter>&& dest, uint64_t log_number,
bool recycle_log_files, bool manual_flush = false);
explicit Writer(std::unique_ptr<WritableFileWriter>&& dest,
uint64_t log_number, bool recycle_log_files,
bool manual_flush = false);
~Writer();

Status AddRecord(const Slice& slice);
Expand Down
2 changes: 0 additions & 2 deletions include/rocksdb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class TraceWriter;
class CompactionJobInfo;
#endif

using std::unique_ptr;

extern const std::string kDefaultColumnFamilyName;
struct ColumnFamilyDescriptor {
std::string name;
Expand Down
3 changes: 0 additions & 3 deletions include/rocksdb/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ class RateLimiter;
class ThreadStatusUpdater;
struct ThreadStatus;

using std::unique_ptr;
using std::shared_ptr;

const size_t kDefaultPageSize = 4 * 1024;

// Options while opening a file to read/write
Expand Down
2 changes: 0 additions & 2 deletions include/rocksdb/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class WritableFileWriter;
struct EnvOptions;
struct Options;

using std::unique_ptr;

enum ChecksumType : char {
kNoChecksum = 0x0,
kCRC32c = 0x1,
Expand Down
1 change: 0 additions & 1 deletion table/adaptive_table_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace rocksdb {

struct EnvOptions;

using std::unique_ptr;
class Status;
class RandomAccessFile;
class WritableFile;
Expand Down
1 change: 0 additions & 1 deletion table/block_based_table_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace rocksdb {

struct EnvOptions;

using std::unique_ptr;
class BlockBasedTableBuilder;

// A class used to track actual bytes written from the tail in the recent SST
Expand Down
1 change: 0 additions & 1 deletion table/block_based_table_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ namespace rocksdb {
extern const uint64_t kBlockBasedTableMagicNumber;
extern const std::string kHashIndexPrefixesBlock;
extern const std::string kHashIndexPrefixesMetadataBlock;
using std::unique_ptr;

typedef BlockBasedTable::IndexReader IndexReader;

Expand Down
2 changes: 0 additions & 2 deletions table/block_based_table_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ struct EnvOptions;
struct ReadOptions;
class GetContext;

using std::unique_ptr;

typedef std::vector<std::pair<std::string, std::string>> KVPairBlock;

// A Table is a sorted map from strings to strings. Tables are
Expand Down
1 change: 0 additions & 1 deletion table/plain_table_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace rocksdb {

struct EnvOptions;

using std::unique_ptr;
class Status;
class RandomAccessFile;
class WritableFile;
Expand Down
12 changes: 6 additions & 6 deletions table/plain_table_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ InternalIterator* PlainTableReader::NewIterator(
}

Status PlainTableReader::PopulateIndexRecordList(
PlainTableIndexBuilder* index_builder, vector<uint32_t>* prefix_hashes) {
PlainTableIndexBuilder* index_builder,
std::vector<uint32_t>* prefix_hashes) {
Slice prev_key_prefix_slice;
std::string prev_key_prefix_buf;
uint32_t pos = data_start_offset_;
Expand Down Expand Up @@ -256,10 +257,9 @@ Status PlainTableReader::PopulateIndexRecordList(
return s;
}

void PlainTableReader::AllocateAndFillBloom(int bloom_bits_per_key,
int num_prefixes,
size_t huge_page_tlb_size,
vector<uint32_t>* prefix_hashes) {
void PlainTableReader::AllocateAndFillBloom(
int bloom_bits_per_key, int num_prefixes, size_t huge_page_tlb_size,
std::vector<uint32_t>* prefix_hashes) {
if (!IsTotalOrderMode()) {
uint32_t bloom_total_bits = num_prefixes * bloom_bits_per_key;
if (bloom_total_bits > 0) {
Expand All @@ -271,7 +271,7 @@ void PlainTableReader::AllocateAndFillBloom(int bloom_bits_per_key,
}
}

void PlainTableReader::FillBloom(vector<uint32_t>* prefix_hashes) {
void PlainTableReader::FillBloom(std::vector<uint32_t>* prefix_hashes) {
assert(bloom_.IsInitialized());
for (auto prefix_hash : *prefix_hashes) {
bloom_.AddHash(prefix_hash);
Expand Down
11 changes: 4 additions & 7 deletions table/plain_table_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class InternalKeyComparator;
class PlainTableKeyDecoder;
class GetContext;

using std::unique_ptr;
using std::unordered_map;
using std::vector;
extern const uint32_t kPlainTableVariableLength;

struct PlainTableReaderFileInfo {
Expand All @@ -50,7 +47,7 @@ struct PlainTableReaderFileInfo {
uint32_t data_end_offset;
std::unique_ptr<RandomAccessFileReader> file;

PlainTableReaderFileInfo(unique_ptr<RandomAccessFileReader>&& _file,
PlainTableReaderFileInfo(std::unique_ptr<RandomAccessFileReader>&& _file,
const EnvOptions& storage_options,
uint32_t _data_size_offset)
: is_mmap_mode(storage_options.use_mmap_reads),
Expand Down Expand Up @@ -202,14 +199,14 @@ class PlainTableReader: public TableReader {
// If bloom_ is not null, all the keys' full-key hash will be added to the
// bloom filter.
Status PopulateIndexRecordList(PlainTableIndexBuilder* index_builder,
vector<uint32_t>* prefix_hashes);
std::vector<uint32_t>* prefix_hashes);

// Internal helper function to allocate memory for bloom filter and fill it
void AllocateAndFillBloom(int bloom_bits_per_key, int num_prefixes,
size_t huge_page_tlb_size,
vector<uint32_t>* prefix_hashes);
std::vector<uint32_t>* prefix_hashes);

void FillBloom(vector<uint32_t>* prefix_hashes);
void FillBloom(std::vector<uint32_t>* prefix_hashes);

// Read the key and value at `offset` to parameters for keys, the and
// `seekable`.
Expand Down
6 changes: 3 additions & 3 deletions tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ class ReportFileOpEnv : public EnvWrapper {
ReportFileOpCounters* counters_;

public:
CountingFile(unique_ptr<SequentialFile>&& target,
CountingFile(std::unique_ptr<SequentialFile>&& target,
ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {}

Expand Down Expand Up @@ -1254,7 +1254,7 @@ class ReportFileOpEnv : public EnvWrapper {
ReportFileOpCounters* counters_;

public:
CountingFile(unique_ptr<RandomAccessFile>&& target,
CountingFile(std::unique_ptr<RandomAccessFile>&& target,
ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {}
Status Read(uint64_t offset, size_t n, Slice* result,
Expand Down Expand Up @@ -1283,7 +1283,7 @@ class ReportFileOpEnv : public EnvWrapper {
ReportFileOpCounters* counters_;

public:
CountingFile(unique_ptr<WritableFile>&& target,
CountingFile(std::unique_ptr<WritableFile>&& target,
ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {}

Expand Down
4 changes: 1 addition & 3 deletions utilities/backupable/backupable_db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ namespace rocksdb {

namespace {

using std::unique_ptr;

class DummyDB : public StackableDB {
public:
/* implicit */
Expand Down Expand Up @@ -206,7 +204,7 @@ class TestEnv : public EnvWrapper {
}

Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result,
std::unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) override {
MutexLock l(&mutex_);
Status s = EnvWrapper::NewRandomAccessFile(fname, result, options);
Expand Down
2 changes: 1 addition & 1 deletion utilities/blob_db/blob_log_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace rocksdb {
namespace blob_db {

Reader::Reader(unique_ptr<RandomAccessFileReader>&& file_reader, Env* env,
Reader::Reader(std::unique_ptr<RandomAccessFileReader>&& file_reader, Env* env,
Statistics* statistics)
: file_(std::move(file_reader)),
env_(env),
Expand Down
2 changes: 1 addition & 1 deletion utilities/blob_db/blob_log_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace rocksdb {
namespace blob_db {

Writer::Writer(unique_ptr<WritableFileWriter>&& dest, Env* env,
Writer::Writer(std::unique_ptr<WritableFileWriter>&& dest, Env* env,
Statistics* statistics, uint64_t log_number, uint64_t bpsync,
bool use_fs, uint64_t boffset)
: dest_(std::move(dest)),
Expand Down

0 comments on commit 2b4d5ce

Please sign in to comment.