Skip to content

Commit 9987a98

Browse files
committed
Standardize abstract types and other cleanup
1 parent e8b1286 commit 9987a98

27 files changed

Lines changed: 477 additions & 419 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ docs/build
77
Manifest.toml
88
dev
99
test/sandbox.jl
10+
lcov.info

src/Common.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
_getmodule(t::T) where {T} = T.name.module
44
_getname(t::T) where {T} = T.name.name
55

6-
function convertPackedType(t::Union{T, Type{T}}) where {T <: AbstractFactorObservation}
6+
function convertPackedType(t::Union{T, Type{T}}) where {T <: AbstractObservation}
77
return getfield(_getmodule(t), Symbol("Packed$(_getname(t))"))
88
end
9-
function convertStructType(::Type{PT}) where {PT <: AbstractPackedFactorObservation}
9+
function convertStructType(::Type{PT}) where {PT <: AbstractPackedObservation}
1010
# see #668 for expanded reasoning. PT may be ::UnionAll if the type is of template type.
1111
ptt = PT isa DataType ? PT.name.name : PT
1212
moduleName = PT isa DataType ? PT.name.module : Main
@@ -64,7 +64,7 @@ Related
6464
6565
ls, lsf
6666
"""
67-
function sortDFG(vars::Vector{<:DFGNode}; by = getTimestamp, kwargs...)
67+
function sortDFG(vars::Vector{<:AbstractGraphNode}; by = getTimestamp, kwargs...)
6868
return sort(vars; by = by, kwargs...)
6969
end
7070
sortDFG(vars::Vector{Symbol}; lt = natural_lt, kwargs...) = sort(vars; lt = lt, kwargs...)

src/DataBlobs/services/BlobEntry.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Get data entry
6565
6666
Also see: [`addBlobentry!`](@ref), [`getBlob`](@ref), [`listBlobentries`](@ref)
6767
"""
68-
function getBlobentry(var::AbstractDFGVariable, key::Symbol)
68+
function getBlobentry(var::AbstractGraphVariable, key::Symbol)
6969
if !hasBlobentry(var, key)
7070
throw(LabelNotFoundError("Blobentry", key, collect(keys(var.dataDict))))
7171
end
@@ -85,7 +85,7 @@ Finds and returns the first blob entry that matches the filter.
8585
8686
Also see: [`getBlobentry`](@ref)
8787
"""
88-
function getfirstBlobentry(var::AbstractDFGVariable, blobId::UUID)
88+
function getfirstBlobentry(var::AbstractGraphVariable, blobId::UUID)
8989
for (k, v) in var.dataDict
9090
if blobId == v.blobId
9191
return v
@@ -98,7 +98,7 @@ function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, blobId::UUID)
9898
return getfirstBlobentry(getVariable(dfg, label), blobId)
9999
end
100100

101-
function getfirstBlobentry(var::AbstractDFGVariable, key::Regex)
101+
function getfirstBlobentry(var::AbstractGraphVariable, key::Regex)
102102
for (k, v) in var.dataDict
103103
if occursin(key, string(v.label))
104104
return v
@@ -152,7 +152,7 @@ Should be extended if DFG variable is not returned by reference.
152152
153153
Also see: [`getBlobentry`](@ref), [`addBlob!`](@ref), [`mergeBlobentries!`](@ref)
154154
"""
155-
function addBlobentry!(var::AbstractDFGVariable, entry::Blobentry)
155+
function addBlobentry!(var::AbstractGraphVariable, entry::Blobentry)
156156
# see https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/985
157157
# blobId::Union{UUID,Nothing} = (isnothing(entry.blobId) ? entry.id : entry.blobId),
158158
# blobSize::Int = (hasfield(Blobentry, :size) ? entry.size : -1)
@@ -182,7 +182,7 @@ Update a Blobentry in the factor graph.
182182
If the Blobentry does not exist, it will be added.
183183
Notes:
184184
"""
185-
function mergeBlobentry!(var::AbstractDFGVariable, bde::Blobentry)
185+
function mergeBlobentry!(var::AbstractGraphVariable, bde::Blobentry)
186186
if !haskey(var.dataDict, bde.label)
187187
addBlobentry!(var, bde)
188188
else
@@ -203,7 +203,7 @@ Note this doesn't remove it from any data stores.
203203
Notes:
204204
- users responsibility to delete data in db before deleting entry
205205
"""
206-
function deleteBlobentry!(var::AbstractDFGVariable, key::Symbol)
206+
function deleteBlobentry!(var::AbstractGraphVariable, key::Symbol)
207207
pop!(var.dataDict, key)
208208
return 1
209209
end
@@ -226,7 +226,7 @@ function deleteBlobentry!(dfg::AbstractDFG, label::Symbol, key::Symbol)
226226
return deleteBlobentry!(getVariable(dfg, label), key)
227227
end
228228

