Skip to content

Commit e692259

Browse files
committed
reconstFactorData
1 parent 22469dd commit e692259

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ export mergeVariableData!, mergeGraphVariableData!
218218
# Serialization type conversion
219219
export convertPackedType, convertStructType
220220

221+
export reconstFactorData
222+
221223
##------------------------------------------------------------------------------
222224
## Other utility functions
223225
##------------------------------------------------------------------------------

src/services/Serialization.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ function packFactor(dfg::AbstractDFG, f::DFGFactor)
332332
return props
333333
end
334334

335+
function reconstFactorData() end
336+
335337
function decodePackedType(dfg::AbstractDFG, varOrder::AbstractVector{Symbol}, ::Type{T}, packeddata::GenericFunctionNodeData{PT}) where {T<:FactorOperationalMemory, PT}
336338
#
337339
# TODO, to solve IIF 1424
@@ -340,7 +342,7 @@ function decodePackedType(dfg::AbstractDFG, varOrder::AbstractVector{Symbol}, ::
340342
# Also look at parentmodule
341343
usrtyp = convertStructType(PT)
342344
fulltype = DFG.FunctionNodeData{T{usrtyp}}
343-
factordata = convert(fulltype, packeddata)
345+
factordata = reconstFactorData(dfg, varOrder, fulltype, packeddata)
344346
return factordata
345347
end
346348

test/testBlocks.jl

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using Dates
44
using Manifolds
55

66
import Base: convert
7+
import DistributedFactorGraphs: reconstFactorData
78

89
# Test InferenceVariable Types
910
# struct TestVariableType1 <: InferenceVariable
@@ -43,11 +44,17 @@ function Base.convert(::Type{PackedTestFunctorInferenceType1}, d::TestFunctorInf
4344
PackedTestFunctorInferenceType1()
4445
end
4546

46-
function Base.convert(::Type{TestFunctorInferenceType1}, d::PackedTestFunctorInferenceType1)
47+
function reconstFactorData(dfg::AbstractDFG, vo::AbstractVector, ::Type{TestFunctorInferenceType1}, d::PackedTestFunctorInferenceType1, ::String)
48+
TestFunctorInferenceType1()
49+
end
50+
51+
# overly simplified test requires both reconstitute and convert
52+
function Base.convert(::Type{TestFunctorInferenceType1}, d::PackedTestFunctorInferenceType1 )
4753
# @info "convert(::Type{TestFunctorInferenceType1}, d::PackedTestFunctorInferenceType1)"
4854
TestFunctorInferenceType1()
4955
end
5056

57+
5158
struct PackedTestAbstractPrior <: PackedInferenceType
5259
s::String
5360
end
@@ -74,20 +81,29 @@ Base.:(==)(a::TestCCW, b::TestCCW) = a.usrfnc! == b.usrfnc!
7481
DFG.getFactorOperationalMemoryType(par::NoSolverParams) = TestCCW
7582
DFG.rebuildFactorMetadata!(dfg::AbstractDFG{NoSolverParams}, fac::DFGFactor) = fac
7683

77-
function Base.convert(::Type{DFG.FunctionNodeData{TestCCW{F}}},
78-
d::DFG.PackedFunctionNodeData{<:AbstractPackedFactor}) where {F <: DFG.AbstractFactor}
79-
84+
function reconstFactorData(dfg::AbstractDFG,
85+
vo::AbstractVector,
86+
::Type{<:DFG.FunctionNodeData{TestCCW{F}}},
87+
d::DFG.PackedFunctionNodeData{<:AbstractPackedFactor} ) where {F <: DFG.AbstractFactor}
88+
nF = convert(F, d.fnc)
8089
return DFG.FunctionNodeData(d.eliminated,
8190
d.potentialused,
8291
d.edgeIDs,
83-
TestCCW(convert(F, d.fnc)),
92+
TestCCW(nF),
8493
d.multihypo,
8594
d.certainhypo,
8695
d.nullhypo,
8796
d.solveInProgress,
8897
d.inflation)
8998
end
9099

100+
function convert( T::Type{DFG.FunctionNodeData{TestCCW{F}}},
101+
d::DFG.PackedFunctionNodeData{<:AbstractPackedFactor} ) where {F <: DFG.AbstractFactor}
102+
#
103+
@error("DEPRECATING $T")
104+
reconstFactorData(T, d, "")
105+
end
106+
91107
function Base.convert(::Type{DFG.PackedFunctionNodeData{P}}, d::DFG.FunctionNodeData{<:FactorOperationalMemory}) where P <: AbstractPackedFactor
92108
return DFG.PackedFunctionNodeData(d.eliminated,
93109
d.potentialused,

0 commit comments

Comments
 (0)