ExtendOverlappingInputs too slow for large databases.
Summary: There was a bug in the ExtendOverlappingInputs method so that the terminating condition for the backward search was incorrect. Test Plan: make clean check Reviewers: sheki, emayanke, MarkCallaghan Reviewed By: MarkCallaghan CC: leveldb Differential Revision: https://reviews.facebook.net/D7725
This commit is contained in:
parent
2fc394a327
commit
d7d43ae21a
@ -589,27 +589,39 @@ void Version::ExtendOverlappingInputs(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
int startIndex = midIndex + 1;
|
||||||
|
int endIndex = midIndex;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
// check backwards from 'mid' to lower indices
|
// check backwards from 'mid' to lower indices
|
||||||
for (size_t i = midIndex; i < files_[level].size(); i--) {
|
for (int i = midIndex; i >= 0 ; i--) {
|
||||||
FileMetaData* f = files_[level][i];
|
FileMetaData* f = files_[level][i];
|
||||||
const Slice file_limit = f->largest.user_key();
|
const Slice file_limit = f->largest.user_key();
|
||||||
if (user_cmp->Compare(file_limit, user_begin) >= 0) {
|
if (user_cmp->Compare(file_limit, user_begin) >= 0) {
|
||||||
inputs->insert(inputs->begin(), f); // insert into beginning of vector
|
startIndex = i;
|
||||||
|
assert((count++, true));
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check forward from 'mid+1' to higher indices
|
// check forward from 'mid+1' to higher indices
|
||||||
for (size_t i = midIndex+1; i < files_[level].size(); i++) {
|
for (unsigned int i = midIndex+1; i < files_[level].size(); i++) {
|
||||||
FileMetaData* f = files_[level][i];
|
FileMetaData* f = files_[level][i];
|
||||||
const Slice file_start = f->smallest.user_key();
|
const Slice file_start = f->smallest.user_key();
|
||||||
if (user_cmp->Compare(file_start, user_end) <= 0) {
|
if (user_cmp->Compare(file_start, user_end) <= 0) {
|
||||||
inputs->push_back(f); // insert into end of vector
|
assert((count++, true));
|
||||||
|
endIndex = i;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert(count == endIndex - startIndex + 1);
|
||||||
|
|
||||||
|
// insert overlapping files into vector
|
||||||
|
for (int i = startIndex; i <= endIndex; i++) {
|
||||||
|
FileMetaData* f = files_[level][i];
|
||||||
|
inputs->push_back(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Version::DebugString(bool hex) const {
|
std::string Version::DebugString(bool hex) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user