Skip to content

Commit

Permalink
Use delete to disable automatic generated methods. (facebook#5009)
Browse files Browse the repository at this point in the history
Summary:
Use delete to disable automatic generated methods instead of private, and put the constructor together for more clear.This modification cause the unused field warning, so add unused attribute to disable this warning.
Pull Request resolved: facebook#5009

Differential Revision: D17288733

fbshipit-source-id: 8a767ce096f185f1db01bd28fc88fef1cdd921f3
  • Loading branch information
Shylock-Hg authored and facebook-github-bot committed Sep 12, 2019
1 parent fcda80f commit 9eb3e1f
Show file tree
Hide file tree
Showing 46 changed files with 205 additions and 219 deletions.
8 changes: 4 additions & 4 deletions db/compacted_db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ namespace rocksdb {
class CompactedDBImpl : public DBImpl {
public:
CompactedDBImpl(const DBOptions& options, const std::string& dbname);
// No copying allowed
CompactedDBImpl(const CompactedDBImpl&) = delete;
void operator=(const CompactedDBImpl&) = delete;

virtual ~CompactedDBImpl();

static Status Open(const Options& options, const std::string& dbname,
Expand Down Expand Up @@ -104,10 +108,6 @@ class CompactedDBImpl : public DBImpl {
Version* version_;
const Comparator* user_comparator_;
LevelFilesBrief files_;

// No copying allowed
CompactedDBImpl(const CompactedDBImpl&);
void operator=(const CompactedDBImpl&);
};
}
#endif // ROCKSDB_LITE
8 changes: 4 additions & 4 deletions db/db_impl/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class DBImpl : public DB {
public:
DBImpl(const DBOptions& options, const std::string& dbname,
const bool seq_per_batch = false, const bool batch_per_txn = true);
// No copying allowed
DBImpl(const DBImpl&) = delete;
void operator=(const DBImpl&) = delete;

virtual ~DBImpl();

// ---- Implementations of the DB interface ----
Expand Down Expand Up @@ -1563,10 +1567,6 @@ class DBImpl : public DB {

void WaitForBackgroundWork();

// No copying allowed
DBImpl(const DBImpl&);
void operator=(const DBImpl&);

// Background threads call this function, which is just a wrapper around
// the InstallSuperVersion() function. Background threads carry
// sv_context which can have new_superversion already
Expand Down
8 changes: 4 additions & 4 deletions db/db_impl/db_impl_readonly.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ namespace rocksdb {
class DBImplReadOnly : public DBImpl {
public:
DBImplReadOnly(const DBOptions& options, const std::string& dbname);
// No copying allowed
DBImplReadOnly(const DBImplReadOnly&) = delete;
void operator=(const DBImplReadOnly&) = delete;

virtual ~DBImplReadOnly();

// Implementations of the DB interface
Expand Down Expand Up @@ -127,10 +131,6 @@ class DBImplReadOnly : public DBImpl {

private:
friend class DB;

// No copying allowed
DBImplReadOnly(const DBImplReadOnly&);
void operator=(const DBImplReadOnly&);
};
} // namespace rocksdb

Expand Down
14 changes: 10 additions & 4 deletions db/db_iter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ class DBIter final: public Iterator {
iter_.iter()->SetPinnedItersMgr(&pinned_iters_mgr_);
}
}
// No copying allowed
DBIter(const DBIter&) = delete;
void operator=(const DBIter&) = delete;

~DBIter() override {
// Release pinned data if any
if (pinned_iters_mgr_.PinningEnabled()) {
Expand Down Expand Up @@ -345,15 +349,17 @@ class DBIter final: public Iterator {
ReadRangeDelAggregator range_del_agg_;
LocalStatistics local_stats_;
PinnedIteratorsManager pinned_iters_mgr_;
#ifdef ROCKSDB_LITE
ROCKSDB_FIELD_UNUSED
#endif
DBImpl* db_impl_;
#ifdef ROCKSDB_LITE
ROCKSDB_FIELD_UNUSED
#endif
ColumnFamilyData* cfd_;
// for diff snapshots we want the lower bound on the seqnum;
// if this value > 0 iterator will return internal keys
SequenceNumber start_seqnum_;

// No copying allowed
DBIter(const DBIter&);
void operator=(const DBIter&);
};

inline bool DBIter::ParseKey(ParsedInternalKey* ikey) {
Expand Down
7 changes: 3 additions & 4 deletions db/dbformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ class IterKey {
key_size_(0),
buf_size_(sizeof(space_)),
is_user_key_(true) {}
// No copying allowed
IterKey(const IterKey&) = delete;
void operator=(const IterKey&) = delete;

~IterKey() { ResetBuffer(); }

Expand Down Expand Up @@ -523,10 +526,6 @@ class IterKey {
}

void EnlargeBuffer(size_t key_size);

// No copying allowed
IterKey(const IterKey&) = delete;
void operator=(const IterKey&) = delete;
};

// Convert from a SliceTranform of user keys, to a SliceTransform of
Expand Down
8 changes: 3 additions & 5 deletions db/log_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Reader {
// @lint-ignore TXT2 T25377293 Grandfathered in
std::unique_ptr<SequentialFileReader>&& file, Reporter* reporter,
bool checksum, uint64_t log_num);
// No copying allowed
Reader(const Reader&) = delete;
void operator=(const Reader&) = delete;

virtual ~Reader();

Expand Down Expand Up @@ -148,11 +151,6 @@ class Reader {
// buffer_ must be updated to remove the dropped bytes prior to invocation.
void ReportCorruption(size_t bytes, const char* reason);
void ReportDrop(size_t bytes, const Status& reason);

private:
// No copying allowed
Reader(const Reader&);
void operator=(const Reader&);
};

class FragmentBufferedReader : public Reader {
Expand Down
8 changes: 4 additions & 4 deletions db/log_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class Writer {
explicit Writer(std::unique_ptr<WritableFileWriter>&& dest,
uint64_t log_number, bool recycle_log_files,
bool manual_flush = false);
// No copying allowed
Writer(const Writer&) = delete;
void operator=(const Writer&) = delete;

~Writer();

Status AddRecord(const Slice& slice);
Expand Down Expand Up @@ -104,10 +108,6 @@ class Writer {
// If true, it does not flush after each write. Instead it relies on the upper
// layer to manually does the flush by calling ::WriteBuffer()
bool manual_flush_;

// No copying allowed
Writer(const Writer&);
void operator=(const Writer&);
};

} // namespace log
Expand Down
7 changes: 3 additions & 4 deletions db/memtable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ class MemTableIterator : public InternalIterator {
iter_ = mem.table_->GetIterator(arena);
}
}
// No copying allowed
MemTableIterator(const MemTableIterator&) = delete;
void operator=(const MemTableIterator&) = delete;

~MemTableIterator() override {
#ifndef NDEBUG
Expand Down Expand Up @@ -408,10 +411,6 @@ class MemTableIterator : public InternalIterator {
bool valid_;
bool arena_mode_;
bool value_pinned_;

// No copying allowed
MemTableIterator(const MemTableIterator&);
void operator=(const MemTableIterator&);
};

InternalIterator* MemTable::NewIterator(const ReadOptions& read_options,
Expand Down
7 changes: 3 additions & 4 deletions db/memtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class MemTable {
const MutableCFOptions& mutable_cf_options,
WriteBufferManager* write_buffer_manager,
SequenceNumber earliest_seq, uint32_t column_family_id);
// No copying allowed
MemTable(const MemTable&) = delete;
MemTable& operator=(const MemTable&) = delete;

// Do not delete this MemTable unless Unref() indicates it not in use.
~MemTable();
Expand Down Expand Up @@ -503,10 +506,6 @@ class MemTable {
void UpdateFlushState();

void UpdateOldestKeyTime();

// No copying allowed
MemTable(const MemTable&);
MemTable& operator=(const MemTable&);
};

extern const char* EncodeKey(std::string* scratch, const Slice& target);
Expand Down
18 changes: 9 additions & 9 deletions db/version_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class VersionStorageInfo {
CompactionStyle compaction_style,
VersionStorageInfo* src_vstorage,
bool _force_consistency_checks);
// No copying allowed
VersionStorageInfo(const VersionStorageInfo&) = delete;
void operator=(const VersionStorageInfo&) = delete;
~VersionStorageInfo();

void Reserve(int level, size_t size) { files_[level].reserve(size); }
Expand Down Expand Up @@ -542,9 +545,6 @@ class VersionStorageInfo {

friend class Version;
friend class VersionSet;
// No copying allowed
VersionStorageInfo(const VersionStorageInfo&) = delete;
void operator=(const VersionStorageInfo&) = delete;
};

using MultiGetRange = MultiGetContext::Range;
Expand Down Expand Up @@ -734,8 +734,8 @@ class Version {
~Version();

// No copying allowed
Version(const Version&);
void operator=(const Version&);
Version(const Version&) = delete;
void operator=(const Version&) = delete;
};

struct ObsoleteFileInfo {
Expand Down Expand Up @@ -797,6 +797,10 @@ class VersionSet {
WriteBufferManager* write_buffer_manager,
WriteController* write_controller,
BlockCacheTracer* const block_cache_tracer);
// No copying allowed
VersionSet(const VersionSet&) = delete;
void operator=(const VersionSet&) = delete;

virtual ~VersionSet();

// Apply *edit to the current version to form a new descriptor that
Expand Down Expand Up @@ -1143,10 +1147,6 @@ class VersionSet {
BlockCacheTracer* const block_cache_tracer_;

private:
// No copying allowed
VersionSet(const VersionSet&);
void operator=(const VersionSet&);

// REQUIRES db mutex at beginning. may release and re-acquire db mutex
Status ProcessManifestWrites(std::deque<ManifestWriter>& writers,
InstrumentedMutex* mu, Directory* db_directory,
Expand Down
7 changes: 3 additions & 4 deletions env/mock_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class MemFile {
rnd_(static_cast<uint32_t>(
MurmurHash(fn.data(), static_cast<int>(fn.size()), 0))),
fsynced_bytes_(0) {}
// No copying allowed.
MemFile(const MemFile&) = delete;
void operator=(const MemFile&) = delete;

void Ref() {
MutexLock lock(&mutex_);
Expand Down Expand Up @@ -154,10 +157,6 @@ class MemFile {
// Private since only Unref() should be used to delete it.
~MemFile() { assert(refs_ == 0); }

// No copying allowed.
MemFile(const MemFile&);
void operator=(const MemFile&);

Env* env_;
const std::string fn_;
mutable port::Mutex mutex_;
Expand Down
7 changes: 3 additions & 4 deletions include/rocksdb/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class Cache {

Cache(std::shared_ptr<MemoryAllocator> allocator = nullptr)
: memory_allocator_(std::move(allocator)) {}
// No copying allowed
Cache(const Cache&) = delete;
Cache& operator=(const Cache&) = delete;

// Destroys all existing entries by calling the "deleter"
// function that was passed via the Insert() function.
Expand Down Expand Up @@ -253,10 +256,6 @@ class Cache {
MemoryAllocator* memory_allocator() const { return memory_allocator_.get(); }

private:
// No copying allowed
Cache(const Cache&);
Cache& operator=(const Cache&);

std::shared_ptr<MemoryAllocator> memory_allocator_;
};

Expand Down
4 changes: 2 additions & 2 deletions include/rocksdb/cleanable.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ namespace rocksdb {
class Cleanable {
public:
Cleanable();
~Cleanable();

// No copy constructor and copy assignment allowed.
Cleanable(Cleanable&) = delete;
Cleanable& operator=(Cleanable&) = delete;

~Cleanable();

// Move constructor and move assignment is allowed.
Cleanable(Cleanable&&);
Cleanable& operator=(Cleanable&&);
Expand Down
9 changes: 4 additions & 5 deletions include/rocksdb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ class DB {
std::vector<std::string>* column_families);

DB() {}
// No copying allowed
DB(const DB&) = delete;
void operator=(const DB&) = delete;

virtual ~DB();

// Create a column_family and return the handle of column family
Expand Down Expand Up @@ -1421,11 +1425,6 @@ class DB {
return Status::NotSupported("Supported only by secondary instance");
}
#endif // !ROCKSDB_LITE

private:
// No copying allowed
DB(const DB&);
void operator=(const DB&);
};

// Destroy the contents of the specified database.
Expand Down
Loading

0 comments on commit 9eb3e1f

Please sign in to comment.