Skip to content

Commit 14a5258

Browse files
authored
Merge pull request #912 from JuliaRobotics/master
v0.18.8-rc1
2 parents 8568cff + 84fdfda commit 14a5258

File tree

11 files changed

+76
-30
lines changed

11 files changed

+76
-30
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.7"
3+
version = "0.18.8"
44

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

src/DataBlobs/services/AbstractDataEntries.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,7 @@ function mergeDataEntries!(
214214
dde = listDataEntries(dst, dlbl)
215215
uids = (s->s.id).(dde)
216216
filter!(s -> !(s.id in uids), des)
217-
union(((s->mergeDataEntries!(dst, dlbl, src, slbl, s.id)).(des))...)
217+
if 0 < length(des)
218+
union(((s->mergeDataEntries!(dst, dlbl, src, slbl, s.id)).(des))...)
219+
end
218220
end

src/DataBlobs/services/BlobStores.jl

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,26 @@
22
## AbstractBlobStore CRUD Interface
33
##==============================================================================
44

5-
getDataBlob(dfg::AbstractDFG, entry::BlobStoreEntry) =
6-
getDataBlob(getBlobStore(dfg, entry.blobstore), entry)
5+
function getDataBlob(dfg::AbstractDFG, entry::BlobStoreEntry)
6+
# cannot use entry.blobstore because the blob can be in any one of the blobstores
7+
stores = getBlobStores(dfg)
8+
blob = UInt8[]
9+
for (k,store) in stores
10+
try
11+
blob = getDataBlob(store, entry)
12+
return blob
13+
catch err
14+
if !(err isa KeyError)
15+
throw(err)
16+
end
17+
end
18+
end
19+
throw(
20+
KeyError(
21+
"could not find $(entry.label), uuid $(entry.id)) in any of the listed blobstores:\n $((s->getKey(s)).(stores))"
22+
)
23+
)
24+
end
725

826
function getDataBlob(store::AbstractBlobStore, entry::BlobStoreEntry)
927
error("$(typeof(store)) doesn't override 'getDataBlob'.")
@@ -68,16 +86,17 @@ function getData(
6886
blobstore::AbstractBlobStore,
6987
label::Symbol,
7088
key::Union{Symbol,UUID};
71-
hashfunction = sha256
89+
hashfunction = sha256,
90+
checkhash::Bool=true
7291
)
7392
de = getDataEntry(dfg, label, key)
7493
db = getDataBlob(blobstore, de)
75-
assertHash(de, db, hashfunction=hashfunction)
94+
checkhash && assertHash(de, db; hashfunction)
7695
return de=>db
7796
end
7897

7998
function addData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::AbstractDataEntry, blob::Vector{UInt8}; hashfunction = sha256)
80-
assertHash(entry, blob, hashfunction=hashfunction)
99+
assertHash(entry, blob; hashfunction)
81100
de = addDataEntry!(dfg, label, entry)
82101
db = addDataBlob!(blobstore, de, blob)
83102
return de=>db
@@ -122,7 +141,7 @@ function addData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol,
122141
"$(dfg.userId)|$(dfg.robotId)|$(dfg.sessionId)|$(label)",
123142
description, mimeType, timestamp)
124143

125-
addData!(dfg, blobstore, label, entry, blob; hashfunction = hashfunction)
144+
addData!(dfg, blobstore, label, entry, blob; hashfunction)
126145
end
127146

128147

@@ -157,7 +176,7 @@ function getDataBlob(store::FolderStore{T}, entry::BlobStoreEntry) where T
157176
return read(f)
158177
end
159178
else
160-
error("Could not find file '$(blobfilename)'.")
179+
throw(KeyError("Could not find file '$(blobfilename)'."))
161180
# return nothing
162181
end
163182
end

src/DataBlobs/services/DataEntryBlob.jl

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,30 +115,52 @@ function getData(
115115
dfg::AbstractDFG,
116116
vlabel::Symbol,
117117
key::Union{Symbol,UUID};
118-
hashfunction = sha256
118+
hashfunction = sha256,
119+
checkhash::Bool=true
119120
)
120-
de = getDataEntry(dfg, vlabel, key)
121+
de_ = getDataEntry(dfg, vlabel, key)
122+
_first(s) = s
123+
_first(s::AbstractVector) = s[1]
124+
de = _first(de_)
121125
db = getDataBlob(dfg, de)
122126

123-
assertHash(de, db, hashfunction=hashfunction)
127+
checkhash && assertHash(de, db, hashfunction=hashfunction)
124128
return de=>db
125129
end
126130

127-
function addData!(dfg::AbstractDFG, label::Symbol, entry::AbstractDataEntry, blob::Vector{UInt8}; hashfunction = sha256)
128-
assertHash(entry, blob, hashfunction=hashfunction)
131+
function addData!(
132+
dfg::AbstractDFG,
133+
label::Symbol,
134+
entry::AbstractDataEntry,
135+
blob::Vector{UInt8};
136+
hashfunction = sha256,
137+
checkhash::Bool=true
138+
)
139+
checkhash && assertHash(entry, blob, hashfunction=hashfunction)
129140
de = addDataEntry!(dfg, label, entry)
130141
db = addDataBlob!(dfg, de, blob)
131142
return de=>db
132143
end
133144

134-
function updateData!(dfg::AbstractDFG, label::Symbol, entry::AbstractDataEntry, blob::Vector{UInt8}; hashfunction = sha256)
135-
assertHash(entry, blob, hashfunction=hashfunction)
145+
function updateData!(
146+
dfg::AbstractDFG,
147+
label::Symbol,
148+
entry::AbstractDataEntry,
149+
blob::Vector{UInt8};
150+
hashfunction = sha256,
151+
checkhash::Bool=true
152+
)
153+
checkhash && assertHash(entry, blob, hashfunction=hashfunction)
136154
de = updateDataEntry!(dfg, label, entry)
137155
db = updateDataBlob!(dfg, de, blob)
138156
return de=>db
139157
end
140158

141-
function deleteData!(dfg::AbstractDFG, label::Symbol, key::Symbol)
159+
function deleteData!(
160+
dfg::AbstractDFG,
161+
label::Symbol,
162+
key::Symbol
163+
)
142164
de = deleteDataEntry!(dfg, label, key)
143165
db = deleteDataBlob!(dfg, de)
144166
return de=>db

src/DataBlobs/services/FileDataEntryBlob.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function getDataBlob(dfg::AbstractDFG, entry::FileDataEntry)
2525
return read(f)
2626
end
2727
else
28-
error("Could not find file '$(blobfilename(entry))'.")
28+
throw(KeyError("Could not find file '$(blobfilename(entry))'."))
2929
# return nothing
3030
end
3131
end

src/GraphsDFG/entities/GraphsDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mutable struct GraphsDFG{T <: AbstractParams, V <: AbstractDFGVariable, F <:Abst
1818
sessionData::Dict{Symbol, String}
1919
addHistory::Vector{Symbol} #TODO: Discuss more - is this an audit trail?
2020
solverParams::T # Solver parameters
21-
blobStores::Dict{Symbol, AbstractBlobStore}
21+
blobStores::Dict{Symbol, <:AbstractBlobStore}
2222
end
2323

2424
"""
@@ -63,7 +63,7 @@ end
6363

6464
function GraphsDFG(g::FactorGraph{Int,DFGVariable,DFGFactor}=FactorGraph{Int,DFGVariable,DFGFactor}();
6565
solverParams::T=NoSolverParams(), kwargs...) where T
66-
return GraphsDFG{T,DFGVariable,DFGFactor}(g; solverParams=solverParams, kwargs...)
66+
return GraphsDFG{T,DFGVariable,DFGFactor}(g; solverParams, kwargs...)
6767
end
6868

6969

src/Neo4jDFG/services/CommonFunctions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function _matchmergeVariableSubnode!(
300300
relationshipKey::Symbol;
301301
addProps::Dict{String, String}=Dict{String, String}(),
302302
currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing) where
303-
{N <: DFGNode, APPE <: AbstractPointParametricEst, ABDE <: AbstractDataEntry, PVND <: PackedVariableNodeData}
303+
{APPE <: AbstractPointParametricEst, ABDE <: AbstractDataEntry, PVND <: PackedVariableNodeData}
304304

305305
# Defensively wrap the node labels.
306306
nodeLabels = [!startswith(n, "`") && !endswith(n, "`") ? "`$(n)`" : n for n in nodeLabels]

src/services/AbstractDFG.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ abstract type AbstractBlobStore{T} end
191191
# AbstractBlobStore should have key or overwrite getKey
192192
getKey(store::AbstractBlobStore) = store.key
193193

194+
getBlobStores(dfg::AbstractDFG) = dfg.blobStores
194195
getBlobStore(dfg::AbstractDFG, key::Symbol) = dfg.blobStores[key]
195196
addBlobStore!(dfg::AbstractDFG, bs::AbstractBlobStore) = push!(dfg.blobStores, getKey(bs)=>bs)
196197
updateBlobStore!(dfg::AbstractDFG, bs::AbstractBlobStore) = push!(dfg.blobStores, getKey(bs)=>bs)

src/services/DFGVariable.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ Retrieve solver data structure stored in a variable.
417417
"""
418418
function getSolverData(v::DFGVariable, key::Symbol=:default)
419419
#TODO this does not fit in with some of the other error behaviour. but its used so added @error
420-
vnd = haskey(v.solverDataDict, key) ? v.solverDataDict[key] : (@error "Variable does not have solver data $(key)"; nothing)
420+
vnd = haskey(v.solverDataDict, key) ? v.solverDataDict[key] : (@error "Variable $(getLabel(v)) does not have solver data $(key)"; nothing)
421421
return vnd
422422
end
423423

src/services/Serialization.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,18 @@ function _unpackVariableNodeData(
193193
end
194194

195195
# returns a DFGVariable
196-
function unpackVariable(dfg::AbstractDFG,
197-
packedProps::Dict{String, Any};
198-
unpackPPEs::Bool=true,
199-
unpackSolverData::Bool=true,
200-
unpackBigData::Bool = haskey(packedProps,"dataEntryType") && haskey(packedProps, "dataEntry")
201-
)
196+
function unpackVariable(
197+
dfg::AbstractDFG,
198+
packedProps::Dict{String, Any};
199+
unpackPPEs::Bool=true,
200+
unpackSolverData::Bool=true,
201+
unpackBigData::Bool = haskey(packedProps,"dataEntryType") && haskey(packedProps, "dataEntry"),
202+
skipVersionCheck::Bool=false,
203+
)
202204
#
203205
@debug "Unpacking variable:\r\n$packedProps"
204206
# Version checking.
205-
_versionCheck(packedProps)
207+
!skipVersionCheck && _versionCheck(packedProps)
206208
label = Symbol(packedProps["label"])
207209
# Make sure that the timestamp is correctly formatted with subseconds
208210
packedProps["timestamp"] = getStandardZDTString(packedProps["timestamp"])

0 commit comments

Comments
 (0)