Skip to content

Commit 5c568d9

Browse files
committed
drop AbstractBlobEntry, close #955
1 parent 79969a2 commit 5c568d9

File tree

9 files changed

+67
-57
lines changed

9 files changed

+67
-57
lines changed
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
##==============================================================================
2-
## AbstractBlobEntry - Defined in src/entities/AbstractDFG.jl
3-
##==============================================================================
4-
# Fields to be implemented
5-
# label
6-
# id
7-
8-
getLabel(entry::AbstractBlobEntry) = entry.label
9-
getId(entry::AbstractBlobEntry) = entry.id
10-
getHash(entry::AbstractBlobEntry) = hex2bytes(entry.hash)
11-
getTimestamp(entry::AbstractBlobEntry) = entry.timestamp
12-
131

142
##==============================================================================
153
## BlobStoreEntry
@@ -19,7 +7,7 @@ getTimestamp(entry::AbstractBlobEntry) = entry.timestamp
197
$(TYPEDEF)
208
General Data Store Entry.
219
"""
22-
@Base.kwdef struct BlobEntry <: AbstractBlobEntry
10+
@Base.kwdef struct BlobEntry
2311
""" This is created by server-side GraphQL """
2412
id::Union{UUID, Nothing}=nothing
2513
""" This is the forced server generated blobId, or the filesystem blobId. """
@@ -38,8 +26,5 @@ General Data Store Entry.
3826
_version::String = string(_getDFGVersion()) # TBD consider upgrading to ::VersionNumber
3927
end
4028

41-
# should be deprecated by v0.21
42-
export BlobStoreEntry
43-
const BlobStoreEntry = BlobEntry
4429

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

src/DataBlobs/services/AbstractBlobEntries.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
##==============================================================================
2-
## AbstractBlobEntry - compare
2+
## BlobEntry - compare
33
##==============================================================================
44

55
import Base: ==
66

7-
@generated function ==(x::T, y::T) where T <: AbstractBlobEntry
7+
@generated function ==(x::T, y::T) where T <: BlobEntry
88
mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
99
end
1010

1111
##==============================================================================
12-
## AbstractBlobEntry - common
12+
## BlobEntry - common
1313
##==============================================================================
1414

1515
"""
@@ -21,7 +21,7 @@ buildSourceString(dfg::AbstractDFG, label::Symbol) =
2121

2222

2323
##==============================================================================
24-
## AbstractBlobEntry - CRUD
24+
## BlobEntry - CRUD
2525
##==============================================================================
2626

2727
"""
@@ -69,13 +69,13 @@ Should be extended if DFG variable is not returned by reference.
6969
7070
Also see: [`getBlobEntry`](@ref), [`addDataBlob`](@ref), [`mergeBlobEntries!`](@ref)
7171
"""
72-
function addBlobEntry!(var::AbstractDFGVariable, bde::AbstractBlobEntry)
72+
function addBlobEntry!(var::AbstractDFGVariable, bde::BlobEntry)
7373
haskey(var.dataDict, bde.label) && error("Data entry $(bde.label) already exists in variable $(getLabel(var))")
7474
var.dataDict[bde.label] = bde
7575
return bde
7676
end
7777

78-
function addBlobEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBlobEntry)
78+
function addBlobEntry!(dfg::AbstractDFG, label::Symbol, bde::BlobEntry)
7979
return addBlobEntry!(getVariable(dfg, label), bde)
8080
end
8181

