Skip to content

Commit 22469dd

Browse files
committed
update decodePackedType
1 parent 4c6fc41 commit 22469dd

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/services/Serialization.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,20 @@ function packFactor(dfg::AbstractDFG, f::DFGFactor)
332332
return props
333333
end
334334

335-
function decodePackedType(::Type{T}, packeddata::GenericFunctionNodeData{PT}) where {T<:FactorOperationalMemory, PT}
336-
# usrtyp = convert(FunctorInferenceType, packeddata.fnc)
335+
function decodePackedType(dfg::AbstractDFG, varOrder::AbstractVector{Symbol}, ::Type{T}, packeddata::GenericFunctionNodeData{PT}) where {T<:FactorOperationalMemory, PT}
336+
#
337+
# TODO, to solve IIF 1424
338+
# variables = map(lb->getVariable(dfg, lb), varOrder)
339+
337340
# Also look at parentmodule
338341
usrtyp = convertStructType(PT)
339342
fulltype = DFG.FunctionNodeData{T{usrtyp}}
340343
factordata = convert(fulltype, packeddata)
341344
return factordata
342345
end
343346

344-
345-
function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G <: AbstractDFG
347+
# Returns `::DFGFactor`
348+
function unpackFactor(dfg::G, packedProps::Dict{String, Any}) where G <: AbstractDFG
346349
# Version checking.
347350
_versionCheck(packedProps)
348351

@@ -369,10 +372,18 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
369372
# FIXME type instability from nothing to T
370373
packed = nothing
371374
fullFactorData = nothing
375+
376+
# Get the stored variable order
377+
_variableOrderSymbols = if packedProps["_variableOrderSymbols"] isa String
378+
JSON2.read(packedProps["_variableOrderSymbols"], Vector{Symbol})
379+
else
380+
Symbol.(packedProps["_variableOrderSymbols"])
381+
end
382+
372383
try
373384
packed = JSON2.read(data, GenericFunctionNodeData{packtype})
374385
decodeType = getFactorOperationalMemoryType(dfg)
375-
fullFactorData = decodePackedType(decodeType, packed)
386+
fullFactorData = decodePackedType(dfg, _variableOrderSymbols, decodeType, packed)
376387
catch ex
377388
io = IOBuffer()
378389
showerror(io, ex, catch_backtrace())
@@ -381,12 +392,6 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
381392
error(msg)
382393
end
383394

384-
# Include the type
385-
if packedProps["_variableOrderSymbols"] isa String
386-
_variableOrderSymbols = JSON2.read(packedProps["_variableOrderSymbols"], Vector{Symbol})
387-
else
388-
_variableOrderSymbols = Symbol.(packedProps["_variableOrderSymbols"])
389-
end
390395
solvable = packedProps["solvable"]
391396

392397
# Rebuild DFGFactor

0 commit comments

Comments
 (0)