@@ -164,15 +164,15 @@ function addVariable!(dfg::CloudGraphsDFG, variable::DFGVariable)
164
164
error (" Variable '$(variable. label) ' already exists in the factor graph" )
165
165
end
166
166
167
- ret = updateVariable! (dfg, variable, skipAddError = true )
167
+ ret = updateVariable! (dfg, variable, warn_if_absent = false )
168
168
169
169
# Do a variable update
170
170
return ret
171
171
end
172
172
173
- function updateVariable! (dfg:: CloudGraphsDFG , variable:: DFGVariable ; skipAddError :: Bool = false )
173
+ function updateVariable! (dfg:: CloudGraphsDFG , variable:: DFGVariable ; warn_if_absent :: Bool = true )
174
174
exist = exists (dfg, variable)
175
- ! skipAddError && ! exist && @warn " Variable label '$(variable. label) ' does not exist in the factor graph, adding"
175
+ warn_if_absent && ! exist && @warn " Variable label '$(variable. label) ' does not exist in the factor graph, adding"
176
176
177
177
# Create/update the base variable
178
178
# NOTE: We are not merging the variable.tags into the labels anymore. We can index by that but not
@@ -196,7 +196,7 @@ function updateVariable!(dfg::CloudGraphsDFG, variable::DFGVariable; skipAddErro
196
196
# length(result.results[1]["data"][1]["row"]) != 1 && error("Cannot update or add variable '$(getLabel(variable))'")
197
197
198
198
# Merge the PPE's, SolverData, and BigData
199
- mergeVariableData! (dfg, variable; currentTransaction= tx, skipExistenceCheck = true )
199
+ mergeVariableData! (dfg, variable; currentTransaction= tx, warn_if_absent = false )
200
200
201
201
commit (tx)
202
202
catch ex
@@ -220,7 +220,7 @@ function addFactor!(dfg::CloudGraphsDFG, factor::DFGFactor)
220
220
end
221
221
222
222
# Do a variable update
223
- return updateFactor! (dfg, factor, skipAddError = true )
223
+ return updateFactor! (dfg, factor, warn_if_absent = false )
224
224
end
225
225
226
226
function getVariable (dfg:: CloudGraphsDFG , label:: Union{Symbol, String} )
@@ -247,8 +247,8 @@ function getVariable(dfg::CloudGraphsDFG, label::Union{Symbol, String})
247
247
return variable
248
248
end
249
249
250
- function mergeVariableData! (dfg:: CloudGraphsDFG , sourceVariable:: DFGVariable ; currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing , skipExistenceCheck :: Bool = false )
251
- if ! skipExistenceCheck & ! exists (dfg, sourceVariable, currentTransaction= currentTransaction)
250
+ function mergeVariableData! (dfg:: CloudGraphsDFG , sourceVariable:: DFGVariable ; currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing , warn_if_absent :: Bool = true )
251
+ if warn_if_absent & & ! exists (dfg, sourceVariable, currentTransaction= currentTransaction)
252
252
error (" Source variable '$(sourceVariable. label) ' doesn't exist in the graph." )
253
253
end
254
254
for (k,v) in sourceVariable. ppeDict
@@ -273,9 +273,9 @@ function getFactor(dfg::CloudGraphsDFG, label::Union{Symbol, String})
273
273
return rebuildFactorMetadata! (dfg, unpackFactor (dfg, props))
274
274
end
275
275
276
- function updateFactor! (dfg:: CloudGraphsDFG , factor:: DFGFactor ; skipAddError :: Bool = false )
276
+ function updateFactor! (dfg:: CloudGraphsDFG , factor:: DFGFactor ; warn_if_absent :: Bool = true )
277
277
exist = exists (dfg, factor)
278
- ! skipAddError && ! exist && @warn " Factor label '$(factor. label) ' does not exist in the factor graph, adding"
278
+ warn_if_absent && ! exist && @warn " Factor label '$(factor. label) ' does not exist in the factor graph, adding"
279
279
280
280
if exist
281
281
# Check that the neighbors are the same
@@ -599,10 +599,11 @@ end
599
599
function updatePPE! (
600
600
dfg:: CloudGraphsDFG ,
601
601
variablekey:: Symbol ,
602
- ppe:: P ;
603
- currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing ):: P where
604
- {P <: AbstractPointParametricEst }
605
- if ! (ppe. solveKey in listPPEs (dfg, variablekey, currentTransaction= currentTransaction))
602
+ ppe:: AbstractPointParametricEst ;
603
+ currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing ,
604
+ warn_if_absent:: Bool = true )
605
+
606
+ if warn_if_absent && ! (ppe. solveKey in listPPEs (dfg, variablekey, currentTransaction= currentTransaction))
606
607
@warn " PPE '$(ppe. solveKey) ' does not exist, adding"
607
608
end
608
609
softType = getSofttype (dfg, variablekey, currentTransaction= currentTransaction)
@@ -618,10 +619,13 @@ function updatePPE!(
618
619
currentTransaction= currentTransaction))
619
620
end
620
621
621
- function updatePPE! (dfg:: CloudGraphsDFG , sourceVariables:: Vector{<:DFGVariable} , ppekey:: Symbol = :default ; currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing )
622
+ function updatePPE! (dfg:: CloudGraphsDFG , sourceVariables:: Vector{<:DFGVariable} , ppekey:: Symbol = :default ;
623
+ currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing ,
624
+ warn_if_absent:: Bool = true )
625
+
622
626
tx = currentTransaction == nothing ? transaction (dfg. neo4jInstance. connection) : currentTransaction
623
627
for var in sourceVariables
624
- updatePPE! (dfg, var. label, getPPE (var, ppekey), currentTransaction= tx)
628
+ updatePPE! (dfg, var. label, getPPE (var, ppekey), currentTransaction= tx, warn_if_absent = warn_if_absent )
625
629
end
626
630
if currentTransaction == nothing
627
631
result = commit (tx)
@@ -694,8 +698,10 @@ function addDataEntry!(dfg::CloudGraphsDFG, label::Symbol, bde::BlobStoreEntry;
694
698
packed)
695
699
end
696
700
697
- function updateDataEntry! (dfg:: CloudGraphsDFG , label:: Symbol , bde:: BlobStoreEntry ; currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing )
698
- if ! (bde. label in listDataEntries (dfg, label, currentTransaction= currentTransaction))
701
+ function updateDataEntry! (dfg:: CloudGraphsDFG , label:: Symbol , bde:: BlobStoreEntry ;
702
+ currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing ,
703
+ warn_if_absent:: Bool = true )
704
+ if warn_if_absent && ! (bde. label in listDataEntries (dfg, label, currentTransaction= currentTransaction))
699
705
@warn " Data label '$(bde. label) ' does not exist, adding"
700
706
end
701
707
packed = _matchmergeVariableSubnode! (
@@ -773,8 +779,9 @@ function updateVariableSolverData!(dfg::CloudGraphsDFG,
773
779
vnd:: VariableNodeData ,
774
780
useCopy:: Bool = true ,
775
781
fields:: Vector{Symbol} = Symbol[];
782
+ warn_if_absent:: Bool = true ,
776
783
currentTransaction:: Union{Nothing, Neo4j.Transaction} = nothing ):: VariableNodeData
777
- if ! (vnd. solveKey in listVariableSolverData (dfg, variablekey, currentTransaction= currentTransaction))
784
+ if warn_if_absent && ! (vnd. solveKey in listVariableSolverData (dfg, variablekey, currentTransaction= currentTransaction))
778
785
@warn " Solver data '$(vnd. solveKey) ' does not exist, adding rather than updating."
779
786
end
780
787
# TODO : Update this to use the selective parameters from fields.
@@ -847,10 +854,11 @@ function updateVariableSolverData!(dfg::CloudGraphsDFG,
847
854
sourceVariables:: Vector{<:DFGVariable} ,
848
855
solvekey:: Symbol = :default ,
849
856
useCopy:: Bool = true ,
850
- fields:: Vector{Symbol} = Symbol[] )
857
+ fields:: Vector{Symbol} = Symbol[];
858
+ warn_if_absent:: Bool = true )
851
859
# TODO : Do in bulk for speed.
852
860
for var in sourceVariables
853
- updateVariableSolverData! (dfg, var. label, getSolverData (var, solvekey), solvekey, useCopy, fields)
861
+ updateVariableSolverData! (dfg, var. label, getSolverData (var, solvekey), solvekey, useCopy, fields; warn_if_absent = warn_if_absent )
854
862
end
855
863
end
856
864
0 commit comments