@@ -27,6 +27,8 @@ buildSourceString(dfg::AbstractDFG, label::Symbol) =
27
27
"""
28
28
$(SIGNATURES)
29
29
Get data entry
30
+
31
+ Also see: [`addDataEntry`](@ref), [`getDataBlob`](@ref), [`listDataEntries`](@ref)
30
32
"""
31
33
function getDataEntry (var:: AbstractDFGVariable , key:: Symbol )
32
34
! hasDataEntry (var, key) && error (" No dataEntry label $(key) found in variable $(getLabel (var)) " )
@@ -42,25 +44,23 @@ function getDataEntry(var::AbstractDFGVariable, blobId::UUID)
42
44
error (" No dataEntry with blobId $(blobId) found in variable $(getLabel (var)) " )
43
45
end
44
46
45
- getDataEntry (dfg:: AbstractDFG , label:: Symbol , key:: Union{Symbol,UUID} ) = getDataEntry (getVariable (dfg, label), key)
47
+ getDataEntry (dfg:: AbstractDFG , label:: Symbol , key:: UUID ) = getDataEntry (getVariable (dfg, label), key)
48
+ getDataEntry (dfg:: AbstractDFG , label:: Symbol , key:: Symbol ) = getDataEntry (getVariable (dfg, label), key)
46
49
47
50
48
51
"""
49
52
$(SIGNATURES)
50
53
Add Data Entry to a DFG variable
54
+ Should be extended if DFG variable is not returned by reference.
55
+
56
+ Also see: [`getDataEntry`](@ref), [`addDataBlob`](@ref), [`mergeDataEntries!`](@ref)
51
57
"""
52
58
function addDataEntry! (var:: AbstractDFGVariable , bde:: AbstractDataEntry )
53
59
haskey (var. dataDict, bde. label) && error (" Data entry $(bde. label) already exists in variable $(getLabel (var)) " )
54
60
var. dataDict[bde. label] = bde
55
61
return bde
56
62
end
57
63
58
-
59
- """
60
- $(SIGNATURES)
61
- Add Data Entry to distributed factor graph.
62
- Should be extended if DFG variable is not returned by reference.
63
- """
64
64
function addDataEntry! (dfg:: AbstractDFG , label:: Symbol , bde:: AbstractDataEntry )
65
65
return addDataEntry! (getVariable (dfg, label), bde)
66
66
end
@@ -173,3 +173,46 @@ function listDataEntrySequence( dfg::AbstractDFG,
173
173
entMsk = entReg .!= = nothing
174
174
ents_[findall (entMsk)] |> _sort
175
175
end
176
+
177
+ """
178
+ $SIGNATURES
179
+
180
+ Add a data entry into the destination variable which already exists
181
+ in a source variable.
182
+
183
+ See also: [`addDataEntry!`](@ref), [`getDataEntry`](@ref), [`listDataEntries`](@ref), [`getDataBlob`](@ref)
184
+ """
185
+ function mergeDataEntries! (
186
+ dst:: AbstractDFG ,
187
+ dlbl:: Symbol ,
188
+ src:: AbstractDFG ,
189
+ slbl:: Symbol ,
190
+ bllb:: Union{Symbol, UUID, <:AbstractString, Regex}
191
+ )
192
+ #
193
+ _makevec (s) = [s;]
194
+ _makevec (s:: AbstractVector ) = s
195
+ des_ = getDataEntry (src, slbl, bllb)
196
+ des = _makevec (des_)
197
+ # don't add data entries that already exist
198
+ dde = listDataEntries (dst, dlbl)
199
+ uids = (s-> s. id). (dde)
200
+ filter! (s -> ! (s. id in uids), des)
201
+ # add any data entries not already in the destination variable, by uuid
202
+ addDataEntry! .(dst, dlbl, des)
203
+ end
204
+
205
+ function mergeDataEntries! (
206
+ dst:: AbstractDFG ,
207
+ dlbl:: Symbol ,
208
+ src:: AbstractDFG ,
209
+ slbl:: Symbol ,
210
+ :: Colon = :
211
+ )
212
+ des = listDataEntries (src, slbl)
213
+ # don't add data entries that already exist
214
+ dde = listDataEntries (dst, dlbl)
215
+ uids = (s-> s. id). (dde)
216
+ filter! (s -> ! (s. id in uids), des)
217
+ union (((s-> mergeDataEntries! (dst, dlbl, src, slbl, s. id)). (des)). .. )
218
+ end
0 commit comments