Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pageserver): add iterator API for btree reader #8083

Merged
merged 3 commits into from
Jun 18, 2024
Merged

Conversation

skyzh
Copy link
Member

@skyzh skyzh commented Jun 17, 2024

Problem

The new image iterator and delta iterator uses an iterator-based API. #8006 / part of #8002

This requires the underlying thing (the btree) to have an iterator API, and the iterator should have a type name so that it can be stored somewhere.

pub struct DeltaLayerIterator {
  index_iterator: BTreeIterator
}

versus

pub struct DeltaLayerIterator {
  index_iterator: impl Stream<....>
}

(this requires nightly flag and still buggy in the Rust compiler)

There are multiple ways to achieve this:

  1. Either write a BTreeIterator from scratch that provides async next. This is the most efficient way to do that.
  2. Or wrap the current get_stream API, which is the current approach in the pull request.

In the future, we should do (1), and the get_stream API should be refactored to use the iterator API. With (2), we have to wrap the get_stream API with Pin<Box<dyn Stream>>, where we have the overhead of dynamic dispatch. However, (2) needs a rewrite of the visit function, which would take some time to write and review. I'd like to define this iterator API first and work on a real iterator API later.

Summary of changes

Add DiskBtreeIterator and related tests.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • Do we need to implement analytics? if so did you add the relevant metrics to the dashboard?
  • If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section.

Checklist before merging

  • Do not forget to reformat commit message to not include the above checklist

Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh requested a review from VladLazar June 17, 2024 18:47
@skyzh skyzh requested a review from a team as a code owner June 17, 2024 18:47
Copy link

github-actions bot commented Jun 17, 2024

3222 tests run: 3105 passed, 0 failed, 117 skipped (full report)


Flaky tests (1)

Postgres 14

Code coverage* (full report)

  • functions: 32.4% (6842 of 21103 functions)
  • lines: 50.0% (53401 of 106835 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
24462d1 at 2024-06-18T19:36:57.961Z :recycle:

Copy link
Contributor

@VladLazar VladLazar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but clippy is complaining

Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh enabled auto-merge (squash) June 18, 2024 14:42
@skyzh skyzh merged commit 68476bb into main Jun 18, 2024
57 checks passed
@skyzh skyzh deleted the skyzh/btree-iter branch June 18, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants