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

Proof of concept for isbits (PR 2) #323

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

oxinabox
Copy link
Contributor

@oxinabox oxinabox commented Apr 9, 2021

This is a rebased version of #287
(and thus also would close #271 )

I am experimenting with it again.

@codecov-io
Copy link

codecov-io commented Apr 9, 2021

Codecov Report

Merging #323 (1a64338) into master (906cea0) will decrease coverage by 0.04%.
The diff coverage is 98.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #323      +/-   ##
==========================================
- Coverage   93.80%   93.75%   -0.05%     
==========================================
  Files          32       33       +1     
  Lines        1534     1586      +52     
==========================================
+ Hits         1439     1487      +48     
- Misses         95       99       +4     
Impacted Files Coverage Δ
src/TimeZones.jl 100.00% <ø> (ø)
src/types/timezone.jl 88.00% <ø> (ø)
src/external.jl 80.00% <80.00%> (ø)
src/types/fixedtimezone.jl 100.00% <100.00%> (ø)
src/types/variabletimezone.jl 100.00% <100.00%> (ø)
src/types/zoneddatetime.jl 96.70% <100.00%> (+0.65%) ⬆️
src/compat.jl 0.00% <0.00%> (-100.00%) ⬇️
src/parse.jl 94.44% <0.00%> (-0.02%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 906cea0...1a64338. Read the comment docs.

@oxinabox
Copy link
Contributor Author

oxinabox commented Apr 9, 2021

When I used this, I get:

BoundsError(TimeZone[tz"Z", tz"UTC", TimeZones.FixedTimeZone("LMT", -21036), TimeZones.FixedTimeZone("CST", -21600), TimeZones.FixedTimeZone("CDT", -21600, 3600), tz"EST", TimeZones.FixedTimeZone("CWT", -21600, 3600), TimeZones.FixedTimeZone("CPT", -21600, 3600), tz"America/Chicago"],
(16,)), Any[(getindex at array.jl:809 [inlined], 1),
(getindex at external.jl:15 [inlined], 1),

Which suggests that it is not serializing properly.

I recall @JeffBezanson saying something about overloading serialize actually doesn't work, because serializing Vector{T} doesn't call serialize(T).

Which seems to be true:

Setup:

julia> using Serialization, TimeZones

julia> zdt = ZonedDateTime(Date(2011, 6, 1), tz"America/Winnipeg")
2011-06-01T00:00:00-05:00

To check if it is serializing properly we expect that the name of the timezone would occur in the serialized stream.

We can see it does for if just serializing a ZonedDateTime

julia> iob = IOBuffer(); serialize(Serializer(iob), zdt); occursin("Winnipeg", String(take!(iob)))
true

But that it does not if serializing an array of ZonedDateTimes:

julia> iob = IOBuffer(); serialize(Serializer(iob), [zdt]); occursin("Winnipeg", String(take!(iob)))
false

@oxinabox
Copy link
Contributor Author

oxinabox commented Apr 9, 2021

I think the answer is we should be overloading write not serialize both serialize_any and serialize_array_values fall back to write>

Edit: no that isn't quite write.
serializing array values calls serialize on the elements.
except of those elements are bitstypes.
And in that case it does call something that falls back to write
https://github.com/JuliaLang/julia/blob/4996445df37e526dac2772e333caf82f1ea987f0/stdlib/Serialization/src/Serialization.jl#L272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZonedDateTime not isbits
3 participants