google / google/leveldb

Why SkipEmptyDataBlocksForward in the end of SeekToFirst

Open
#1,049 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.4k
Forks
8.2k
PR merge metrics
No merged PRs in 30d

Description

Comment of `Iterator::SeekToFirst` says that the iterator is valid iff the source is not empty, I think if the first element is corrupted, the iterator should be invalid, like `Block::Iter` does.
`TwoLevelIterator::SeekToFirst`'s definition is :
```
index_iter_.SeekToFirst();
InitDataBlock();
if (data_iter_.iter() != nullptr) data_iter_.SeekToFirst();
SkipEmptyDataBlocksForward();
```
Let's say that we use it to iterate over single SST. If the first key-value pair is corrupted, `SkipEmptyDataBlocksForward` will move to the next available data block rather than invalidate the whole iterator.

The `Block::Iter` and `TwoLevelIterator` behaves differently IMO, what's the purpose? Thanks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.