Skip to content

Commit f61d5f6

Browse files
committed
Merge branch 'master' of github.com:JuliaRobotics/DistributedFactorGraphs.jl into 23Q1/dfg_v0_19_1_updates
2 parents 41bd28d + 00f1567 commit f61d5f6

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.19.0"
3+
version = "0.19.1"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/services/Serialization.jl

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,29 +349,40 @@ function unpackVariable(
349349
isnothing(variableType) && error("Cannot deserialize variableType '$variableTypeString' in variable '$label'")
350350
pointType = getPointType(variableType)
351351

352-
_ensureid!(s::Dict) = begin s["id"] = haskey(s, "id") ? s["id"] : nothing end
353-
_ensureid!(s::PackedVariableNodeData) = s
354-
355-
# FIXME, drop nested packing, see DFG #867
356-
solverData = if unpackSolverData && haskey(packedProps, "solverDataDict")
357-
packed = if packedProps["solverDataDict"] isa String
358-
# JSON2.read(packedProps["solverDataDict"], Dict{String, PackedVariableNodeData})
359-
# JSON3.read(packedProps["solverDataDict"], Dict{String, PackedVariableNodeData})
360-
jdc = JSON.parse(packedProps["solverDataDict"])
352+
function _unpackSolverData(
353+
packedSolverData;
354+
oldkeys=false
355+
)
356+
_ensureid!(s::Dict) = begin s["id"] = haskey(s, "id") ? s["id"] : nothing end
357+
_ensureid!(s::PackedVariableNodeData) = s
358+
packed = if packedSolverData isa String
359+
# JSON2.read(packedSolverData, Dict{String, PackedVariableNodeData})
360+
# JSON3.read(packedSolverData, Dict{String, PackedVariableNodeData})
361+
jdc = JSON.parse(packedSolverData)
361362
jpvd = Dict{String,PackedVariableNodeData}()
362363
for (k,v) in jdc
363364
_ensureid!(v)
364365
jpvd[k] = transcodeType(PackedVariableNodeData, v)
365366
end
366367
jpvd
367368
else
368-
packedProps["solverDataDict"]
369+
packedSolverData
369370
end
370371
packedvals = values(packed)
371372
_ensureid!.(packedvals)
373+
# @show keys(packed)
372374
# TODO deprecate, this is for DFG18 compat only
373375
packed_ = transcodeType.(PackedVariableNodeData, packedvals) # from Dict to hard type
374-
Dict{Symbol, VariableNodeData{variableType, pointType}}(Symbol.(keys(packed)) .=> map(p -> unpackVariableNodeData(p), packed_))
376+
unpacked_ = map(p -> unpackVariableNodeData(p), packed_)
377+
keys_ = oldkeys ? Symbol.(keys(packed_)) : map(s->s.solveKey, unpacked_)
378+
Dict{Symbol, VariableNodeData{variableType, pointType}}(keys_ .=> unpacked_)
379+
end
380+
381+
# FIXME, drop nested packing, see DFG #867
382+
solverData = if unpackSolverData && haskey(packedProps, "solverDataDict")
383+
_unpackSolverData(packedProps["solverDataDict"]; oldkeys=false)
384+
elseif unpackSolverData && haskey(packedProps, "solverData")
385+
_unpackSolverData(packedProps["solverData"])
375386
else
376387
Dict{Symbol, VariableNodeData{variableType, pointType}}()
377388
end
@@ -380,13 +391,13 @@ function unpackVariable(
380391
# variable = DFGVariable{variableType}(Symbol(packedProps["label"]), timestamp, nstime, Set(tags), ppeDict, solverData, smallData, Dict{Symbol,AbstractDataEntry}(), Ref(packedProps["solvable"]))
381392

382393
variable = DFGVariable{variableType}(;
383-
id=id,
394+
id,
384395
label = Symbol(packedProps["label"]),
385396
# variableType = variableType,
386-
timestamp = timestamp,
387-
nstime = nstime,
397+
timestamp,
398+
nstime,
388399
tags = Set{Symbol}(tags_),
389-
ppeDict = ppeDict,
400+
ppeDict,
390401
solverDataDict = solverData,
391402
smallData= smallData,
392403
dataDict = Dict{Symbol,AbstractDataEntry}(),

0 commit comments

Comments
 (0)