Skip to content
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

Fix key value in ThreadedRodeo deserialization #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/threaded_rodeo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,9 @@ where
.expect("failed to allocate memory for interner");

for (string, key) in deser_map {
if key.into_usize() > highest {
highest = key.into_usize();
let next_key = key.into_usize() + 1;
Kixiron marked this conversation as resolved.
Show resolved Hide resolved
if next_key > highest {
highest = next_key;
Kixiron marked this conversation as resolved.
Show resolved Hide resolved
}

let allocated = unsafe {
Expand Down Expand Up @@ -1707,6 +1708,12 @@ mod tests {
let deser: ThreadedRodeo = serde_json::from_str(&ser).unwrap();
let deser2: ThreadedRodeo = serde_json::from_str(&ser2).unwrap();

// Verify that the "next" key is set correctly
assert_eq!(
rodeo.key.load(Ordering::Relaxed),
deser.key.load(Ordering::Relaxed)
);

for (correct_key, correct_str) in [(a, "a"), (b, "b"), (c, "c"), (d, "d")].iter().copied() {
assert_eq!(correct_key, deser.get(correct_str).unwrap());
assert_eq!(correct_key, deser2.get(correct_str).unwrap());
Expand Down