Skip to content

Commit e63d336

Browse files
authored
Merge pull request #402 from JuliaRobotics/feat/2Q20/401
add hasDataEntry, rm ReturnTypes
2 parents 6578196 + 8e35c78 commit e63d336

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

src/BigData/services/AbstractBigDataEntries.jl

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
$(SIGNATURES)
2121
Add Big Data Entry to a DFG variable
2222
"""
23-
function addBigDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)::AbstractBigDataEntry
23+
function addBigDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)
2424
haskey(var.bigData,bde.key) && error("BigData entry $(bde.key) already exists in variable")
2525
var.bigData[bde.key] = bde
2626
return bde
@@ -31,33 +31,41 @@ end
3131
Add Big Data Entry to distributed factor graph.
3232
Should be extended if DFG variable is not returned by reference.
3333
"""
34-
function addBigDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)::AbstractBigDataEntry
34+
function addBigDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)
3535
return addBigDataEntry!(getVariable(dfg, label), bde)
3636
end
3737

38+
"""
39+
$SIGNATURES
40+
41+
Does a data entry (element) exist at `key`.
42+
"""
43+
hasDataEntry(var::DFGVariable, key::Symbol) = haskey(var.bigData, key)
44+
const hasBigDataEntry = hasDataEntry
45+
3846
"""
3947
$(SIGNATURES)
4048
Get big data entry
4149
"""
42-
function getBigDataEntry(var::AbstractDFGVariable, key::Symbol)::Union{Nothing, AbstractBigDataEntry}
43-
!haskey(var.bigData, key) && (error("BigData entry $(key) does not exist in variable"); return nothing)
50+
function getBigDataEntry(var::AbstractDFGVariable, key::Symbol)
51+
!hasDataEntry(var, key) && (error("BigData entry $(key) does not exist in variable"); return nothing)
4452
return var.bigData[key]
4553
end
4654

47-
function getBigDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol)::Union{Nothing, AbstractBigDataEntry}
55+
function getBigDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol)
4856
return getBigDataEntry(getVariable(dfg, label), key)
4957
end
5058

5159
"""
5260
$(SIGNATURES)
5361
Update big data entry
5462
"""
55-
function updateBigDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)::Union{Nothing, AbstractBigDataEntry}
63+
function updateBigDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)
5664
!haskey(var.bigData,bde.key) && (@warn "$(bde.key) does not exist in variable, adding")
5765
var.bigData[bde.key] = bde
5866
return bde
5967
end
60-
function updateBigDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)::Union{Nothing, AbstractBigDataEntry}
68+
function updateBigDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)
6169
# !isVariable(dfg, label) && return nothing
6270
return updateBigDataEntry!(getVariable(dfg, label), bde)
6371
end
@@ -66,31 +74,36 @@ end
6674
$(SIGNATURES)
6775
Delete big data entry from the factor graph.
6876
Note this doesn't remove it from any data stores.
77+
78+
Notes:
79+
- users responsibility to delete big data in db before deleting entry
6980
"""
70-
function deleteBigDataEntry!(var::AbstractDFGVariable, key::Symbol)::Union{Nothing, AbstractDFGVariable} #users responsibility to delete big data in db before deleting entry
81+
function deleteBigDataEntry!(var::AbstractDFGVariable, key::Symbol)
7182
bde = getBigDataEntry(var, key)
7283
bde == nothing && return nothing
7384
delete!(var.bigData, key)
7485
return var
7586
end
76-
function deleteBigDataEntry!(dfg::AbstractDFG, label::Symbol, key::Symbol)::Union{Nothing, AbstractDFGVariable} #users responsibility to delete big data in db before deleting entry
87+
function deleteBigDataEntry!(dfg::AbstractDFG, label::Symbol, key::Symbol)
88+
#users responsibility to delete big data in db before deleting entry
7789
!isVariable(dfg, label) && return nothing
7890
return deleteBigDataEntry!(getVariable(dfg, label), key)
7991
end
8092

81-
function deleteBigDataEntry!(var::AbstractDFGVariable, entry::AbstractBigDataEntry)::Union{Nothing, AbstractDFGVariable} #users responsibility to delete big data in db before deleting entry
93+
function deleteBigDataEntry!(var::AbstractDFGVariable, entry::AbstractBigDataEntry)
94+
#users responsibility to delete big data in db before deleting entry
8295
return deleteBigDataEntry!(var, entry.key)
8396
end
8497

8598
"""
8699
$(SIGNATURES)
87100
Get big data entries, Vector{AbstractBigDataEntry}
88101
"""
89-
function getBigDataEntries(var::AbstractDFGVariable)::Vector{AbstractBigDataEntry}
102+
function getBigDataEntries(var::AbstractDFGVariable)
90103
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBigDataEntry}}?
91104
collect(values(var.bigData))
92105
end
93-
function getBigDataEntries(dfg::AbstractDFG, label::Symbol)::Union{Nothing, Vector{AbstractBigDataEntry}}
106+
function getBigDataEntries(dfg::AbstractDFG, label::Symbol)
94107
!isVariable(dfg, label) && return nothing
95108
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBigDataEntry}}?
96109
getBigDataEntries(getVariable(dfg, label))
@@ -101,10 +114,10 @@ end
101114
$(SIGNATURES)
102115
getBigDataKeys
103116
"""
104-
function getBigDataKeys(var::AbstractDFGVariable)::Vector{Symbol}
117+
function getBigDataKeys(var::AbstractDFGVariable)
105118
collect(keys(var.bigData))
106119
end
107-
function getBigDataKeys(dfg::AbstractDFG, label::Symbol)::Union{Nothing, Vector{Symbol}}
120+
function getBigDataKeys(dfg::AbstractDFG, label::Symbol)
108121
!isVariable(dfg, label) && return nothing
109122
getBigDataKeys(getVariable(dfg, label))
110123
end

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export getNeighborhood, getNeighbors, _getDuplicatedEmptyDFG
165165
export copyGraph!, deepcopyGraph, deepcopyGraph!, buildSubgraph, mergeGraph!
166166
# Big Data
167167
##------------------------------------------------------------------------------
168-
export addBigDataEntry!, getBigDataEntry, updateBigDataEntry!, deleteBigDataEntry!, getBigDataEntries, getBigDataKeys
168+
export addBigDataEntry!, getBigDataEntry, updateBigDataEntry!, deleteBigDataEntry!, getBigDataEntries, getBigDataKeys, hasDataEntry, hasBigDataEntry
169169

170170

171171
##------------------------------------------------------------------------------

0 commit comments

Comments
 (0)