-
Notifications
You must be signed in to change notification settings - Fork 31
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
add versionize for VecDequeue/HashMap/HashSet. #25
Conversation
f7cee51
to
5bc6c21
Compare
- add versionize support for VecDequeue/HashMap/HashSet. Signed-off-by: JasonBian <zizheng.bian@linux.alibaba.com>
5bc6c21
to
f006078
Compare
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.
PR looks good overall. I have left some comments on the code.
Also please cover the new primitives in these tests: test_bincode_deserialize_from_versionize()
and test_bincode_serialize_to_versionize()
@@ -333,6 +340,168 @@ where | |||
} | |||
} | |||
|
|||
impl<T> Versionize for VecDeque<T> |
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 is almost like implementation for Vec. Can we do this with a macro to avoid duplicating code ?
.map_err(|ref err| VersionizeError::Serialize(format!("{:?}", err)))?; | ||
// Walk the hash map and write each element. | ||
for (k, v) in self.iter() { | ||
(k.clone(), v.clone()).serialize(writer, version_map, app_version)?; |
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.
Can we avoid the temporary clones here ?
) | ||
.unwrap(); | ||
|
||
assert_eq!(store, restore); |
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.
Please add negative tests.
<HashSet<String> as Versionize>::deserialize(&mut snapshot_mem.as_slice(), &vm, 1) | ||
.unwrap(); | ||
|
||
assert_eq!(store, restore); |
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.
Same as above.
Hello @imaginezz ! Do you plan to continue working on this PR? |
I will close this pr, and update in #37 |
Signed-off-by: JasonBianzizheng.bian@linux.alibaba.com
Reason for This PR
Added support for some of the commonly used data structures: VecDeque, HashMap, and HashSet
Description of Changes
primitives.rs
.lib.rs
.License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).unsafe
code is properly documented.CHANGELOG.md
.