Skip to content

Commit 218b6ff

Browse files
committed
Updating BlobDataEntry with latest fields.
1 parent f61d5f6 commit 218b6ff

File tree

4 files changed

+52
-57
lines changed

4 files changed

+52
-57
lines changed

src/DataBlobs/entities/AbstractDataEntries.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export BlobStoreEntry
2121
General Data Store Entry.
2222
"""
2323
@Base.kwdef struct BlobStoreEntry <: AbstractDataEntry
24-
id::Union{UUID, Nothing}
24+
id::Union{UUID, Nothing}=nothing
2525
label::Symbol
2626
blobstore::Symbol
2727
hash::String # Probably https://docs.julialang.org/en/v1/stdlib/SHA
@@ -30,6 +30,8 @@ General Data Store Entry.
3030
mimeType::String
3131
metadata::String
3232
timestamp::ZonedDateTime = now(localzone())
33+
_type::String = "BlobStoreEntry"
34+
_version::String = _getDFGVersion()
3335
end
3436

3537
_fixtimezone(cts::NamedTuple) = ZonedDateTime(cts.utc_datetime*"+00")

src/DataBlobs/services/BlobStores.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function updateData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symb
105105
# Recalculate the hash - NOTE Assuming that this is going to be a BlobStoreEntry. TBD.
106106
newEntry = BlobStoreEntry(entry.id, entry.label, blobstore.key, bytes2hex(hashfunction(blob)),
107107
buildSourceString(dfg, label),
108-
entry.description, entry.mimeType, entry.metadata, entry.timestamp)
108+
entry.description, entry.mimeType, entry.metadata, entry.timestamp, entry._type, _getDFGVersion())
109109

110110
de = updateDataEntry!(dfg, label, newEntry)
111111
db = updateDataBlob!(blobstore, de, blob)
@@ -136,9 +136,16 @@ function addData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol,
136136
blob::Vector{UInt8}, timestamp=now(localzone()); description="", mimeType = "application/octet-stream", id::UUID = uuid4(), hashfunction = sha256)
137137

138138

139-
entry = BlobStoreEntry(id, key, blobstore.key, bytes2hex(hashfunction(blob)),
140-
buildSourceString(dfg, label),
141-
description, mimeType, "", timestamp)
139+
entry = BlobStoreEntry(
140+
id = id,
141+
label = key,
142+
blobstore = blobstore.key,
143+
hash = bytes2hex(hashfunction(blob)),
144+
origin = buildSourceString(dfg, label),
145+
description = description,
146+
mimeType = mimeType,
147+
metadata = "",
148+
timestamp = timestamp)
142149

143150
addData!(dfg, blobstore, label, entry, blob; hashfunction)
144151
end

src/entities/DFGVariable.jl

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,6 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P}
4444
solveKey::Symbol
4545

4646
events::Dict{Symbol,Threads.Condition} = Dict{Symbol,Threads.Condition}()
47-
48-
# VariableNodeData{T,P}(w...) where {T <:InferenceVariable, P} = new{T,P}(w...)
49-
# VariableNodeData{T,P}(;solveKey::Symbol=:default ) where {T <:InferenceVariable, P} = new{T,P}(
50-
# nothing,
51-
# Vector{P}(),
52-
# zeros(0,0),
53-
# Symbol[],
54-
# Int[],
55-
# 0,
56-
# false,
57-
# :NOTHING,
58-
# Symbol[],
59-
# T(),
60-
# false,
61-
# Float64[0.0;],
62-
# false,
63-
# false,
64-
# 0,
65-
# 0,
66-
# solveKey,
67-
# Dict{Symbol,Threads.Condition}() )
6847
#
6948
end
7049

@@ -75,32 +54,6 @@ end
7554
VariableNodeData{T,P}(;solveKey::Symbol=:default) where {T <: InferenceVariable, P} = VariableNodeData(; val=Vector{P}(), variableType=T(), solveKey)
7655
VariableNodeData{T}(;solveKey::Symbol=:default ) where T <: InferenceVariable = VariableNodeData(; solveKey, variableType=T(), val=Vector{getPointType(T)}()) # {T, getPointType(T)}
7756

78-
# VariableNodeData( val::Vector{P},
79-
# bw::AbstractMatrix{<:Real},
80-
# BayesNetOutVertIDs::AbstractVector{Symbol},
81-
# dimIDs::AbstractVector{Int},
82-
# dims::Int,
83-
# eliminated::Bool,
84-
# BayesNetVertID::Symbol,
85-
# separator::AbstractVector{Symbol},
86-
# variableType::T,
87-
# initialized::Bool,
88-
# ipc::AbstractVector{<:Real},
89-
# ismargin::Bool,
90-
# dontmargin::Bool,
91-
# solveInProgress::Int=0,
92-
# solvedCount::Int=0,
93-
# solveKey::Symbol=:default,
94-
# events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}();
95-
# id::Union{UUID, Nothing}=nothing
96-
# ) where {T <: InferenceVariable, P} =
97-
# VariableNodeData{T,P}( id, val,bw,BayesNetOutVertIDs,dimIDs,dims,
98-
# eliminated,BayesNetVertID,separator,
99-
# variableType,initialized,ipc,ismargin,
100-
# dontmargin, solveInProgress, solvedCount,
101-
# solveKey, events )
102-
#
103-
10457
function VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <: InferenceVariable
10558
#
10659
# p0 = getPointIdentity(T)

test/testBlocks.jl

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,15 @@ function DataEntriesTestBlock!(fg, v2)
850850
# listDataEntries
851851
# emptyDataEntries
852852
# mergeDataEntries
853-
storeEntry = BlobStoreEntry(uuid4(), :a, :b, "","","","", "", now(localzone()))
853+
storeEntry = BlobStoreEntry(
854+
id = uuid4(),
855+
label = :a,
856+
blobstore = :b,
857+
hash = "",
858+
origin = "",
859+
description = "",
860+
mimeType = "",
861+
metadata = "")
854862
@test getLabel(storeEntry) == storeEntry.label
855863
@test getId(storeEntry) == storeEntry.id
856864
@test getHash(storeEntry) == hex2bytes(storeEntry.hash)
@@ -902,10 +910,35 @@ function DataEntriesTestBlock!(fg, v2)
902910
end
903911

904912
function blobsStoresTestBlock!(fg)
905-
906-
de1 = BlobStoreEntry(uuid4(),:label1, :store1, "AAAA","origin1","description1","mimetype1","", now(localzone()))
907-
de2 = BlobStoreEntry(uuid4(),:label2, :store2, "FFFF","origin2","description2","mimetype2","", ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
908-
de2_update = BlobStoreEntry(uuid4(),:label2, :store2, "0123","origin2","description2","mimetype2","", ZonedDateTime("2020-08-12T12:00:01.000+00:00"))
913+
de1 = BlobStoreEntry(
914+
id = uuid4(),
915+
label = :label1,
916+
blobstore = :store1,
917+
hash = "AAAA",
918+
origin = "origin1",
919+
description = "description1",
920+
mimeType = "mimetype1",
921+
metadata = "")
922+
de2 = BlobStoreEntry(
923+
id = uuid4(),
924+
label = :label2,
925+
blobstore = :store2,
926+
hash = "FFFF",
927+
origin = "origin2",
928+
description = "description2",
929+
mimeType = "mimetype2",
930+
metadata = "",
931+
timestamp = ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
932+
de2_update = BlobStoreEntry(
933+
id = uuid4(),
934+
label = :label2,
935+
blobstore = :store2,
936+
hash = "0123",
937+
origin = "origin2",
938+
description = "description2",
939+
mimeType = "mimetype2",
940+
metadata = "",
941+
timestamp = ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
909942
@test getLabel(de1) == de1.label
910943
@test getId(de1) == de1.id
911944
@test getHash(de1) == hex2bytes(de1.hash)

0 commit comments

Comments
 (0)