@@ -87,12 +87,12 @@ Update data entry
8787
DevNote
8888
- DF, unclear if `update` verb is applicable in this case, see #404
8989
"""
90-
function updateBlobEntry!(var::AbstractDFGVariable, bde::AbstractBlobEntry)
90+
function updateBlobEntry!(var::AbstractDFGVariable, bde::BlobEntry)
9191
!haskey(var.dataDict, bde.label) && (@warn "$(bde.label) does not exist in variable $(getLabel(var)), adding")
9292
var.dataDict[bde.label] = bde
9393
return bde
9494
end
95-
function updateBlobEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBlobEntry)
95+
function updateBlobEntry!(dfg::AbstractDFG, label::Symbol, bde::BlobEntry)
9696
# !isVariable(dfg, label) && return nothing
9797
return updateBlobEntry!(getVariable(dfg, label), bde)
9898
end
@@ -114,13 +114,13 @@ function deleteBlobEntry!(dfg::AbstractDFG, label::Symbol, key::Symbol)
114114
return deleteBlobEntry!(getVariable(dfg, label), key)
115115
end
116116

117-
function deleteBlobEntry!(var::AbstractDFGVariable, entry::AbstractBlobEntry)
117+
function deleteBlobEntry!(var::AbstractDFGVariable, entry::BlobEntry)
118118
#users responsibility to delete data in db before deleting entry
119119
return deleteBlobEntry!(var, entry.label)
120120
end
121121

122122
##==============================================================================
123-
## AbstractBlobEntry - Helper functions, Lists, etc
123+
## BlobEntry - Helper functions, Lists, etc
124124
##==============================================================================
125125

126126
"""
@@ -133,15 +133,15 @@ hasBlobEntry(var::AbstractDFGVariable, key::Symbol) = haskey(var.dataDict, key)
133133

134134
"""
135135
$(SIGNATURES)
136-
Get data entries, Vector{AbstractBlobEntry}
136+
Get data entries, Vector{BlobEntry}
137137
"""
138138
function getBlobEntries(var::AbstractDFGVariable)
139-
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBlobEntry}}?
139+
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,BlobEntry}}?
140140
collect(values(var.dataDict))
141141
end
142142
function getBlobEntries(dfg::AbstractDFG, label::Symbol)
143143
# !isVariable(dfg, label) && return nothing
144-
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBlobEntry}}?
144+
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,BlobEntry}}?
145145
getBlobEntries(getVariable(dfg, label))
146146
end
147147

