-
Notifications
You must be signed in to change notification settings - Fork 28
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 deepcopy
/serialize
when used after delete!
#112
Conversation
Oh no there are actually more issues with the values of the Dictionary itself |
I see the problem. What we can do is take a shortcut if
The disadvantage of the first one is it won't be thread safe when you have multiple readers (I'm not even sure it is safe under single-threaded concurrency). Probably should go with the second with code like: serialize_type(s, T, false)
if indices.holes == 0
return serialize(s, ind.values)
else
is = Vector{I}(undef, length(dict))
@inbounds for t in tokens(dict)
is[i] = ind.values[t]
end
return serialize(s, is)
end It might be even better if we could stream out the indices in the second branch rather than collecting them in memory, but at least this is safe. Will need equivalent code for dictionaries, and for deepcopy. |
So I was thinking of an even more straightforward solution with dispatching Something like
This way we just build a whole new |
So I just implemented my proposal |
Codecov ReportBase: 78.86% // Head: 79.33% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #112 +/- ##
==========================================
+ Coverage 78.86% 79.33% +0.47%
==========================================
Files 20 20
Lines 2342 2347 +5
==========================================
+ Hits 1847 1862 +15
+ Misses 495 485 -10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@andyferris Would you rather have me use your solution instead? |
@theogf news here? |
Hi @andyferris, any update on this :) ? |
Sorry I have been smashed. Correct is more important the fast, so lets merge this. Thanks @theogf |
Hey @andyferris !
It looks my
deepcopy
andserialize
implementation have a bug.I wrongly assumed that
indices.values == collect(indices)
.It is visibly not true and create
undef
references when using nonisbits
structure.I used
collect(indices)
instead and took care of updating the tests accordingly.(version patch is bumped as well)