Skip to content

Commit b193629

Browse files
authored
Merge pull request #923 from JuliaRobotics/22Q4/enh/close922
more dispatches getData Entry, close #922
2 parents 12d7292 + a82b296 commit b193629

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

src/DataBlobs/services/AbstractDataEntries.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,25 @@ function getDataEntry(var::AbstractDFGVariable, blobId::UUID)
4141
return v
4242
end
4343
end
44-
error("No dataEntry with blobId $(blobId) found in variable $(getLabel(var))")
44+
throw(
45+
KeyError("No dataEntry with blobId $(blobId) found in variable $(getLabel(var))")
46+
)
4547
end
48+
function getDataEntry(var::AbstractDFGVariable, key::Regex)
49+
for (k,v) in var.dataDict
50+
if occursin(key, string(v.label))
51+
return v
52+
end
53+
end
54+
throw(
55+
KeyError("No dataEntry with label matching regex $(key) found in variable $(getLabel(var))")
56+
)
57+
end
58+
getDataEntry(var::AbstractDFGVariable, key::AbstractString) = getDataEntry(var,Regex(key))
59+
4660

47-
getDataEntry(dfg::AbstractDFG, label::Symbol, key::UUID) = getDataEntry(getVariable(dfg, label), key)
48-
getDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol) = getDataEntry(getVariable(dfg, label), key)
61+
getDataEntry(dfg::AbstractDFG, label::Symbol, key::Union{Symbol, UUID, <:AbstractString, Regex}) = getDataEntry(getVariable(dfg, label), key)
62+
# getDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol) = getDataEntry(getVariable(dfg, label), key)
4963

5064

5165
"""

src/DataBlobs/services/BlobStores.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function getDataBlob(dfg::AbstractDFG, entry::BlobStoreEntry)
1717
end
1818
throw(
1919
KeyError(
20-
"could not find $(entry.label), uuid $(entry.id)) in any of the listed blobstores:\n $((s->getKey(s)).(stores))"
20+
"could not find $(entry.label), uuid $(entry.id)) in any of the listed blobstores:\n $([s->getKey(s) for (s,v) in stores]))"
2121
)
2222
)
2323
end
@@ -84,7 +84,7 @@ function getData(
8484
dfg::AbstractDFG,
8585
blobstore::AbstractBlobStore,
8686
label::Symbol,
87-
key::Union{Symbol,UUID};
87+
key::Union{Symbol,UUID, <:AbstractString, Regex};
8888
hashfunction = sha256,
8989
checkhash::Bool=true
9090
)

src/DataBlobs/services/DataEntryBlob.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ end
114114
function getData(
115115
dfg::AbstractDFG,
116116
vlabel::Symbol,
117-
key::Union{Symbol,UUID};
117+
key::Union{Symbol,UUID, <:AbstractString, Regex};
118118
hashfunction = sha256,
119119
checkhash::Bool=true
120120
)

test/consol_DataEntryBlobTests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ addBlobStore!(dfg, ds)
9393

9494
ade,adb = addData!(dfg, :filestore, :x1, :random, dataset1)
9595
_,_ = addData!(dfg, :filestore, :x1, :another_1, dataset1)
96+
_,_ = getData(dfg, :x1, "random")
97+
_,_ = getData(dfg, :x1, r"rando")
9698
gde,gdb = getData(dfg, :x1, :random)
9799

98100
@test incrDataLabelSuffix(dfg,:x1,:random) == :random_1

0 commit comments

Comments
 (0)