Skip to content

Commit a9e1655

Browse files
authored
implement addVariables! and addFactors! (#1101)
Co-authored-by: Johannes Terblanche <Affie@users.noreply.github.com>
1 parent d3dc7b7 commit a9e1655

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ export InMemoryDFGTypes, LocalDFG
105105
# AbstractDFG Interface
106106
export exists,
107107
addVariable!,
108+
addVariables!,
108109
addFactor!,
110+
addFactors!,
109111
getVariable,
110112
getFactor,
111113
updateVariable!,

src/FileDFG/services/FileDFG.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ function loadDFG!(
123123
# do actual unzipping
124124
filename = lastdirname[1:(end - length(".tar.gz"))] |> string
125125
if unzip
126-
@show sfolder = split(dstname, '.')
127126
Base.mkpath(loaddir)
128-
folder = joinpath(loaddir, filename) #splitpath(string(sfolder[end-2]))[end]
127+
folder = joinpath(loaddir, filename)
129128
@info "loadDFG! detected a gzip $dstname -- unpacking via $loaddir now..."
130129
Base.rm(folder; recursive = true, force = true)
131130
# unzip the tar file

src/entities/DFGFactor.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ Base.@kwdef struct PackedFactor <: AbstractDFGFactor
104104
end
105105
#TODO type not in DFG PackedFactor, should it be?
106106
# _type::String
107-
108107
# createdTimestamp::DateTime
109108
# lastUpdatedTimestamp::DateTime
110109

110+
PackedFactor(f::PackedFactor) = f
111+
111112
# TODO consolidate to just one type
112113
"""
113114
$(TYPEDEF)

src/services/AbstractDFG.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,33 @@ function addVariable!(
279279
end
280280

281281
"""
282-
Add a DFGFactor to a DFG.
283282
$(SIGNATURES)
283+
Add a Vector{DFGVariable} to a DFG.
284+
"""
285+
function addVariables!(dfg::AbstractDFG, variables::Vector{<:AbstractDFGVariable})
286+
return asyncmap(variables) do v
287+
return addVariable!(dfg, v)
288+
end
289+
end
290+
291+
"""
292+
$(SIGNATURES)
293+
Add a DFGFactor to a DFG.
284294
"""
285295
function addFactor!(dfg::AbstractDFG, factor::F) where {F <: AbstractDFGFactor}
286296
return error("addFactor! not implemented for $(typeof(dfg))(dfg, factor)")
287297
end
288298

299+
"""
300+
$(SIGNATURES)
301+
Add a Vector{DFGFactor} to a DFG.
302+
"""
303+
function addFactors!(dfg::AbstractDFG, factors::Vector{<:AbstractDFGFactor})
304+
return asyncmap(factors) do f
305+
return addFactor!(dfg, f)
306+
end
307+
end
308+
289309
"""
290310
$(SIGNATURES)
291311
Get a DFGVariable from a DFG using its label.

0 commit comments

Comments
 (0)