@@ -212,7 +212,7 @@ function mergeBlobEntries!(
212212
dde = listBlobEntries(dst, dlbl)
213213
# HACK, verb list should just return vector of Symbol. NCE36
214214
_getid(s) = s
215-
_getid(s::AbstractBlobEntry) = s.id
215+
_getid(s::BlobEntry) = s.id
216216
uids = _getid.(dde) # (s->s.id).(dde)
217217
filter!(s -> !(_getid(s) in uids), des)
218218
# add any data entries not already in the destination variable, by uuid
@@ -231,7 +231,7 @@ function mergeBlobEntries!(
231231
dde = listBlobEntries(dst, dlbl)
232232
# HACK, verb list should just return vector of Symbol. NCE36
233233
_getid(s) = s
234-
_getid(s::AbstractBlobEntry) = s.id
234+
_getid(s::BlobEntry) = s.id
235235
uids = _getid.(dde) # (s->s.id).(dde)
236236
filter!(s -> !(_getid(s) in uids), des)
237237
if 0 < length(des)

src/DataBlobs/services/BlobEntry.jl

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11

2+
##==============================================================================
3+
## BlobEntry - Defined in src/entities/AbstractDFG.jl
4+
##==============================================================================
5+
# Fields to be implemented
6+
# label
7+
# id
8+
9+
getLabel(entry::BlobEntry) = entry.label
10+
getId(entry::BlobEntry) = entry.id
11+
getHash(entry::BlobEntry) = hex2bytes(entry.hash)
12+
getTimestamp(entry::BlobEntry) = entry.timestamp
13+
14+
15+
216
function assertHash(
3-
de::AbstractBlobEntry,
17+
de::BlobEntry,
418
db::AbstractVector{UInt8};
519
hashfunction::Function = sha256
620
)
@@ -12,6 +26,7 @@ function assertHash(
1226
end
1327
end
1428

29+
1530
##==============================================================================
1631
## DFG BlobBlob CRUD
1732
##==============================================================================
@@ -90,24 +105,25 @@ $(METHODLIST)
90105
function deleteBlob! end
91106

92107
#
93-
# addBlob!(dfg::AbstractDFG, entry::AbstractBlobEntry, blob)
94-
# updateBlob!(dfg::AbstractDFG, entry::AbstractBlobEntry, blob)
95-
# deleteBlob!(dfg::AbstractDFG, entry::AbstractBlobEntry)
108+
# addBlob!(dfg::AbstractDFG, entry::BlobEntry, blob)
109+
# updateBlob!(dfg::AbstractDFG, entry::BlobEntry, blob)
110+
# deleteBlob!(dfg::AbstractDFG, entry::BlobEntry)
111+
96112

97113

98-
function getBlob(dfg::AbstractDFG, entry::AbstractBlobEntry)
114+
function getBlob(dfg::AbstractDFG, entry::BlobEntry)
99115
error("$(typeof(dfg)) doesn't override 'getBlob', with $(typeof(entry)).")
100116
end
101117

102-
function addBlob!(dfg::AbstractDFG, entry::AbstractBlobEntry, data::T) where T
118+
function addBlob!(dfg::AbstractDFG, entry::BlobEntry, data::T) where T
103119
error("$(typeof(dfg)) doesn't override 'addBlob!'.")
104120
end
105121

106-
function updateBlob!(dfg::AbstractDFG, entry::AbstractBlobEntry, data::T) where T
122+
function updateBlob!(dfg::AbstractDFG, entry::BlobEntry, data::T) where T
107123
error("$(typeof(dfg)) doesn't override 'updateBlob!'.")
108124
end
109125

110-
function deleteBlob!(dfg::AbstractDFG, entry::AbstractBlobEntry)
126+
function deleteBlob!(dfg::AbstractDFG, entry::BlobEntry)
111127
error("$(typeof(dfg)) doesn't override 'deleteBlob!'.")
112128
end
113129

@@ -147,7 +163,7 @@ end
147163
function addBlob!(
148164
dfg::AbstractDFG,
149165
label::Symbol,
150-
entry::AbstractBlobEntry,
166+
entry::BlobEntry,
151167
blob::Vector{UInt8};
152168
hashfunction = sha256,
153169
checkhash::Bool=true
@@ -176,7 +192,7 @@ end
176192
function updateBlob!(
177193
dfg::AbstractDFG,
178194
label::Symbol,
179-
entry::AbstractBlobEntry,
195+
entry::BlobEntry,
180196
blob::Vector{UInt8};
181197
hashfunction = sha256,
182198
checkhash::Bool=true

src/DataBlobs/services/BlobStores.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ end
6363
# Can specify which entries to copy with the `sourceEntries` parameter.
6464
# Returns the list of copied entries.
6565
# """
66-
# function copyBlobStore(sourceStore::D1, destStore::D2; sourceEntries=listEntries(sourceStore))::Vector{E} where {T, D1 <: AbstractDataStore{T}, D2 <: AbstractDataStore{T}, E <: AbstractBlobEntry}
66+
# function copyBlobStore(sourceStore::D1, destStore::D2; sourceEntries=listEntries(sourceStore))::Vector{E} where {T, D1 <: AbstractDataStore{T}, D2 <: AbstractDataStore{T}, E <: BlobEntry}
6767
# # Quick check
6868
# destEntries = listBlobs(destStore)
6969
# typeof(sourceEntries) != typeof(destEntries) && error("Can't copy stores, source has entries of type $(typeof(sourceEntries)), destination has entries of type $(typeof(destEntries)).")
@@ -94,14 +94,14 @@ function getBlob(
9494
return de=>db
9595
end
9696

97-
function addBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::AbstractBlobEntry, blob::Vector{UInt8}; hashfunction = sha256)
97+
function addBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::BlobEntry, blob::Vector{UInt8}; hashfunction = sha256)
9898
assertHash(entry, blob; hashfunction)
9999
de = addBlobEntry!(dfg, label, entry)
100100
db = addBlob!(blobstore, de, blob)
101101
return de=>db
102102
end
103103

104-
function updateBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::AbstractBlobEntry, blob::Vector{UInt8}; hashfunction = sha256)
104+
function updateBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::BlobEntry, blob::Vector{UInt8}; hashfunction = sha256)
105105
# Recalculate the hash - NOTE Assuming that this is going to be a BlobEntry. TBD.
106106
newEntry = BlobEntry(entry.id, entry.blobId, entry.originId, entry.label, blobstore.key, bytes2hex(hashfunction(blob)),
107107
buildSourceString(dfg, label),
@@ -112,7 +112,7 @@ function updateBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symb
112112
return de=>db
113113
end
114114

115-
deleteBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::AbstractBlobEntry) =
115+
deleteBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::BlobEntry) =
116116
deleteBlob!(dfg, blobstore, label, entry.label)
117117

118118
function deleteBlob!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, key::Symbol)

