feat: implement last row cache reader for flat format#7757
feat: implement last row cache reader for flat format#7757evenyag merged 13 commits intoGreptimeTeam:mainfrom
Conversation
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces crucial performance enhancements for data retrieval in the flat SST format by adding a dedicated last-row caching mechanism. It extends the existing caching infrastructure to support Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a last-row cache reader for the flat SST format, which is a valuable performance optimization for a common query pattern. The changes are well-structured, with a new SelectorResult enum to handle different cache entry formats and a FlatLastTimestampSelector for the core logic. The integration into the existing read path appears correct. I have one suggestion to improve the clarity and robustness of the new reader implementation, as detailed in the comment.
Signed-off-by: evenyag <realevenyag@gmail.com>
Signed-off-by: evenyag <realevenyag@gmail.com>
- Replace VecDeque with BatchBuffer struct for output buffering - Remove rebuild_pk_dictionary_for_key as batches go directly into buffer - Remove unused push method and make BatchBuffer pub(crate) - Remove debug logging in maybe_update_cache Signed-off-by: evenyag <realevenyag@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c86866ddc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: evenyag <realevenyag@gmail.com>
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
#7732
What's changed and what's your intention?
FlatRowGroupLastRowCachedReaderandFlatLastTimestampSelectorto support last-row selectionand caching for the flat SST format, mirroring the existing primary-key format cache
SelectorResultValuewith aSelectorResultenum to store either primary-keyBatchorflat
RecordBatchcache entriesPUT-only and all rows are selected
TSBS lastpoint without cache:
with cache
Details
The existing last-row cache (
RowGroupLastRowCachedReader) only works with the primary-key SSTformat. This PR adds equivalent support for the flat format:
FlatLastTimestampSelector: Processes sorted flatRecordBatches, tracking primary keyboundaries to emit only the row with the latest timestamp per series. Handles primary keys spanning
multiple batches and deduplicates timestamps across batch boundaries.
FlatRowGroupLastRowCachedReader: Cache-aware reader that checks for cached flat results onhit, or reads through
FlatRowGroupReaderand populates the cache on miss.SelectorResultenum: The cache value type now distinguishes betweenPrimaryKey(Vec<Batch>)and
Flat(Vec<RecordBatch>)variants. Cache lookups validate both format and projection match beforereturning hits.
FileRange::flat_readernow accepts an optionalTimeSeriesRowSelectorand creates thelast-row reader when applicable (PUT-only, all rows selected).
Future Work
The ScanHint rule will ensure it only passes the last row hint when there are only tag filters. So the last row cache doesn't consider field filters now. We can support a more flexible last row cache in the future.
PR Checklist
Please convert it to a draft if some of the following conditions are not met.