-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(store/v2): support reverse iteration for PebbleDB #18193
Conversation
WalkthroughThis change introduces reverse iteration support for the PebbleDB database, with necessary modifications in the iterator logic and associated tests. It also enhances key validation in the Changes
TipsChat with CodeRabbit Bot (
|
@alexanderbez your pull request is missing a changelog! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files selected for processing (3)
- store/storage/pebbledb/db.go (1 hunks)
- store/storage/pebbledb/db_test.go (2 hunks)
- store/storage/pebbledb/iterator.go (4 hunks)
Files skipped from review due to trivial changes (1)
- store/storage/pebbledb/db_test.go
Additional comments (Suppressed): 9
store/storage/pebbledb/iterator.go (4)
29-29: The
reverse
field has been added to theiterator
struct to control the direction of iteration. Ensure that this field is properly initialized and used throughout the codebase.32-39: The
newPebbleDBIterator
function now accepts areverse
parameter and uses it to determine the initial position of the iterator. This is a breaking change and all calls to this function need to be updated to include thereverse
parameter.107-122: The
Next
method of theiterator
struct has been updated to handle reverse iteration. The logic for moving to the next key has been modified based on thereverse
flag. Ensure that this change does not affect the existing functionality of forward iteration.265-270: The
DebugRawIterate
function has been updated to handle reverse iteration. The logic for moving to the next key has been modified based on thereverse
flag. Ensure that this change does not affect the existing functionality of forward iteration.store/storage/pebbledb/db.go (5)
185-185: The
newPebbleDBIterator
function now accepts a new boolean parameterreverse
. Ensure that all calls to this function throughout the codebase have been updated to include this new parameter.189-195: Input validation has been added for the
start
andend
keys in theReverseIterator
function. This is a good practice to prevent unexpected behavior and errors.197-202: The keys are now encoded using
MVCCEncode
before being passed to the iterator. This is likely done to ensure that the keys are in a format that the iterator can understand and process correctly.204-207: Error handling has been added for the creation of the PebbleDB iterator. This is a good practice to prevent unexpected behavior and errors.
209-209: The
newPebbleDBIterator
function now accepts a new boolean parameterreverse
. Ensure that all calls to this function throughout the codebase have been updated to include this new parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ut ACK
Description
Closes: #17976
This was actually much simpler to implement than I had originally imagined.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
TestDatabase_ReverseIterator
) for the database's reverse iteration functionality, simplifying the test suite.These changes aim to improve the user experience by providing more flexible data access and ensuring more reliable database operations.