@@ -189,12 +189,30 @@ function _unpackPPE(
189
189
return ppe
190
190
end
191
191
192
+ """
193
+ $(SIGNATURES)
194
+
195
+ Unpack a Dict{String, Any} into a PPE.
196
+
197
+ Notes:
198
+ - returns `::VariableNodeData`
199
+ """
200
+ function _unpackVariableNodeData (
201
+ dfg:: AbstractDFG ,
202
+ packedDict:: Dict{String, Any}
203
+ )
204
+ #
205
+ packedVND = Unmarshal. unmarshal (PackedVariableNodeData, packedDict)
206
+ return unpackVariableNodeData (dfg, packedVND)
207
+ end
208
+
192
209
# returns a DFGVariable
193
210
function unpackVariable (dfg:: G ,
194
211
packedProps:: Dict{String, Any} ;
195
212
unpackPPEs:: Bool = true ,
196
213
unpackSolverData:: Bool = true ,
197
214
unpackBigData:: Bool = true ) where G <: AbstractDFG
215
+ #
198
216
@debug " Unpacking variable:\r\n $packedProps "
199
217
# Version checking.
200
218
_versionCheck (packedProps)
@@ -213,10 +231,10 @@ function unpackVariable(dfg::G,
213
231
Symbol .(packedProps[" tags" ])
214
232
end
215
233
216
- ppeDict = if haskey (packedProps," ppesDict" )
234
+ ppeDict = if unpackPPEs && haskey (packedProps," ppesDict" )
217
235
# FIXME , drop nested packing, see DFG #867
218
236
JSON2. read (packedProps[" ppeDict" ], Dict{Symbol, MeanMaxPPE})
219
- elseif haskey (packedProps," ppes" ) && packedProps[" ppes" ] isa AbstractVector
237
+ elseif unpackPPEs && haskey (packedProps," ppes" ) && packedProps[" ppes" ] isa AbstractVector
220
238
# these different cases are not well covered in tests, but first fix #867
221
239
# TODO dont hardcode the ppeType (which is already discovered for each entry in _updatePPE)
222
240
ppedict = Dict {Symbol, MeanMaxPPE} ()
@@ -237,11 +255,18 @@ function unpackVariable(dfg::G,
237
255
isnothing (variableType) && error (" Cannot deserialize variableType '$variableTypeString ' in variable '$label '" )
238
256
pointType = getPointType (variableType)
239
257
240
- if unpackSolverData
258
+ solverData = if unpackSolverData && haskey (packedProps, " solverDataDict " )
241
259
packed = JSON2. read (packedProps[" solverDataDict" ], Dict{String, PackedVariableNodeData})
242
- solverData = Dict {Symbol, VariableNodeData{variableType, pointType}} (Symbol .(keys (packed)) .=> map (p -> unpackVariableNodeData (dfg, p), values (packed)))
260
+ Dict {Symbol, VariableNodeData{variableType, pointType}} (Symbol .(keys (packed)) .=> map (p -> unpackVariableNodeData (dfg, p), values (packed)))
261
+ elseif unpackPPEs && haskey (packedProps," solverData" ) && packedProps[" solverData" ] isa AbstractVector
262
+ solverdict = Dict {Symbol, VariableNodeData{variableType, pointType}} ()
263
+ for sd in packedProps[" solverData" ]
264
+ # _type = haskey(sd, "_type") ? sd["_type"] : "DistributedFactorGraphs.PackedVariableNodeData"
265
+ solverdict[Symbol (sd[" solveKey" ])] = _unpackVariableNodeData (dfg, sd)
266
+ end
267
+ solverdict
243
268
else
244
- solverData = Dict {Symbol, VariableNodeData{variableType, pointType}} ()
269
+ Dict {Symbol, VariableNodeData{variableType, pointType}} ()
245
270
end
246
271
# Rebuild DFGVariable using the first solver variableType in solverData
247
272
# @info "dbg Serialization 171" variableType Symbol(packedProps["label"]) timestamp nstime ppeDict solverData smallData Dict{Symbol,AbstractDataEntry}() Ref(packedProps["solvable"])
0 commit comments