Skip to content

Commit

Permalink
Merge pull request #1032 from JuliaRobotics/23Q3/enh/getdata
Browse files Browse the repository at this point in the history
getData sorting
  • Loading branch information
dehann authored Aug 10, 2023
2 parents 3344ba0 + 3f3a7ae commit 8756d25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/DataBlobs/services/BlobEntry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ function getBlobEntries(dfg::AbstractDFG, label::Symbol, regex::Regex)
end
end

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


"""
$(SIGNATURES)
Expand Down Expand Up @@ -413,7 +415,7 @@ function incrDataLabelSuffix(
catch err
# append latest count
if !(err isa KeyError)
throw(err)
throw(err)
end
end
# the piece from old label without the suffix count number
Expand Down
14 changes: 9 additions & 5 deletions src/DataBlobs/services/HelpersDataWrapEntryBlob.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ function getData(
vlabel::Symbol,
key::Union{Symbol,UUID, <:AbstractString, Regex};
hashfunction = sha256,
checkhash::Bool=true
checkhash::Bool=true,
getlast::Bool=true
)
de_ = getBlobEntry(dfg, vlabel, key)
de_ = getBlobEntries(dfg, vlabel, key)
lbls = (s->s.label).(de_)
idx = sortperm(lbls; rev=getlast)
_first(s) = s
_first(s::AbstractVector) = s[1]
de = _first(de_)
de = _first(de_[idx])
db = getBlob(dfg, de)

checkhash && assertHash(de, db, hashfunction=hashfunction)
Expand All @@ -104,7 +107,8 @@ function getData(
label::Symbol,
key::Symbol;
hashfunction = sha256,
checkhash::Bool=true
checkhash::Bool=true,
getlast::Bool=true
)
de = getBlobEntry(dfg, label, key)
db = getBlob(blobstore, de)
Expand All @@ -121,7 +125,7 @@ function addData!(
hashfunction = sha256,
checkhash::Bool=false
)
checkhash && assertHash(entry, blob, hashfunction=hashfunction)
checkhash && assertHash(entry, blob; hashfunction)
blobId = addBlob!(dfg, entry, blob) |> UUID
newEntry = BlobEntry(entry; blobId) #, size=length(blob))
addBlobEntry!(dfg, label, newEntry)
Expand Down

0 comments on commit 8756d25

Please sign in to comment.