Skip to content

Commit

Permalink
Rename pending_flush_ to queued_for_flush_.
Browse files Browse the repository at this point in the history
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 facebook#3777

Differential Revision: D7783066

Pulled By: riversand963

fbshipit-source-id: f1bd8c8bfe5eafd2c94da0d8566c9b2b6bb57229
  • Loading branch information
riversand963 authored and facebook-github-bot committed Apr 27, 2018
1 parent 37cd617 commit 513b5ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions db/column_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ ColumnFamilyData::ColumnFamilyData(
log_number_(0),
flush_reason_(FlushReason::kOthers),
column_family_set_(column_family_set),
pending_flush_(false),
queued_for_flush_(false),
pending_compaction_(false),
prev_compaction_needed_bytes_(0),
allow_2pc_(db_options.allow_2pc),
Expand Down Expand Up @@ -504,7 +504,7 @@ ColumnFamilyData::~ColumnFamilyData() {

// It would be wrong if this ColumnFamilyData is in flush_queue_ or
// compaction_queue_ and we destroyed it
assert(!pending_flush_);
assert(!queued_for_flush_);
assert(!pending_compaction_);

if (super_version_ != nullptr) {
Expand Down
6 changes: 3 additions & 3 deletions db/column_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ class ColumnFamilyData {
void ResetThreadLocalSuperVersions();

// 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; }
bool pending_flush() { return pending_flush_; }
bool queued_for_flush() { return queued_for_flush_; }
bool pending_compaction() { return pending_compaction_; }

enum class WriteStallCause {
Expand Down Expand Up @@ -453,7 +453,7 @@ class ColumnFamilyData {
std::unique_ptr<WriteControllerToken> write_controller_token_;

// 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
// DBImpl::compaction_queue_
Expand Down
10 changes: 5 additions & 5 deletions db/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1288,26 +1288,26 @@ ColumnFamilyData* DBImpl::PopFirstFromCompactionQueue() {
}

void DBImpl::AddToFlushQueue(ColumnFamilyData* cfd, FlushReason flush_reason) {
assert(!cfd->pending_flush());
assert(!cfd->queued_for_flush());
cfd->Ref();
flush_queue_.push_back(cfd);
cfd->set_pending_flush(true);
cfd->set_queued_for_flush(true);
cfd->SetFlushReason(flush_reason);
}

ColumnFamilyData* DBImpl::PopFirstFromFlushQueue() {
assert(!flush_queue_.empty());
auto cfd = *flush_queue_.begin();
flush_queue_.pop_front();
assert(cfd->pending_flush());
cfd->set_pending_flush(false);
assert(cfd->queued_for_flush());
cfd->set_queued_for_flush(false);
// TODO: need to unset flush reason?
return cfd;
}

void DBImpl::SchedulePendingFlush(ColumnFamilyData* cfd,
FlushReason flush_reason) {
if (!cfd->pending_flush() && cfd->imm()->IsFlushPending()) {
if (!cfd->queued_for_flush() && cfd->imm()->IsFlushPending()) {
AddToFlushQueue(cfd, flush_reason);
++unscheduled_flushes_;
}
Expand Down

0 comments on commit 513b5ce

Please sign in to comment.