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: Implement memtable range #4162

Merged
merged 10 commits into from
Jun 18, 2024
Merged

Conversation

evenyag
Copy link
Contributor

@evenyag evenyag commented Jun 18, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

This PR implements MemtableRange to represent a partition (range) of a memtable. This allows iterating the memtable concurrently. The memtable range keeps an IterBuilder to build an iterator to read that range.

The Memtable trait has a new method ranges() to return the list of ranges to read. Both time_series and partition_tree memtables return just 1 range.

The ScanPart now keeps a list of MemtableRange instead of Memtable.

It also refactors the FileRange and extracts a struct RangeBase so we can reuse it in other places. The RangeBase contains fields to prune batches from a file.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jun 18, 2024
@evenyag evenyag marked this pull request as ready for review June 18, 2024 07:33
@evenyag evenyag requested review from v0y4g3r, waynexia and a team as code owners June 18, 2024 07:33
@v0y4g3r
Copy link
Contributor

v0y4g3r commented Jun 18, 2024

Is it possible to completely deprecate Memtable::iter with Memtable::range? I think range is more generic and compatible with current RegionScanner design. In the long term, memtable should be considered as an in-memory file part just like those in disks.

@evenyag evenyag requested a review from WenyXu June 18, 2024 07:49
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 22 lines in your changes missing coverage. Please review.

Project coverage is 84.59%. Comparing base (0fc18b6) to head (3e00faf).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4162      +/-   ##
==========================================
- Coverage   84.92%   84.59%   -0.34%     
==========================================
  Files        1023     1024       +1     
  Lines      179298   179502     +204     
==========================================
- Hits       152272   151846     -426     
- Misses      27026    27656     +630     

src/mito2/src/memtable.rs Show resolved Hide resolved
src/mito2/src/memtable.rs Show resolved Hide resolved
@v0y4g3r v0y4g3r self-requested a review June 18, 2024 08:44
Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

LGTM

@evenyag
Copy link
Contributor Author

evenyag commented Jun 18, 2024

Is it possible to completely deprecate Memtable::iter with Memtable::range?

It should be possible. Do we need to do it in this PR? Maybe we can deprecate iter() after ranges() is stable.

Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

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

LGTM

@killme2008 killme2008 added this pull request to the merge queue Jun 18, 2024
Merged via the queue into GreptimeTeam:main with commit fe74efd Jun 18, 2024
98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants