Skip to content

Commit

Permalink
ForwardIterator: used newly added VersionStorageInfo::FindFileInRange
Browse files Browse the repository at this point in the history
  • Loading branch information
rockeet committed Aug 28, 2022
1 parent 30d2a6e commit aaff2e1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
14 changes: 1 addition & 13 deletions db/forward_iterator.cc
Expand Up @@ -464,7 +464,7 @@ void ForwardIterator::SeekInternal(const Slice& internal_key,
}
uint32_t f_idx = 0;
if (!seek_to_first) {
f_idx = FindFileInRange(level_files, internal_key, 0,
f_idx = vstorage->FindFileInRange(level, internal_key, 0,
static_cast<uint32_t>(level_files.size()));
}

Expand Down Expand Up @@ -991,18 +991,6 @@ bool ForwardIterator::TEST_CheckDeletedIters(int* pdeleted_iters,
return retval;
}

uint32_t ForwardIterator::FindFileInRange(
const std::vector<FileMetaData*>& files, const Slice& internal_key,
uint32_t left, uint32_t right) {
auto cmp = [&](const FileMetaData* f, const Slice& k) -> bool {
return cfd_->internal_comparator().InternalKeyComparator::Compare(
f->largest.Encode(), k) < 0;
};
const auto &b = files.begin();
return static_cast<uint32_t>(std::lower_bound(b + left,
b + right, internal_key, cmp) - b);
}

void ForwardIterator::DeleteIterator(InternalIterator* iter, bool is_arena) {
if (iter == nullptr) {
return;
Expand Down
4 changes: 0 additions & 4 deletions db/forward_iterator.h
Expand Up @@ -105,10 +105,6 @@ class ForwardIterator : public InternalIterator {
void UpdateCurrent();
bool NeedToSeekImmutable(const Slice& internal_key);
void DeleteCurrentIter();
uint32_t FindFileInRange(
const std::vector<FileMetaData*>& files, const Slice& internal_key,
uint32_t left, uint32_t right);

bool IsOverUpperBound(const Slice& internal_key) const;

// Set PinnedIteratorsManager for all children Iterators, this function should
Expand Down
6 changes: 6 additions & 0 deletions db/version_set.cc
Expand Up @@ -3823,6 +3823,12 @@ uint64_t VersionStorageInfo::NumLevelBytes(int level) const {
return TotalFileSize(files_[level]);
}

int VersionStorageInfo::FindFileInRange(int level, const Slice& key,
uint32_t left, uint32_t right) const {
return ROCKSDB_NAMESPACE::FindFileInRange(*internal_comparator_,
level_files_brief_[level], key, left, right);
}

const char* VersionStorageInfo::LevelSummary(
LevelSummaryStorage* scratch) const {
int len = 0;
Expand Down
2 changes: 2 additions & 0 deletions db/version_set.h
Expand Up @@ -315,6 +315,8 @@ class VersionStorageInfo {
return files_[level];
}

int FindFileInRange(int level, const Slice& key, uint32_t left, uint32_t right) const;

class FileLocation {
public:
FileLocation() = default;
Expand Down

0 comments on commit aaff2e1

Please sign in to comment.