After trying to load this type I get the following error:
stored type foo5 does not match currently loaded type
Stacktrace:
[1] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\jld_types.jl:721
[2] read(::JLD.JldDataset) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:368
[3] read(::JLD.JldFile, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:344
[4] (::JLD.##41#42{String})(::JLD.JldFile) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:1241
[5] #jldopen#11(::Array{Any,1}, ::Function, ::JLD.##41#42{String}, ::String, ::Vararg{String,N} where N) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:243
[6] load(::FileIO.File{FileIO.DataFormat{:JLD}}, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:1240
[7] #load#13(::Array{Any,1}, ::Function, ::String, ::String, ::Vararg{String,N} where N) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\FileIO\src\loadsave.jl:113
[8] load(::String, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\FileIO\src\loadsave.jl:113
Any ideas or anything obvious that I’m doing wrong?
Nullables are immutable, so perhaps your OldNullable should be a struct (the new equivalent of the old immutable) instead. I realize that your code matches the readme, but it’s possible that the readme is incorrect. See https://github.com/JuliaIO/JLD.jl/issues/180 where the version that worked used a struct for OldNullable.
If I do exactly as the link states, I can write a 0.5 Nullable{Date} to disk and read in 0.6. But it doesn’t work when I have it nested inside my type.
stored type oldfoo5 does not match currently loaded type
Stacktrace:
[1] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\jld_types.jl:721
[2] read(::JLD.JldDataset) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:368
[3] read(::JLD.JldFile, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:344
[4] (::JLD.##41#42{String})(::JLD.JldFile) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:1241
[5] #jldopen#11(::Array{Any,1}, ::Function, ::JLD.##41#42{String}, ::String, ::Vararg{String,N} where N) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:243
[6] load(::FileIO.File{FileIO.DataFormat{:JLD}}, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:1240
[7] #load#13(::Array{Any,1}, ::Function, ::String, ::String, ::Vararg{String,N} where N) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\FileIO\src\loadsave.jl:113
[8] load(::String, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\FileIO\src\loadsave.jl:113
So, I’ve encountered another issue with this. Reading in the old types works as suggested, however if I decide to create a new one and write it out, I can’t load it back in again. Have you encountered that?
So if you keep the existing code to “rescue” the old types but then create a new one and write it to disk. You’d can’t load it again. Same error then reappears.
Seems like the mapping to read OldNullable then causes in issue when trying to write out a regular Nullable.
However, i can load the type if I create a session and don’t include the mapping code.
new_foo = foo5(66, Date())
file_path = "C:\\new_foo.jld"
file_dir, file_name = splitdir(file_path)
file_prefix, file_ext = splitext(file_name)
JLD.save(file_path, file_prefix, new_foo, compress=false)
file_path = "C:\\new_foo.jld"
file_dir, file_name = splitdir(file_path)
file_prefix, file_ext = splitext(file_name)
obj = JLD.load(file_path, file_prefix)
stored type OldNullable{Base.Dates.Date} does not match currently loaded type
Stacktrace:
[1] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\jld_types.jl:721
[2] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\jld_types.jl:711
[3] read(::JLD.JldDataset) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:368
[4] read(::JLD.JldFile, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:344
[5] (::JLD.##41#42{String})(::JLD.JldFile) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:1241
[6] #jldopen#11(::Array{Any,1}, ::Function, ::JLD.##41#42{String}, ::String, ::Vararg{String,N} where N) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:243
[7] load(::FileIO.File{FileIO.DataFormat{:JLD}}, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\JLD\src\JLD.jl:1240
[8] #load#13(::Array{Any,1}, ::Function, ::String, ::String, ::Vararg{String,N} where N) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\FileIO\src\loadsave.jl:113
[9] load(::String, ::String) at C:\Program Files\ReSolver.DistributedJulia\packages\v0.6\FileIO\src\loadsave.jl:113