[RocksDB] Replace iterator based loop with range based loop for stl containers
Summary: As title. Code is shorter and cleaner See https://our.dev.facebook.com/intern/tasks/?t=2233981 Test Plan: make check Reviewers: dhruba, heyongqiang Reviewed By: dhruba CC: leveldb, zshao Differential Revision: https://reviews.facebook.net/D9789
This commit is contained in:
parent
d815082159
commit
6763110867
@ -443,12 +443,9 @@ void DBImpl::PurgeObsoleteWALFiles() {
|
|||||||
int64_t currentTime;
|
int64_t currentTime;
|
||||||
const Status status = env_->GetCurrentTime(¤tTime);
|
const Status status = env_->GetCurrentTime(¤tTime);
|
||||||
assert(status.ok());
|
assert(status.ok());
|
||||||
for (std::vector<std::string>::iterator it = WALFiles.begin();
|
for (const auto& f : WALFiles) {
|
||||||
it != WALFiles.end();
|
|
||||||
++it) {
|
|
||||||
|
|
||||||
uint64_t fileMTime;
|
uint64_t fileMTime;
|
||||||
const std::string filePath = archivalDir + "/" + *it;
|
const std::string filePath = archivalDir + "/" + f;
|
||||||
const Status s = env_->GetFileModificationTime(filePath, &fileMTime);
|
const Status s = env_->GetFileModificationTime(filePath, &fileMTime);
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
if (status.ok() &&
|
if (status.ok() &&
|
||||||
@ -1051,12 +1048,10 @@ Status DBImpl::ListAllWALFiles(const std::string& path,
|
|||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
for(std::vector<std::string>::iterator it = allFiles.begin();
|
for (const auto& f : allFiles) {
|
||||||
it != allFiles.end();
|
|
||||||
++it) {
|
|
||||||
uint64_t number;
|
uint64_t number;
|
||||||
FileType type;
|
FileType type;
|
||||||
if (ParseFileName(*it, &number, &type) && type == kLogFile){
|
if (ParseFileName(f, &number, &type) && type == kLogFile){
|
||||||
logFiles->push_back(LogFile(number, logType));
|
logFiles->push_back(LogFile(number, logType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1366,10 +1361,7 @@ void DBImpl::AllocateCompactionOutputFileNumbers(CompactionState* compact) {
|
|||||||
// Frees up unused file number.
|
// Frees up unused file number.
|
||||||
void DBImpl::ReleaseCompactionUnusedFileNumbers(CompactionState* compact) {
|
void DBImpl::ReleaseCompactionUnusedFileNumbers(CompactionState* compact) {
|
||||||
mutex_.AssertHeld();
|
mutex_.AssertHeld();
|
||||||
for (std::list<uint64_t>::iterator it =
|
for (const auto file_number : compact->allocated_file_numbers) {
|
||||||
compact->allocated_file_numbers.begin();
|
|
||||||
it != compact->allocated_file_numbers.end(); ++it) {
|
|
||||||
uint64_t file_number = *it;
|
|
||||||
pending_outputs_.erase(file_number);
|
pending_outputs_.erase(file_number);
|
||||||
// Log(options_.info_log, "XXX releasing unused file num %d", file_number);
|
// Log(options_.info_log, "XXX releasing unused file num %d", file_number);
|
||||||
}
|
}
|
||||||
@ -1513,13 +1505,13 @@ Status DBImpl::InstallCompactionResults(CompactionState* compact) {
|
|||||||
inline SequenceNumber DBImpl::findEarliestVisibleSnapshot(
|
inline SequenceNumber DBImpl::findEarliestVisibleSnapshot(
|
||||||
SequenceNumber in, std::vector<SequenceNumber>& snapshots) {
|
SequenceNumber in, std::vector<SequenceNumber>& snapshots) {
|
||||||
SequenceNumber prev __attribute__((unused)) = 0;
|
SequenceNumber prev __attribute__((unused)) = 0;
|
||||||
for (std::vector<SequenceNumber>::iterator it = snapshots.begin();
|
for (const auto cur : snapshots) {
|
||||||
it < snapshots.end(); it++) {
|
assert(prev <= cur);
|
||||||
assert (prev <= *it);
|
if (cur >= in) {
|
||||||
if (*it >= in) {
|
return cur;
|
||||||
return *it;
|
|
||||||
}
|
}
|
||||||
assert(prev = *it); // assignment
|
prev = cur; // assignment
|
||||||
|
assert(prev);
|
||||||
}
|
}
|
||||||
Log(options_.info_log,
|
Log(options_.info_log,
|
||||||
"Looking for seqid %ld but maxseqid is %ld", in,
|
"Looking for seqid %ld but maxseqid is %ld", in,
|
||||||
|
Loading…
Reference in New Issue
Block a user