Skip to content

Commit e79bed1

Browse files
authored
Merge pull request #996 from JuliaRobotics/23Q1/enh/getblobentvars
2 parents a78b6d9 + c22a5dc commit e79bed1

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

src/DataBlobs/services/BlobEntry.jl

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ hasBlobEntry(var::AbstractDFGVariable, blobLabel::Symbol) = haskey(var.dataDict,
200200

201201
"""
202202
$(SIGNATURES)
203-
Get data entries, Vector{BlobEntry}
203+
204+
Get blob entries, Vector{BlobEntry}
204205
"""
205206
function getBlobEntries(var::AbstractDFGVariable)
206207
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,BlobEntry}}?
@@ -212,6 +213,36 @@ function getBlobEntries(dfg::AbstractDFG, label::Symbol)
212213
getBlobEntries(getVariable(dfg, label))
213214
end
214215

216+
"""
217+
$(SIGNATURES)
218+
219+
Get all blob entries matching a Regex pattern over variables
220+
221+
Notes
222+
- Use `dropEmpties=true` to not include empty lists in result.
223+
- Use keyword `varList` for which variables to search through.
224+
"""
225+
function getBlobEntriesVariables(
226+
dfg::AbstractDFG,
227+
bLblPattern::Regex;
228+
varList::AbstractVector{Symbol} = sort(listVariables(dfg); lt=natural_lt),
229+
dropEmpties::Bool = false
230+
)
231+
RETLIST = Vector{Vector{BlobEntry}}()
232+
@showprogress "Get entries matching $bLblPattern" for vl in varList
233+
bes = filter(
234+
s->occursin(bLblPattern,string(s.label)),
235+
listBlobEntries(dfg,vl)
236+
)
237+
# only push to list if there are entries on this variable
238+
(!dropEmpties || 0 < length(bes)) ? nothing : continue
239+
push!(RETLIST, bes)
240+
end
241+
242+
return RETLIST
243+
end
244+
245+
215246
"""
216247
$(SIGNATURES)
217248
List the blob entries associated with a particular variable.

src/DataBlobs/services/HelpersDataWrapEntryBlob.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# NOTE this is the convenience wrappers for entry and blob.
77

88
"""
9-
Get the data entry and blob for the specified blobstore or dfg retured as a tuple.
9+
Get the blob entry and blob for the specified blobstore or dfg retured as a tuple.
1010
Related
1111
[`getBlobEntry`](@ref)
1212
@@ -241,12 +241,12 @@ end
241241
deleteData!(
242242
dfg::AbstractDFG,
243243
blobstore::AbstractBlobStore,
244-
label::Symbol,
244+
vLbl::Symbol,
245245
entry::BlobEntry
246246
) = deleteBlob!(
247247
dfg,
248248
blobstore,
249-
label,
249+
vLbl,
250250
entry.label
251251
)
252252

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export hasBlobEntry,getBlobEntry,addBlobEntry!,updateBlobEntry!,deleteBlobEntry!
200200
export incrDataLabelSuffix
201201

202202
export getBlobEntries, listDataEntries, hasDataEntry, hasDataEntry
203+
export getBlobEntriesVariables
203204
export listDataEntrySequence
204205
# convenience wrappers
205206
export mergeDataEntries!

0 commit comments

Comments
 (0)