JLD.jl icon indicating copy to clipboard operation
JLD.jl copied to clipboard

Multiple writes of complex types stop load from working

Open oxinabox opened this issue 9 years ago • 1 comments
trafficstars

Hi, It seems there is a way to break type saving/loading, if you do multiple writes of a suitably complex type:

The MWE I could create is:

using JLD
using HDF5

jldopen("example.jld", "w") do fh
    write(fh, "weights", [(:Heavy,100), (:Light,50)])
end
jldopen("example.jld", "r+") do fh
    write(fh, "otherweights", [(:VeryHeavy, 200), (:VeryLight, 25)])

end
load("example.jld")

when you try to do the load you get:

LoadError: stored type Core.Tuple{Core.Symbol,Core.Int64} does not match currently loaded type
while loading In[5], in expression starting on line 9

 in jldatatype at /home/ubuntu/.julia/v0.5/JLD/src/jld_types.jl:689
 in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:370
 in read_ref at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:498
 in read_refs at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:471
 in read_array at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:407
 in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:372
 in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:346
 in anonymous at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:1185
 in jldopen at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:245
 [inlined code] from /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:243
 in load at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:1184
 in load at /home/ubuntu/.julia/v0.5/FileIO/src/loadsave.jl:42
 [inlined code] from essentials.jl:114

however both load("example.jld","weights") and load("example.jld","otherweights") work. It also works fine if they are both written at the same time.

A few more examples of things that work leading up to it are on https://gist.github.com/oxinabox/95f71548345e8fc583

This is with

Julia Version 0.5.0-dev+1331 Commit 9d6dee5 (2015-11-18 04:38 UTC) Platform Info: System: Linux (x86_64-linux-gnu) CPU: AMD Opteron 63xx class CPU WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Piledriver) LAPACK: libopenblas64_ LIBM: libopenlibm LLVM: libLLVM-3.3

JLD 0.5.7 HDF5 0.5.7

oxinabox avatar Feb 01 '16 09:02 oxinabox

Probably duplicate of https://github.com/JuliaLang/JLD.jl/issues/12

Though:

jldopen("example.jld", "w") do fh
    write(fh, "weights", (:Heavy,:Heavy))
end
jldopen("example.jld", "r+") do fh
    write(fh, "otherweights", (:VeryHeavy, :Heavy))

end
load("example.jld")

Does not work

but

jldopen("example.jld", "w") do fh
    write(fh, "weights", (:Heavy,:Heavy))
    write(fh, "otherweights", (:VeryHeavy, :Heavy))

end
load("example.jld")

Does work

oxinabox avatar Feb 01 '16 10:02 oxinabox