229-
function deleteBlobentry!(var::AbstractDFGVariable, entry::Blobentry)
229+
function deleteBlobentry!(var::AbstractGraphVariable, entry::Blobentry)
230230
#users responsibility to delete data in db before deleting entry
231231
return deleteBlobentry!(var, entry.label)
232232
end
@@ -240,7 +240,8 @@ end
240240
241241
Does a blob entry exist with `blobLabel`.
242242
"""
243-
hasBlobentry(var::AbstractDFGVariable, blobLabel::Symbol) = haskey(var.dataDict, blobLabel)
243+
hasBlobentry(var::AbstractGraphVariable, blobLabel::Symbol) =
244+
haskey(var.dataDict, blobLabel)
244245

245246
function hasBlobentry(var::VariableDFG, label::Symbol)
246247
return label in getproperty.(var.blobEntries, :label)
@@ -251,7 +252,7 @@ end
251252
252253
Get blob entries, Vector{Blobentry}
253254
"""
254-
function getBlobentries(var::AbstractDFGVariable)
255+
function getBlobentries(var::AbstractGraphVariable)
255256
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,Blobentry}}?
256257
return collect(values(var.dataDict))
257258
end
@@ -311,7 +312,7 @@ end
311312
$(SIGNATURES)
312313
List the blob entries associated with a particular variable.
313314
"""
314-
function listBlobentries(var::AbstractDFGVariable)
315+
function listBlobentries(var::AbstractGraphVariable)
315316
return collect(keys(var.dataDict))
316317
end
317318

src/DataBlobs/services/BlobStores.jl

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Get the data blob for the specified blobstore or dfg.
77
88
Related
99
[`getBlobentry`](@ref)
10+
Implement
11+
`getBlob(store::AbstractBlobstore, blobId::UUID)`
1012
1113
$(METHODLIST)
1214
"""
@@ -17,67 +19,31 @@ Adds a blob to the blob store or dfg with the blobId.
1719
1820
Related
1921
[`addBlobentry!`](@ref)
20-
22+
Implement
23+
`addBlob!(store::AbstractBlobstore, blobId::UUID, data)`
2124
$(METHODLIST)
2225
"""
2326
function addBlob! end
2427

25-
"""
26-
Update a blob to the blob store or dfg with the given entry.
27-
Related
28-
[`mergeBlobentry!`](@ref)
29-
30-
$(METHODLIST)
31-
32-
DevNotes
33-
- TODO TBD update verb on data since data blobs and entries are restricted to immutable only.
34-
"""
35-
function updateBlob! end
36-
3728
"""
3829
Delete a blob from the blob store or dfg with the given entry.
3930
4031
Related
4132
[`deleteBlobentry!`](@ref)
42-
33+
Implement
34+
`deleteBlob!(store::AbstractBlobstore, blobId::UUID)`
4335
$(METHODLIST)
4436
"""
4537
function deleteBlob! end
4638

4739
"""
4840
$(SIGNATURES)
49-
List all ids in the blob store.
41+
List all `blobId`s in the blob store.
42+
Implement
43+
`listBlobs(store::AbstractBlobstore)`
5044
"""
5145
function listBlobs end
5246

53-
##==============================================================================
54-
## AbstractBlobstore CRUD Interface
55-
##==============================================================================
56-
57-
function getBlob(store::AbstractBlobstore, ::UUID)
58-
return error("$(typeof(store)) doesn't override 'getBlob'.")
59-
end
60-
61-
function addBlob!(store::AbstractBlobstore{T}, ::UUID, ::T) where {T}
62-
return error("$(typeof(store)) doesn't override 'addBlob!'.")
63-
end
64-
65-
function updateBlob!(store::AbstractBlobstore{T}, ::UUID, ::T) where {T}
66-
return error("$(typeof(store)) doesn't override 'updateBlob!'.")
67-
end
68-
69-
function deleteBlob!(store::AbstractBlobstore, ::UUID)
70-
return error("$(typeof(store)) doesn't override 'deleteBlob!'.")
71-
end
72-
73-
function listBlobs(store::AbstractBlobstore)
74-
return error("$(typeof(store)) doesn't override 'listBlobs'.")
75-
end
76-
77-
function hasBlob(store::AbstractBlobstore, ::UUID)
78-
return error("$(typeof(store)) doesn't override 'hasBlob'.")
79-
end
80-
8147
##==============================================================================
8248
## AbstractBlobstore derived CRUD for Blob
8349
##==============================================================================

src/Deprecated.jl

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ export AbstractRelativeMinimize,
99
InferenceType,
1010
PackedSamplableBelief
1111

12+
#TODO: maybe just remove these
13+
export NoSolverParams
14+
1215
const AbstractPrior = PriorObservation
1316
const AbstractRelative = RelativeObservation
17+
const AbstractParams = AbstractDFGParams
1418

1519
abstract type AbstractRelativeMinimize <: RelativeObservation end
1620
abstract type AbstractManifoldMinimize <: RelativeObservation end
1721

1822
const InferenceVariable = VariableStateType{Any}
19-
const InferenceType = AbstractPackedFactorObservation
23+
const InferenceType = AbstractPackedObservation
2024

2125
const PackedSamplableBelief = PackedBelief
2226

@@ -149,14 +153,36 @@ function cloneSolveKey!(dfg::AbstractDFG, dest::Symbol, src::Symbol; kw...)
149153
return cloneSolveKey!(dfg, dest, dfg, src; kw...)
150154
end
151155

156+
export getData, addData!, updateData!, deleteData!
157+
158+
#TODO not a good function, as it's not complete.
159+
# """
160+
# $(SIGNATURES)
161+
# Convenience function to get all the metadata of a DFG
162+
# """
163+
# export getDFGInfo
164+
function getDFGInfo(dfg::AbstractDFG)
165+
return (
166+
description = getDescription(dfg),
167+
agentLabel = getAgentLabel(dfg),
168+
graphLabel = getGraphLabel(dfg),
169+
agentMetadata = getAgentMetadata(dfg),
170+
graphMetadata = getGraphMetadata(dfg),
171+
solverParams = getSolverParams(dfg),
172+
)
173+
end
174+
175+
export DFGVariable
176+
const DFGVariable = VariableCompute
177+
152178
## ================================================================================
153179
## Deprecated in v0.27
154180
##=================================================================================
155181
export AbstractFactor
156-
const AbstractFactor = AbstractFactorObservation
182+
const AbstractFactor = AbstractObservation
157183

