-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: improve backed_args by allowing random access to its arguments #6189
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
Conversation
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 completed. 1 suggestions posted.
Comment augment review to trigger a new review at any time.
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.
Pull request overview
This PR refactors the BackedArguments class to use prefix sums (offsets) instead of individual lengths for storing argument metadata. This change enables O(1) random access to arguments by upgrading the iterator from forward_iterator to random_access_iterator, eliminating the need to track byte offsets separately when traversing arguments.
Key changes:
- Replaced
lens_vector withoffsets_vector to store prefix sums instead of individual lengths - Upgraded iterator category to
random_access_iterator_tagwith arithmetic operators (operator+,operator-, etc.) - Simplified
WrapperBackedinParsedArgsby removing theofs_bytes_tracking member
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/common/backed_args.h |
Core refactoring: replaced length tracking with offset (prefix sum) storage; upgraded iterator to random access with arithmetic operators |
src/facade/facade_types.h |
Simplified WrapperBacked by removing ofs_bytes_ member; updated front(), ToSlice(), and Tail() to use new random access capabilities |
src/facade/memcache_parser.h |
Updated Command::key() to use empty() instead of lens_.empty() |
src/facade/memcache_parser.cc |
Changed from tokens[0] to tokens_view[0] for consistency after prefix removal |
src/facade/memcache_parser_test.cc |
Simplified ToArgs() to construct vector directly from iterator range |
Change BackedArguments to keep prefix sums of all lengths of its items Based on the idea from #6176 (comment) Signed-off-by: Roman Gershman <roman@dragonflydb.io>
…dragonflydb#6189) Change BackedArguments to keep prefix sums of all lengths of its items Based on the idea from dragonflydb#6176 (comment) Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Change BackedArguments to keep prefix sums of all lengths of its items Based on the idea from #6176 (comment)