Skip to content

Commit 0e925cd

Browse files
committed
blobs via uuids or labels
1 parent f690f1a commit 0e925cd

File tree

5 files changed

+27
-29
lines changed

5 files changed

+27
-29
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.18.5"
3+
version = "0.18.6"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/DataBlobs/services/AbstractDataEntries.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@ buildSourceString(dfg::AbstractDFG, label::Symbol) =
2929
Get data entry
3030
"""
3131
function getDataEntry(var::AbstractDFGVariable, key::Symbol)
32-
!hasDataEntry(var, key) && error("Data entry $(key) does not exist in variable $(getLabel(var))")
32+
!hasDataEntry(var, key) && error("No dataEntry label $(key) found in variable $(getLabel(var))")
3333
return var.dataDict[key]
3434
end
3535

36-
function getDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol)
37-
return getDataEntry(getVariable(dfg, label), key)
36+
function getDataEntry(var::AbstractDFGVariable, blobId::UUID)
37+
for (k,v) in var.dataDict
38+
if v.id == blobId
39+
return v
40+
end
41+
end
42+
error("No dataEntry with blobId $(blobId) found in variable $(getLabel(var))")
3843
end
3944

45+
getDataEntry(dfg::AbstractDFG, label::Symbol, key::Union{Symbol,UUID}) = getDataEntry(getVariable(dfg, label), key)
46+
47+
4048
"""
4149
$(SIGNATURES)
4250
Add Data Entry to a DFG variable

src/DataBlobs/services/BlobStores.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ end
6363
## Store and Entry Data CRUD
6464
##==============================================================================
6565

66-
function getData(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, key::Symbol; hashfunction = sha256)
66+
function getData(
67+
dfg::AbstractDFG,
68+
blobstore::AbstractBlobStore,
69+
label::Symbol,
70+
key::Union{Symbol,UUID};
71+
hashfunction = sha256
72+
)
6773
de = getDataEntry(dfg, label, key)
6874
db = getDataBlob(blobstore, de)
6975
assertHash(de, db, hashfunction=hashfunction)

src/DataBlobs/services/DataEntryBlob.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,13 @@ end
111111
## DFG Data CRUD
112112
##==============================================================================
113113

114-
function getData(dfg::AbstractDFG, label::Symbol, key::Symbol; hashfunction = sha256)
115-
de = getDataEntry(dfg, label, key)
114+
function getData(
115+
dfg::AbstractDFG,
116+
vlabel::Symbol,
117+
key::Union{Symbol,UUID};
118+
hashfunction = sha256
119+
)
120+
de = getDataEntry(dfg, vlabel, key)
116121
db = getDataBlob(dfg, de)
117122

118123
assertHash(de, db, hashfunction=hashfunction)

src/services/Serialization.jl

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -458,25 +458,6 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any}) where G <: Abstrac
458458
@assert !(packedProps["_variableOrderSymbols"] isa String) "unpackFactor expecting JSON only data, packed `_variableOrderSymbols` should be a vector of strings (not a single string of elements)."
459459
tags = _vecSymbol(packedProps["tags"])
460460
_variableOrderSymbols = _vecSymbol(packedProps["_variableOrderSymbols"])
461-
# if packedProps["tags"] isa String
462-
# # TODO, legacy and should be removed
463-
# tags = JSON2.read(packedProps["tags"], Vector{Symbol})
464-
# else
465-
# # the preferred (and should be only) solution
466-
# tags = Symbol.(packedProps["tags"])
467-
# # If tags is empty we need to make sure it's a Vector{Symbol}
468-
# if length(tags) == 0
469-
# tags = Vector{Symbol}()
470-
# end
471-
# end
472-
# # Get the stored variable order
473-
# _variableOrderSymbols = if packedProps["_variableOrderSymbols"] isa String
474-
# # TODO, legacy and should be removed
475-
# JSON2.read(packedProps["_variableOrderSymbols"], Vector{Symbol})
476-
# else
477-
# # the preferred (and should be only) solution
478-
# Symbol.(packedProps["_variableOrderSymbols"])
479-
# end
480461

481462
data = packedProps["data"]
482463
datatype = packedProps["fnctype"]
@@ -487,10 +468,8 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any}) where G <: Abstrac
487468
packed = nothing
488469
fullFactorData = nothing
489470

490-
# @show packtype
491-
# @show data
492471
try
493-
packed = convert(GenericFunctionNodeData{packtype}, data) # JSON2.read(data, GenericFunctionNodeData{packtype})
472+
packed = convert(GenericFunctionNodeData{packtype}, data)
494473
decodeType = getFactorOperationalMemoryType(dfg)
495474
fullFactorData = decodePackedType(dfg, _variableOrderSymbols, decodeType, packed)
496475
catch ex

0 commit comments

Comments
 (0)