158184
export AbstractPackedFactor
159-
const AbstractPackedFactor = AbstractPackedFactorObservation
185+
const AbstractPackedFactor = AbstractPackedObservation
160186

161187
export FactorOperationalMemory
162188
const FactorOperationalMemory = FactorSolverCache
@@ -214,8 +240,8 @@ const VariableNodeData = VariableState
214240
@deprecate hasBlobEntry(args...; kwargs...) hasBlobentry(args...; kwargs...)
215241
@deprecate getBlobEntry(args...; kwargs...) getBlobentry(args...; kwargs...)
216242
@deprecate getBlobEntryFirst(args...; kwargs...) getfirstBlobentry(args...; kwargs...)
217-
@deprecate getBlobentry(var::AbstractDFGVariable, blobId::UUID) getfirstBlobentry(
218-
var::AbstractDFGVariable,
243+
@deprecate getBlobentry(var::AbstractGraphVariable, blobId::UUID) getfirstBlobentry(
244+
var::AbstractGraphVariable,
219245
blobId::UUID,
220246
)
221247
@deprecate addBlobEntry!(args...; kwargs...) addBlobentry!(args...; kwargs...)
@@ -385,11 +411,7 @@ end
385411

386412
## factor refactor deprecations
387413
Base.@kwdef mutable struct GenericFunctionNodeData{
388-
T <: Union{
389-
<:AbstractPackedFactorObservation,
390-
<:AbstractFactorObservation,
391-
<:FactorSolverCache,
392-
},
414+
T <: Union{<:AbstractPackedObservation, <:AbstractObservation, <:FactorSolverCache},
393415
}
394416
eliminated::Bool = false
395417
potentialused::Bool = false
@@ -481,7 +503,7 @@ function decodePackedType(
481503
end
482504

483505
export _packSolverData
484-
function _packSolverData(f::FactorCompute, fnctype::AbstractFactorObservation)
506+
function _packSolverData(f::FactorCompute, fnctype::AbstractObservation)
485507
#
486508
error("_packSolverData is deprecated, use seperate packing of observation #TODO")
487509
packtype = convertPackedType(fnctype)
@@ -501,20 +523,20 @@ end
501523
export GenericFunctionNodeData, PackedFunctionNodeData, FunctionNodeData
502524

503525
const PackedFunctionNodeData{T} =
504-
GenericFunctionNodeData{T} where {T <: AbstractPackedFactorObservation}
526+
GenericFunctionNodeData{T} where {T <: AbstractPackedObservation}
505527
function PackedFunctionNodeData(args...; kw...)
506528
error("PackedFunctionNodeData is obsolete")
507529
return PackedFunctionNodeData{typeof(args[4])}(args...; kw...)
508530
end
509531

510532
const FunctionNodeData{T} = GenericFunctionNodeData{
511533
T,
512-
} where {T <: Union{<:AbstractFactorObservation, <:FactorSolverCache}}
534+
} where {T <: Union{<:AbstractObservation, <:FactorSolverCache}}
513535
FunctionNodeData(args...; kw...) = FunctionNodeData{typeof(args[4])}(args...; kw...)
514536

515537
# this is the GenericFunctionNodeData for packed types
516538
#TODO deprecate FactorData in favor of FactorState (with no more distinction between packed and compute)
517-
const FactorData = PackedFunctionNodeData{AbstractPackedFactorObservation}
539+
const FactorData = PackedFunctionNodeData{AbstractPackedObservation}
518540

519541
function FactorCompute(
520542
label::Symbol,

0 commit comments

Comments
 (0)