src/Deprecated.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
## Remove in v0.21
44
##=================================================================================
55

6+
7+
"""
8+
$(TYPEDEF)
9+
Abstract parent struct for big data entry.
10+
"""
11+
abstract type AbstractBlobEntry end
12+
13+
# should be deprecated by v0.21
14+
export BlobStoreEntry
15+
const BlobStoreEntry = BlobEntry
16+
617
@deprecate hasDataEntry(w...;kw...) hasBlobEntry(w...;kw...)
718
@deprecate getBlobEntry(w...;kw...) getBlobEntry(w...;kw...)
819
@deprecate addDataEntry!(w...;kw...) addBlobEntry!(w...;kw...)

src/entities/AbstractDFG.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ Empty structure for solver parameters.
4040
struct NoSolverParams <: AbstractParams
4141
end
4242

43-
"""
44-
$(TYPEDEF)
45-
Abstract parent struct for big data entry.
46-
"""
47-
abstract type AbstractBlobEntry end
48-
4943
"""
5044
Types valid for small data.
5145
"""

src/entities/DFGVariable.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Base.@kwdef struct DFGVariable{T<:InferenceVariable} <: AbstractDFGVariable
234234
smallData::Dict{Symbol, SmallDataTypes}
235235
"""Dictionary of large data associated with this variable.
236236
Accessors: [`addDataEntry!`](@ref), [`getBlobEntry`](@ref), [`updateDataEntry!`](@ref), and [`deleteDataEntry!`](@ref)"""
237-
dataDict::Dict{Symbol, AbstractBlobEntry}
237+
dataDict::Dict{Symbol, BlobEntry}
238238
"""Solvable flag for the variable.
239239
Accessors: [`getSolvable`](@ref), [`setSolvable!`](@ref)"""
240240
solvable::Base.RefValue{Int}
@@ -255,7 +255,7 @@ function DFGVariable(label::Symbol, variableType::Type{T};
255255
estimateDict::Dict{Symbol, <: AbstractPointParametricEst}=Dict{Symbol, MeanMaxPPE}(),
256256
solverDataDict::Dict{Symbol, VariableNodeData{T,P}}=Dict{Symbol, VariableNodeData{T,getPointType(T)}}(),
257257
smallData::Dict{Symbol, SmallDataTypes}=Dict{Symbol, SmallDataTypes}(),
258-
dataDict::Dict{Symbol, AbstractBlobEntry}=Dict{Symbol,AbstractBlobEntry}(),
258+
dataDict::Dict{Symbol, BlobEntry}=Dict{Symbol,BlobEntry}(),
259259
solvable::Int=1) where {T <: InferenceVariable, P}
260260
#
261261
DFGVariable{T}(id, label, timestamp, nstime, tags, estimateDict, solverDataDict, smallData, dataDict, Ref(solvable))
@@ -278,7 +278,7 @@ function DFGVariable(label::Symbol,
278278
tags::Set{Symbol}=Set{Symbol}(),
279279
estimateDict::Dict{Symbol, <: AbstractPointParametricEst}=Dict{Symbol, MeanMaxPPE}(),
280280
smallData::Dict{Symbol, SmallDataTypes}=Dict{Symbol, SmallDataTypes}(),
281-
dataDict::Dict{Symbol, <: AbstractBlobEntry}=Dict{Symbol,AbstractBlobEntry}(),
281+
dataDict::Dict{Symbol, <: BlobEntry}=Dict{Symbol,BlobEntry}(),
282282
solvable::Int=1) where {T <: InferenceVariable}
283283
#
284284
DFGVariable{T}(id, label, timestamp, nstime, tags, estimateDict, Dict{Symbol, VariableNodeData{T, getPointType(T)}}(:default=>solverData), smallData, dataDict, Ref(solvable))
@@ -341,7 +341,7 @@ Base.@kwdef struct DFGVariableSummary <: AbstractDFGVariable
341341
variableTypeName::Symbol
342342
"""Dictionary of large data associated with this variable.
343343
Accessors: [`addDataEntry!`](@ref), [`getBlobEntry`](@ref), [`updateDataEntry!`](@ref), and [`deleteDataEntry!`](@ref)"""
344-
dataDict::Dict{Symbol, AbstractBlobEntry}
344+
dataDict::Dict{Symbol, BlobEntry}
345345
end
346346

