Skip to content

Commit 4ce4d21

Browse files
authored
Add some missing functions, Blobentry and merge (#1202)
* Add some missing functions, Blobentry and merge * test Factor Blobentry * VariableCompute -> VariableDFG * imporve Agent/Graph Blobentry test
1 parent 4a13246 commit 4ce4d21

24 files changed

+428
-297
lines changed

docs/src/DataStructure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Accessible properties for each of the variable structures:
1717
|---------------------|-------|-----------|------|-----------|-----------|----------|-------------|----------|--------------|
1818
| VariableSkeleton | X | | X | | | | | | |
1919
| VariableSummary | X | X | X | X | Symbol | | | | X |
20-
| VariableCompute | X | X | X | X | X | X | X | X | X |
20+
| VariableDFG | X | X | X | X | X | X | X | X | X |
2121

2222
Accessible properties for each of the factor structures:
2323

docs/src/GraphData.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,6 @@ Agent and Graph bloblets are useful for storing data that is related to the enti
161161
Example of using graph-level data:
162162

163163
```julia
164-
setAgentMetadata!(dfg, Dict(:a => "Hello"))
165-
getAgentMetadata(dfg)
164+
addAgentBloblet!(dfg, Bloblet(:status, "ready"))
165+
getAgentBloblet(dfg, :status)
166166
```

src/DataBlobs/entities/BlobEntry.jl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,6 @@ function Base.getproperty(x::Blobentry, f::Symbol)
113113
end
114114
end
115115

116-
function Base.setproperty!(x::Blobentry, f::Symbol, val)
117-
if f == :blobId
118-
@warn "Blobentry field :blobId has been renamed to :blobid"
119-
setfield!(x, :blobid, val)
120-
elseif f == :mimeType
121-
@warn "Blobentry field :mimeType has been renamed to :mimetype"
122-
setfield!(x, :mimetype, val)
123-
elseif f == :_version
124-
@warn "Blobentry field :_version has been renamed to :version"
125-
setfield!(x, :version, val)
126-
elseif f in [:id, :createdTimestamp, :lastUpdatedTimestamp, :hash]
127-
error("Blobentry field $f has been deprecated")
128-
else
129-
setfield!(x, f, val)
130-
end
131-
end
132-
133116
const Blobentries = OrderedDict{Symbol, Blobentry}
134117

135118
function StructUtils.lower(entries::Blobentries)

src/DataBlobs/services/BlobEntry.jl

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ end
1313
function getBlobentries(
1414
node;
1515
labelFilter::Union{Nothing, Function} = nothing,
16-
blobIdFilter::Union{Nothing, Function} = nothing,
16+
blobidFilter::Union{Nothing, Function} = nothing,
1717
)
1818
entries = collect(values(refBlobentries(node)))
1919
filterDFG!(entries, labelFilter, getLabel)
20-
filterDFG!(entries, blobIdFilter, x -> string(x.blobid))
20+
filterDFG!(entries, blobidFilter, x -> string(x.blobid))
2121
return entries
2222
end
2323

@@ -195,6 +195,52 @@ function listModelBlobentries end
195195
function hasGraphBlobentry end
196196
function hasAgentBlobentry end
197197
function hasModelBlobentry end
198+
199+
##==============================================================================
200+
## Default Variable/Factor implementations
201+
##==============================================================================
202+
203+
function getVariableBlobentry(dfg::AbstractDFG, variableLabel::Symbol, label::Symbol)
204+
return getBlobentry(getVariable(dfg, variableLabel), label)
205+
end
206+
207+
function getVariableBlobentries(
208+
dfg::AbstractDFG,
209+
variableLabel::Symbol;
210+
labelFilter::Union{Nothing, Function} = nothing,
211+
blobidFilter::Union{Nothing, Function} = nothing,
212+
)
213+
return getBlobentries(getVariable(dfg, variableLabel); labelFilter, blobidFilter)
214+
end
215+
216+
function listVariableBlobentries(dfg::AbstractDFG, variableLabel::Symbol)
217+
return listBlobentries(getVariable(dfg, variableLabel))
218+
end
219+
220+
function hasVariableBlobentry(dfg::AbstractDFG, variableLabel::Symbol, label::Symbol)
221+
return hasBlobentry(getVariable(dfg, variableLabel), label)
222+
end
223+
224+
function getFactorBlobentry(dfg::AbstractDFG, factorLabel::Symbol, label::Symbol)
225+
return getBlobentry(getFactor(dfg, factorLabel), label)
226+
end
227+
228+
function getFactorBlobentries(
229+
dfg::AbstractDFG,
230+
factorLabel::Symbol;
231+
labelFilter::Union{Nothing, Function} = nothing,
232+
blobidFilter::Union{Nothing, Function} = nothing,
233+
)
234+
return getBlobentries(getFactor(dfg, factorLabel); labelFilter, blobidFilter)
235+
end
236+
237+
function listFactorBlobentries(dfg::AbstractDFG, factorLabel::Symbol)
238+
return listBlobentries(getFactor(dfg, factorLabel))
239+
end
240+
241+
function hasFactorBlobentry(dfg::AbstractDFG, factorLabel::Symbol, label::Symbol)
242+
return hasBlobentry(getFactor(dfg, factorLabel), label)
243+
end
198244
##==============================================================================
199245
## Blobentry [default] bulk operations
200246
##==============================================================================
@@ -280,19 +326,10 @@ end
280326
## Blobentry - Helper functions, Lists, etc
281327
##==============================================================================
282328

283-
function getVariableBlobentries(
284-
dfg::AbstractDFG,
285-
variableLabel::Symbol;
286-
labelFilter::Union{Nothing, Function} = nothing,
287-
blobIdFilter::Union{Nothing, Function} = nothing,
288-
)
289-
return getBlobentries(getVariable(dfg, variableLabel); labelFilter, blobIdFilter)
290-
end
291-
292329
function gatherBlobentries(
293330
dfg::AbstractDFG;
294331
labelFilter::Union{Nothing, Function} = nothing,
295-
blobIdFilter::Union{Nothing, Function} = nothing,
332+
blobidFilter::Union{Nothing, Function} = nothing,
296333
solvableFilter::Union{Nothing, Function} = nothing,
297334
tagsFilter::Union{Nothing, Function} = nothing,
298335
typeFilter::Union{Nothing, Function} = nothing,
@@ -306,15 +343,11 @@ function gatherBlobentries(
306343
labelFilter = variableLabelFilter,
307344
)
308345
return map(vls) do vl
309-
return vl => getVariableBlobentries(dfg, vl; labelFilter, blobIdFilter)
346+
return vl => getVariableBlobentries(dfg, vl; labelFilter, blobidFilter)
310347
end
311348
end
312349
const collectBlobentries = gatherBlobentries
313350

314-
function listVariableBlobentries(dfg::AbstractDFG, label::Symbol)
315-
return listBlobentries(getVariable(dfg, label))
316-
end
317-
318351
"""
319352
$(SIGNATURES)
320353
Finds and returns the first blob entry that matches the filter.
@@ -324,11 +357,11 @@ Also see: [`getBlobentry`](@ref)
324357
function getfirstBlobentry(
325358
node;
326359
labelFilter::Union{Nothing, Function} = nothing,
327-
blobIdFilter::Union{Nothing, Function} = nothing,
360+
blobidFilter::Union{Nothing, Function} = nothing,
328361
sortby::Function = getLabel,
329362
sortlt::Function = natural_lt,
330363
)
331-
entries = getBlobentries(node; labelFilter, blobIdFilter)
364+
entries = getBlobentries(node; labelFilter, blobidFilter)
332365
if isempty(entries)
333366
return nothing
334367
else
@@ -340,9 +373,9 @@ function getfirstVariableBlobentry(
340373
dfg::AbstractDFG,
341374
label::Symbol;
342375
labelFilter::Union{Nothing, Function} = nothing,
343-
blobIdFilter::Union{Nothing, Function} = nothing,
376+
blobidFilter::Union{Nothing, Function} = nothing,
344377
)
345-
return getfirstBlobentry(getVariable(dfg, label); labelFilter, blobIdFilter)
378+
return getfirstBlobentry(getVariable(dfg, label); labelFilter, blobidFilter)
346379
end
347380

348381
## =============================================================================

src/Deprecated.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ end
5858
# isSolvable
5959
# """
6060
function getSolveInProgress(
61-
var::Union{VariableCompute, FactorCompute},
61+
var::Union{VariableDFG, FactorCompute},
6262
solveKey::Symbol = :default,
6363
)
6464
# Variable
65-
if var isa VariableCompute
65+
if var isa VariableDFG
6666
if haskey(refStates(var), solveKey)
6767
return refStates(var)[solveKey].solveInProgress
6868
else
@@ -76,7 +76,7 @@ end
7676
#TODO missing set solveInProgress and graph level accessor
7777

7878
function isSolveInProgress(
79-
node::Union{VariableCompute, FactorCompute},
79+
node::Union{VariableDFG, FactorCompute},
8080
solvekey::Symbol = :default,
8181
)
8282
return getSolveInProgress(node, solvekey) > 0
@@ -321,6 +321,12 @@ function updateBlob!(args...)
321321
return error("updateBlob! is obsolete as blobid=>Blob pairs are immutable.")
322322
end
323323

324+
function setTags!(node, tags::Union{Vector{Symbol}, Set{Symbol}})
325+
Base.depwarn("setTags! is deprecated, use mergeTags! or addTags! instead.", :setTags!)
326+
node.tags !== tags && empty!(node.tags)
327+
return union!(node.tags, tags)
328+
end
329+
324330
## ================================================================================
325331
## Deprecated in v0.28
326332
##=================================================================================
@@ -629,18 +635,18 @@ end
629635

630636
function getfirstBlobentry(var::AbstractGraphVariable, blobId::UUID)
631637
Base.depwarn(
632-
"getfirstBlobentry(var, blobId) is deprecated, use getfirstBlobentry(var; blobIdFilter = ==(string(blobId))) instead.",
638+
"getfirstBlobentry(var, blobId) is deprecated, use getfirstBlobentry(var; blobidFilter = ==(string(blobId))) instead.",
633639
:getfirstBlobentry,
634640
)
635-
return getfirstBlobentry(var; blobIdFilter = ==(string(blobId)))
641+
return getfirstBlobentry(var; blobidFilter = ==(string(blobId)))
636642
end
637643

638644
function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, blobId::UUID)
639645
Base.depwarn(
640-
"getfirstBlobentry(dfg, label, blobId) is deprecated, use getfirstBlobentry(dfg, label; blobIdFilter = ==(string(blobId))) instead.",
646+
"getfirstBlobentry(dfg, label, blobId) is deprecated, use getfirstBlobentry(dfg, label; blobidFilter = ==(string(blobId))) instead.",
641647
:getfirstBlobentry,
642648
)
643-
return getfirstBlobentry(dfg, label; blobIdFilter = ==(string(blobId)))
649+
return getfirstBlobentry(dfg, label; blobidFilter = ==(string(blobId)))
644650
end
645651

646652
function getfirstBlobentry(var::AbstractGraphVariable, key::Regex)

0 commit comments

Comments
 (0)