Skip to content

Commit 8756d25

Browse files
authored
Merge pull request #1032 from JuliaRobotics/23Q3/enh/getdata
getData sorting
2 parents 3344ba0 + 3f3a7ae commit 8756d25

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/DataBlobs/services/BlobEntry.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ function getBlobEntries(dfg::AbstractDFG, label::Symbol, regex::Regex)
242242
end
243243
end
244244

245+
getBlobEntries(dfg::AbstractDFG, label::Symbol, skey::Union{Symbol, <:AbstractString}) = getBlobEntries(dfg, label, Regex(string(skey)))
246+
245247

246248
"""
247249
$(SIGNATURES)
@@ -413,7 +415,7 @@ function incrDataLabelSuffix(
413415
catch err
414416
# append latest count
415417
if !(err isa KeyError)
416-
throw(err)
418+
throw(err)
417419
end
418420
end
419421
# the piece from old label without the suffix count number

src/DataBlobs/services/HelpersDataWrapEntryBlob.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,15 @@ function getData(
8585
vlabel::Symbol,
8686
key::Union{Symbol,UUID, <:AbstractString, Regex};
8787
hashfunction = sha256,
88-
checkhash::Bool=true
88+
checkhash::Bool=true,
89+
getlast::Bool=true
8990
)
90-
de_ = getBlobEntry(dfg, vlabel, key)
91+
de_ = getBlobEntries(dfg, vlabel, key)
92+
lbls = (s->s.label).(de_)
93+
idx = sortperm(lbls; rev=getlast)
9194
_first(s) = s
9295
_first(s::AbstractVector) = s[1]
93-
de = _first(de_)
96+
de = _first(de_[idx])
9497
db = getBlob(dfg, de)
9598

9699
checkhash && assertHash(de, db, hashfunction=hashfunction)
@@ -104,7 +107,8 @@ function getData(
104107
label::Symbol,
105108
key::Symbol;
106109
hashfunction = sha256,
107-
checkhash::Bool=true
110+
checkhash::Bool=true,
111+
getlast::Bool=true
108112
)
109113
de = getBlobEntry(dfg, label, key)
110114
db = getBlob(blobstore, de)
@@ -121,7 +125,7 @@ function addData!(
121125
hashfunction = sha256,
122126
checkhash::Bool=false
123127
)
124-
checkhash && assertHash(entry, blob, hashfunction=hashfunction)
128+
checkhash && assertHash(entry, blob; hashfunction)
125129
blobId = addBlob!(dfg, entry, blob) |> UUID
126130
newEntry = BlobEntry(entry; blobId) #, size=length(blob))
127131
addBlobEntry!(dfg, label, newEntry)

0 commit comments

Comments
 (0)