Rename pending_flush_ to queued_for_flush_.

Summary:
With ColumnFamilyData::pending_flush_, we have the following code snippet in DBImpl::ScheedulePendingFlush

```
if (!cfd->pending_flush() && cfd->imm()->IsFlushPending()) {
...
}
```

`Pending` is ambiguous, and I feel `queued_for_flush` is a better name,
especially for the sake of readability.
Closes https://github.com/facebook/rocksdb/pull/3777

Differential Revision: D7783066

Pulled By: riversand963

fbshipit-source-id: f1bd8c8bfe5eafd2c94da0d8566c9b2b6bb57229
main
Yanqin Jin 7 years ago committed by Facebook Github Bot
parent 37cd617b6b
commit 513b5ce618
  1. 4
      db/column_family.cc
  2. 6
      db/column_family.h
  3. 10
      db/db_impl_compaction_flush.cc

@ -427,7 +427,7 @@ ColumnFamilyData::ColumnFamilyData(
log_number_(0), log_number_(0),
flush_reason_(FlushReason::kOthers), flush_reason_(FlushReason::kOthers),
column_family_set_(column_family_set), column_family_set_(column_family_set),
pending_flush_(false), queued_for_flush_(false),
pending_compaction_(false), pending_compaction_(false),
prev_compaction_needed_bytes_(0), prev_compaction_needed_bytes_(0),
allow_2pc_(db_options.allow_2pc), allow_2pc_(db_options.allow_2pc),
@ -504,7 +504,7 @@ ColumnFamilyData::~ColumnFamilyData() {
// It would be wrong if this ColumnFamilyData is in flush_queue_ or // It would be wrong if this ColumnFamilyData is in flush_queue_ or
// compaction_queue_ and we destroyed it // compaction_queue_ and we destroyed it
assert(!pending_flush_); assert(!queued_for_flush_);
assert(!pending_compaction_); assert(!pending_compaction_);
if (super_version_ != nullptr) { if (super_version_ != nullptr) {

@ -345,9 +345,9 @@ class ColumnFamilyData {
void ResetThreadLocalSuperVersions(); void ResetThreadLocalSuperVersions();
// Protected by DB mutex // Protected by DB mutex
void set_pending_flush(bool value) { pending_flush_ = value; } void set_queued_for_flush(bool value) { queued_for_flush_ = value; }
void set_pending_compaction(bool value) { pending_compaction_ = value; } void set_pending_compaction(bool value) { pending_compaction_ = value; }
bool pending_flush() { return pending_flush_; } bool queued_for_flush() { return queued_for_flush_; }
bool pending_compaction() { return pending_compaction_; } bool pending_compaction() { return pending_compaction_; }
enum class WriteStallCause { enum class WriteStallCause {
@ -453,7 +453,7 @@ class ColumnFamilyData {
std::unique_ptr<WriteControllerToken> write_controller_token_; std::unique_ptr<WriteControllerToken> write_controller_token_;
// If true --> this ColumnFamily is currently present in DBImpl::flush_queue_ // If true --> this ColumnFamily is currently present in DBImpl::flush_queue_
bool pending_flush_; bool queued_for_flush_;
// If true --> this ColumnFamily is currently present in // If true --> this ColumnFamily is currently present in
// DBImpl::compaction_queue_ // DBImpl::compaction_queue_

@ -1288,10 +1288,10 @@ ColumnFamilyData* DBImpl::PopFirstFromCompactionQueue() {
} }
void DBImpl::AddToFlushQueue(ColumnFamilyData* cfd, FlushReason flush_reason) { void DBImpl::AddToFlushQueue(ColumnFamilyData* cfd, FlushReason flush_reason) {
assert(!cfd->pending_flush()); assert(!cfd->queued_for_flush());
cfd->Ref(); cfd->Ref();
flush_queue_.push_back(cfd); flush_queue_.push_back(cfd);
cfd->set_pending_flush(true); cfd->set_queued_for_flush(true);
cfd->SetFlushReason(flush_reason); cfd->SetFlushReason(flush_reason);
} }
@ -1299,15 +1299,15 @@ ColumnFamilyData* DBImpl::PopFirstFromFlushQueue() {
assert(!flush_queue_.empty()); assert(!flush_queue_.empty());
auto cfd = *flush_queue_.begin(); auto cfd = *flush_queue_.begin();
flush_queue_.pop_front(); flush_queue_.pop_front();
assert(cfd->pending_flush()); assert(cfd->queued_for_flush());
cfd->set_pending_flush(false); cfd->set_queued_for_flush(false);
// TODO: need to unset flush reason? // TODO: need to unset flush reason?
return cfd; return cfd;
} }
void DBImpl::SchedulePendingFlush(ColumnFamilyData* cfd, void DBImpl::SchedulePendingFlush(ColumnFamilyData* cfd,
FlushReason flush_reason) { FlushReason flush_reason) {
if (!cfd->pending_flush() && cfd->imm()->IsFlushPending()) { if (!cfd->queued_for_flush() && cfd->imm()->IsFlushPending()) {
AddToFlushQueue(cfd, flush_reason); AddToFlushQueue(cfd, flush_reason);
++unscheduled_flushes_; ++unscheduled_flushes_;
} }

Loading…
Cancel
Save