BSON.jl
BSON.jl copied to clipboard
Freeze while trying to save custom struct
I am able to save a custom struct using BSON when one of the data members is a character but not when it is a string (it seems to hang). It is a nested struct, and the change that I am making is in the inner struct. I am not sure if this is related to padding (I did also at one point get ERROR: LoadError: Padding of type UInt8 is not compatible with type
) or another known issue. I have been able to save the struct using JSON.
e.g. a::Int64 b::Int64 c::Char d::Bool
saves but not a::Int64 b::Int64 c::String d::Bool
I have a related problem (padding not compatible). Any ideas how to work around this?
ERROR: Padding of type UInt8 is not compatible with type StudentSolution.
Stacktrace:
[1] check_readable at ./reinterpretarray.jl:79 [inlined]
[2] getindex at ./reinterpretarray.jl:123 [inlined]
[3] iterate at ./abstractarray.jl:914 [inlined]
[4] iterate at ./abstractarray.jl:912 [inlined]
[5] reinterpret_(::Type{UInt8}, ::Array{StudentSolution,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/extensions.jl:67
[6] lower(::Array{StudentSolution,3}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/extensions.jl:72
[7] _lower_recursive(::Array{StudentSolution,3}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[8] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::Array{StudentSolution,3}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[9] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:28
[10] _lower_recursive(::Array{Array{StudentSolution,3},1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[11] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::Array{Array{StudentSolution,3},1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[12] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:28
[13] _lower_recursive(::Array{Any,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[14] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[15] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:21
[16] _lower_recursive(::SpSolution, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[17] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::SpSolution) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[18] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:28
[19] _lower_recursive(::Array{Any,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[20] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[21] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:21
[22] _lower_recursive(::Array{SpSolution,2}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[23] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::Array{SpSolution,2}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[24] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:28
[25] _lower_recursive(::Array{Any,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[26] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[27] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:21
[28] _lower_recursive(::ModelSolution, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[29] (::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}})(::ModelSolution) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[30] applychildren!(::BSON.var"#7#11"{IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/BSON.jl:21
[31] _lower_recursive(::Dict{Symbol,ModelSolution}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:62
[32] lower_recursive(::Dict{Symbol,ModelSolution}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:73
[33] bson(::IOStream, ::Dict{Symbol,ModelSolution}) at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:81
[34] #14 at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:83 [inlined]
[35] #open#271(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}, ::typeof(open), ::BSON.var"#14#15"{Dict{Symbol,ModelSolution}}, ::String, ::Vararg{String,N} where N) at ./io.jl:298
[36] open at ./io.jl:296 [inlined]
[37] bson at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:83 [inlined]
[38] #bson#16 at /Users/lutz/.julia/packages/BSON/lY9i8/src/write.jl:85 [inlined]
[39] #bson at ./none:0 [inlined]
[40] #save_solution#177(::Int64, ::typeof(CollegeStrat.save_solution), ::Model, ::ModelSolution) at /Users/lutz/Documents/projects/p2019/college_stratification/CollegeStrat/src/model/load_save.jl:68
[41] save_solution at /Users/lutz/Documents/projects/p2019/college_stratification/CollegeStrat/src/model/load_save.jl:68 [inlined]
[42] #calibrate#199(::Symbol, ::Bool, ::typeof(calibrate), ::Symbol) at /Users/lutz/Documents/projects/p2019/college_stratification/CollegeStrat/src/model/calibration.jl:52
[43] calibrate(::Symbol) at /Users/lutz/Documents/projects/p2019/college_stratification/CollegeStrat/src/model/calibration.jl:9
[44] top-level scope at REPL[18]:1
ModelSolution
is a deeply nested struct
.
julia> versioninfo()
Julia Version 1.3.0
Commit 46ce4d7933 (2019-11-26 06:09 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin19.0.0)
CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)