-
Notifications
You must be signed in to change notification settings - Fork 21
Add mutability binary view #526
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
base: main
Are you sure you want to change the base?
Add mutability binary view #526
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #526 +/- ##
==========================================
+ Coverage 88.11% 88.37% +0.26%
==========================================
Files 100 100
Lines 7470 7888 +418
==========================================
+ Hits 6582 6971 +389
- Misses 888 917 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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 adds mutation support to the variable size binary view array implementation, enabling resize, insert, and erase operations. The implementation provides comprehensive mutating functionality while managing the complex storage layout of binary view arrays with their inline storage optimization for strings ≤12 bytes.
Key changes:
- Adds assignment, resize, insert, and erase methods to the binary view array
- Implements comprehensive test coverage for all mutation operations
- Fixes assertion logic in the base class to allow empty range operations
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
include/sparrow/variable_size_binary_view_array.hpp |
Adds mutating methods (assign, resize_values, insert_value, insert_values, erase_values) with complex buffer management logic |
include/sparrow/layout/mutable_array_base.hpp |
Fixes assertion to allow empty range erases (first == last) |
test/test_variable_size_binary_view_array.cpp |
Comprehensive test suite covering all mutation scenarios including edge cases |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
*reinterpret_cast<std::int32_t*>(view_ptr + BUFFER_INDEX_OFFSET) = static_cast<std::int32_t>( | ||
FIRST_VAR_DATA_BUFFER_INDEX | ||
); | ||
|
||
*reinterpret_cast<std::int32_t*>(view_ptr + BUFFER_OFFSET_OFFSET) = static_cast<std::int32_t>( | ||
final_offset | ||
); |
Copilot
AI
Oct 9, 2025
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.
These lines use reinterpret_cast for writing int32 values, which is inconsistent with the safe unaligned write helper function 'write_int32_unaligned' that was introduced and used elsewhere in the code. Use the helper function for consistency and safety.
*reinterpret_cast<std::int32_t*>(view_ptr + BUFFER_INDEX_OFFSET) = static_cast<std::int32_t>( | |
FIRST_VAR_DATA_BUFFER_INDEX | |
); | |
*reinterpret_cast<std::int32_t*>(view_ptr + BUFFER_OFFSET_OFFSET) = static_cast<std::int32_t>( | |
final_offset | |
); | |
write_int32_unaligned(view_ptr + BUFFER_INDEX_OFFSET, static_cast<std::int32_t>( | |
FIRST_VAR_DATA_BUFFER_INDEX | |
)); | |
write_int32_unaligned(view_ptr + BUFFER_OFFSET_OFFSET, static_cast<std::int32_t>( | |
final_offset | |
)); |
Copilot uses AI. Check for mistakes.
for more information, see https://pre-commit.ci
*dest = static_cast<std::uint8_t>(*src_it); | ||
++src_it; | ||
++dest; | ||
} |
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.
What about simplifying the implementation with something like:
std::ranges::transform(range, dest, to_uint8_transform());
And since it's a single line, I think calls to copy_and_convert_to_uint8
could actually be replaced with that single line.
++src_it; | ||
++dest; | ||
++copied; | ||
} |
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.
This implementation could be simplified with something like:
std::ranges::transform(range | std::views::take(count), dest, to_uint8_transform());
); | ||
auto val_casted = val | std::ranges::views::transform(to_uint8_transform()); | ||
|
||
sparrow::ranges::copy(val_casted, long_string_storage.data() + long_string_storage_offset); |
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.
These two lines are equivalent to copy_and_convert_to_uint8(val, long_string_storage.data() + long_string_storage_offset)
. Or you can keep them as is if you decide to remove the copy_and_convert_to_uint8
function.
No description provided.