347347

src/services/Serialization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function unpackVariable(variable::PackedVariable; skipVersionCheck::Bool=false)
174174
solverDict = Dict{Symbol, VariableNodeData{variableType, pointType}}(
175175
map(sd -> sd.solveKey, variable.solverData) .=>
176176
map(sd -> DFG.unpackVariableNodeData(sd), variable.solverData))
177-
dataDict = Dict{Symbol, AbstractBlobEntry}(map(de -> de.label, variable.dataEntries) .=> variable.dataEntries)
177+
dataDict = Dict{Symbol, BlobEntry}(map(de -> de.label, variable.dataEntries) .=> variable.dataEntries)
178178
metadata = JSON3.read(base64decode(variable.metadata), Dict{Symbol, DFG.SmallDataTypes})
179179

180180
return DFGVariable(

test/interfaceTests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ end
6161
@test printVariable(iobuf, var1, skipfields=[:timestamp, :solver, :ppe, :nstime]) === nothing
6262

6363
# for julia v1.6
64-
@test String(take!(iobuf)) == "DFGVariable{TestVariableType1}\nid:\nnothing\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict{Symbol, Union{Bool, Float64, Int64, Vector{Bool}, Vector{Float64}, Vector{Int64}, Vector{String}, String}}(:small=>\"data\")\ndataDict:\nDict{Symbol, DistributedFactorGraphs.AbstractBlobEntry}()\nsolvable:\n0\n"
64+
if DistributedFactorGraphs._getDFGVersion() < v"0.19"
65+
@test String(take!(iobuf)) == "DFGVariable{TestVariableType1}\nid:\nnothing\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict{Symbol, Union{Bool, Float64, Int64, Vector{Bool}, Vector{Float64}, Vector{Int64}, Vector{String}, String}}(:small=>\"data\")\ndataDict:\nDict{Symbol, DistributedFactorGraphs.BlobEntry}()\nsolvable:\n0\n"
66+
else
67+
@test String(take!(iobuf)) == "DFGVariable{TestVariableType1}\nid:\nnothing\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict{Symbol, Union{Bool, Float64, Int64, Vector{Bool}, Vector{Float64}, Vector{Int64}, Vector{String}, String}}(:small=>\"data\")\ndataDict:\nDict{Symbol, BlobEntry}()\nsolvable:\n0\n"
68+
end
6569

6670
@test printVariable(iobuf, var1, short=true) === nothing
6771
varstr = String(take!(iobuf))

0 commit comments

Comments
 (0)