55function convert (
66 :: Type{PackedFunctionNodeData{P}} ,
77 d:: FunctionNodeData{T} ,
8- ) where {P <: AbstractPackedFactor , T <: FactorOperationalMemory }
8+ ) where {P <: AbstractPackedFactor , T <: FactorSolverCache }
9+ error (" TODO remove. PackedFunctionNodeData is obsolete" )
910 return PackedFunctionNodeData (
1011 d. eliminated,
1112 d. potentialused,
2223# # unpack converters------------------------------------------------------------
2324
2425# see #1424
25- function reconstFactorData (
26+ # TODO Consolidate: this looks alot like `getDefaultFactorData`
27+ function DFG. reconstFactorData (
2628 dfg:: AbstractDFG ,
2729 varOrder:: AbstractVector{Symbol} ,
2830 :: Type{<:GenericFunctionNodeData{<:CommonConvWrapper{F}}} ,
2931 packed:: GenericFunctionNodeData{<:AbstractPackedFactor} ,
3032) where {F <: AbstractFactor }
33+
34+ error (" TODO remove. Obsolete: use `DFG.rebuildFactorCache!` and getDefaultFactorData instead." )
3135 #
3236 # TODO store threadmodel=MutliThreaded,SingleThreaded in persistence layer
3337 usrfnc = convert (F, packed. fnc)
@@ -89,7 +93,7 @@ Dev Notes:
8993- TODO: We should only really do this in-memory if we can by without it (review this).
9094- TODO: needs testing
9195"""
92- function rebuildFactorMetadata ! (
96+ function DFG . rebuildFactorCache ! (
9397 dfg:: AbstractDFG{SolverParams} ,
9498 factor:: DFGFactor ,
9599 neighbors = map (vId -> getVariable (dfg, vId), listNeighbors (dfg, factor));
@@ -99,50 +103,54 @@ function rebuildFactorMetadata!(
99103 # Set up the neighbor data
100104
101105 # Rebuilding the CCW
102- fsd = getSolverData (factor)
103- fnd_new = getDefaultFactorData (
106+ state = DFG . getFactorState (factor)
107+ state, solvercache = getDefaultFactorData (
104108 dfg,
105109 neighbors,
106- getFactorType (factor);
107- multihypo = fsd. multihypo,
108- nullhypo = fsd. nullhypo,
109- # special inflation override
110- inflation = fsd. inflation,
111- eliminated = fsd. eliminated,
112- potentialused = fsd. potentialused,
113- edgeIDs = fsd. edgeIDs,
114- solveInProgress = fsd. solveInProgress,
110+ DFG. getObservation (factor);
111+ multihypo = state. multihypo,
112+ nullhypo = state. nullhypo,
113+ # special inflation override
114+ inflation = state. inflation,
115+ eliminated = state. eliminated,
116+ potentialused = state. potentialused,
117+ solveInProgress = state. solveInProgress,
115118 _blockRecursion= _blockRecursionGradients
116119 )
117120 #
118-
119- factor_ = if typeof (fnd_new) != typeof (getSolverData (factor))
120- # must change the type of factor solver data FND{CCW{...}}
121- # create a new factor
122- factor__ = DFGFactor (
123- getLabel (factor),
124- getTimestamp (factor),
125- factor. nstime,
126- getTags (factor),
127- fnd_new,
128- getSolvable (factor),
129- Tuple (getVariableOrder (factor)),
130- )
131- #
132-
133- # replace old factor in dfg with a new one
134- deleteFactor! (dfg, factor; suppressGetFactor = true )
135- addFactor! (dfg, factor__)
136-
137- factor__
138- else
139- setSolverData! (factor, fnd_new)
140- # We're not updating here because we don't want
141- # to solve cloud in loop, we want to make sure this flow works:
142- # Pull big cloud graph into local -> solve local -> push back into cloud.
143- # updateFactor!(dfg, factor)
144- factor
145- end
121+ DFG. setCache! (factor, solvercache)
122+ return factor
123+
124+ # factor_ = if typeof(solvercache) != typeof(DFG.getCache(factor))
125+ # # must change the type of factor solver data FND{CCW{...}}
126+ # # create a new factor
127+ # factor__ = FactorCompute(
128+ # getLabel(factor),
129+ # Tuple(getVariableOrder(factor)),
130+ # DFG.getObservation(factor),
131+ # state,
132+ # solvercache;
133+ # timestamp = getTimestamp(factor),
134+ # nstime = factor.nstime,
135+ # tags = getTags(factor),
136+ # solvable = getSolvable(factor),
137+ # )
138+ # #
139+
140+ # # replace old factor in dfg with a new one
141+ # deleteFactor!(dfg, factor; suppressGetFactor = true)
142+ # addFactor!(dfg, factor__)
143+
144+ # factor__
145+ # else
146+ # setSolverData!(factor, new_solverData)
147+ # DFG.setCache!(factor, solvercache)
148+ # # We're not updating here because we don't want
149+ # # to solve cloud in loop, we want to make sure this flow works:
150+ # # Pull big cloud graph into local -> solve local -> push back into cloud.
151+ # # updateFactor!(dfg, factor)
152+ # factor
153+ # end
146154
147155 # ... Copying neighbor data into the factor?
148156 # JT TODO it looks like this is already updated in getDefaultFactorData -> _createCCW
@@ -151,7 +159,7 @@ function rebuildFactorMetadata!(
151159 # ccw_new.fnc.cpt[i].factormetadata.variableuserdata = deepcopy(neighborUserData)
152160 # end
153161
154- return factor_
162+ # return factor_
155163end
156164
157165# # =================================================================
0 commit comments