Skip to content

Commit

Permalink
implement addVariables! and addFactors! (#1101)
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Terblanche <[email protected]>
  • Loading branch information
Affie and Affie authored Oct 25, 2024
1 parent d3dc7b7 commit a9e1655
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/DistributedFactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export InMemoryDFGTypes, LocalDFG
# AbstractDFG Interface
export exists,
addVariable!,
addVariables!,
addFactor!,
addFactors!,
getVariable,
getFactor,
updateVariable!,
Expand Down
3 changes: 1 addition & 2 deletions src/FileDFG/services/FileDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ function loadDFG!(
# do actual unzipping
filename = lastdirname[1:(end - length(".tar.gz"))] |> string
if unzip
@show sfolder = split(dstname, '.')
Base.mkpath(loaddir)
folder = joinpath(loaddir, filename) #splitpath(string(sfolder[end-2]))[end]
folder = joinpath(loaddir, filename)
@info "loadDFG! detected a gzip $dstname -- unpacking via $loaddir now..."
Base.rm(folder; recursive = true, force = true)
# unzip the tar file
Expand Down
3 changes: 2 additions & 1 deletion src/entities/DFGFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ Base.@kwdef struct PackedFactor <: AbstractDFGFactor
end
#TODO type not in DFG PackedFactor, should it be?
# _type::String

# createdTimestamp::DateTime
# lastUpdatedTimestamp::DateTime

PackedFactor(f::PackedFactor) = f

# TODO consolidate to just one type
"""
$(TYPEDEF)
Expand Down
22 changes: 21 additions & 1 deletion src/services/AbstractDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,33 @@ function addVariable!(
end

"""
Add a DFGFactor to a DFG.
$(SIGNATURES)
Add a Vector{DFGVariable} to a DFG.
"""
function addVariables!(dfg::AbstractDFG, variables::Vector{<:AbstractDFGVariable})
return asyncmap(variables) do v
return addVariable!(dfg, v)
end
end

"""
$(SIGNATURES)
Add a DFGFactor to a DFG.
"""
function addFactor!(dfg::AbstractDFG, factor::F) where {F <: AbstractDFGFactor}
return error("addFactor! not implemented for $(typeof(dfg))(dfg, factor)")
end

"""
$(SIGNATURES)
Add a Vector{DFGFactor} to a DFG.
"""
function addFactors!(dfg::AbstractDFG, factors::Vector{<:AbstractDFGFactor})
return asyncmap(factors) do f
return addFactor!(dfg, f)
end
end

"""
$(SIGNATURES)
Get a DFGVariable from a DFG using its label.
Expand Down

0 comments on commit a9e1655

Please sign in to comment.