-
Notifications
You must be signed in to change notification settings - Fork 132
Add the ability to serialize/deserialize Arc<str>
and Box<str>
#1339
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 the ability to serialize/deserialize Arc<str>
and Box<str>
#1339
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.
Thanks for the contribution! I left some minor comments regarding tests.
I also think that docs should be adjusted.
docs/source/data-types/text.md
- it should mention that Box and Arc are supported.docs/source/data-types/data-types.md
mapping should also be updated.
Let me know if everything looks good now. |
@Sokom141 When looking into this I uncovered some more issues. Then I looked into impl<'frame, 'metadata, T: DeserializeValue<'frame, 'metadata>> DeserializeValue<'frame, 'metadata>
for Box<T>
{
fn type_check(typ: &ColumnType) -> Result<(), TypeCheckError> {
T::type_check(typ).map_err(typck_error_replace_rust_name::<Self>)
}
fn deserialize(
typ: &'metadata ColumnType<'metadata>,
v: Option<FrameSlice<'frame>>,
) -> Result<Self, DeserializationError> {
T::deserialize(typ, v)
.map(Box::new)
.map_err(deser_error_replace_rust_name::<Self>)
}
} This code unfortunately has a subtle mistake. Then I started to wonder if we already have this bug somewhere else since it is so easy to cause it. I think we should:
I'll open an issue for that and we'll try to address it soon. I don't think there is much sense in merging this PR since it doesn't solve the real issue we found. |
Nice catch. This is fine for me, I am happy that this has uncovered some underlying problems! |
Description
This PR add the ability to automatically derive
SerializeValue
andDeserializeValue
on structs that containBox<str>
andArc<str>
, enabling particular patterns to reduce memory footprint.Along with the implementation I have added tests where I thought it made sense. Everything seems to work but I had troubles with the Makefile and wasn't able to bring up the 3-node cluster, so please double check (
cargo t -p scylla-cql
passed every test anyway).Thanks!
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.Fixes: #1336