Skip to content

Commit b0399e3

Browse files
authored
Merge pull request #957 from JuliaRobotics/23Q1/enh/blobidsarehard
Towards standard BlobEntry
2 parents c9e0323 + 6e42f59 commit b0399e3

File tree

2 files changed

+69
-86
lines changed

2 files changed

+69
-86
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.19.4"
3+
version = "0.20.0"
44

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

src/DataBlobs/entities/AbstractDataEntries.jl

Lines changed: 68 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ getTimestamp(entry::AbstractDataEntry) = entry.timestamp
1414
##==============================================================================
1515
## BlobStoreEntry
1616
##==============================================================================
17-
export BlobStoreEntry
17+
export BlobEntry
1818

1919
"""
2020
$(TYPEDEF)
2121
General Data Store Entry.
2222
"""
23-
@Base.kwdef struct BlobStoreEntry <: AbstractDataEntry
24-
id::Union{UUID, Nothing}=nothing
23+
@Base.kwdef struct BlobEntry <: AbstractDataEntry
24+
""" This is created by server-side GraphQL """
25+
id::Union{UUID, Nothing}=nothing
26+
""" This is the forced server generated blobId, or the filesystem blobId. """
27+
blobId::Union{UUID, Nothing}=nothing
28+
""" This is the ID at creation at the edge, do whatever you want with this, but make sure you populate it. """
29+
originId::UUID
2530
label::Symbol
2631
blobstore::Symbol
2732
hash::String # Probably https://docs.julialang.org/en/v1/stdlib/SHA
@@ -30,99 +35,77 @@ General Data Store Entry.
3035
mimeType::String
3136
metadata::String = ""
3237
timestamp::ZonedDateTime = now(localzone())
33-
_type::String = "BlobStoreEntry"
38+
_type::String = "BlobEntry"
3439
_version::String = string(_getDFGVersion()) # TBD consider upgrading to ::VersionNumber
3540
end
3641

42+
# should be deprecated by v0.21
43+
export BlobStoreEntry
44+
const BlobStoreEntry = BlobEntry
45+
3746
_fixtimezone(cts::NamedTuple) = ZonedDateTime(cts.utc_datetime*"+00")
3847

39-
# # needed for deserialization from JSON during DFG v0.19 transition, see #867
40-
# # TODO this function can likely be removed, since julia automatically tries type conversion on constructors.
41-
# function BlobStoreEntry(;
42-
# id,
43-
# label,
44-
# blobstore,
45-
# hash,
46-
# origin,
47-
# description,
48-
# mimeType,
49-
# timestamp,
50-
# kwargs... # drop excessive fields
51-
# )
52-
# #
53-
# BlobStoreEntry(;
54-
# id=UUID(id),
55-
# label=Symbol(label),
56-
# blobstore=Symbol(blobstore),
57-
# hash,
58-
# origin,
59-
# description,
60-
# mimeType,
61-
# timestamp=_fixtimezone(timestamp),
62-
# )
48+
# # TODO
49+
# """
50+
# $(TYPEDEF)
51+
# Data Entry in MongoDB.
52+
# """
53+
# struct MongodbDataEntry <: AbstractDataEntry
54+
# label::Symbol
55+
# id::UUID
56+
# oid::NTuple{12, UInt8} #mongodb object id - TODO Not needed with id::UUID unique, but perhaps usefull
57+
# hash::String
58+
# createdTimestamp::ZonedDateTime
59+
# # mongodb
60+
# # mongoConfig::MongoConfig
61+
# #maybe other fields such as:
62+
# #flags::Bool ready, valid, locked, permissions
63+
# #MIMEType::String
6364
# end
6465

65-
# TODO
66-
"""
67-
$(TYPEDEF)
68-
Data Entry in MongoDB.
69-
"""
70-
struct MongodbDataEntry <: AbstractDataEntry
71-
label::Symbol
72-
id::UUID
73-
oid::NTuple{12, UInt8} #mongodb object id - TODO Not needed with id::UUID unique, but perhaps usefull
74-
hash::String
75-
createdTimestamp::ZonedDateTime
76-
# mongodb
77-
# mongoConfig::MongoConfig
78-
#maybe other fields such as:
79-
#flags::Bool ready, valid, locked, permissions
80-
#MIMEType::String
81-
end
8266

67+
# ##==============================================================================
68+
# ## FileDataEntryBlob Types
69+
# ##==============================================================================
70+
# export FileDataEntry
71+
# """
72+
# $(TYPEDEF)
73+
# Data Entry in a file.
74+
# """
75+
# struct FileDataEntry <: AbstractDataEntry
76+
# label::Symbol
77+
# id::UUID
78+
# folder::String
79+
# hash::String #using bytes2hex or perhaps Vector{Uint8}?
80+
# createdTimestamp::ZonedDateTime
8381

84-
##==============================================================================
85-
## FileDataEntryBlob Types
86-
##==============================================================================
87-
export FileDataEntry
88-
"""
89-
$(TYPEDEF)
90-
Data Entry in a file.
91-
"""
92-
struct FileDataEntry <: AbstractDataEntry
93-
label::Symbol
94-
id::UUID
95-
folder::String
96-
hash::String #using bytes2hex or perhaps Vector{Uint8}?
97-
createdTimestamp::ZonedDateTime
98-
99-
function FileDataEntry(label, id, folder, hash, timestamp)
100-
if !isdir(folder)
101-
@info "Folder '$folder' doesn't exist - creating."
102-
# create new folder
103-
mkpath(folder)
104-
end
105-
return new(label, id, folder, hash, timestamp)
106-
end
107-
end
82+
# function FileDataEntry(label, id, folder, hash, timestamp)
83+
# if !isdir(folder)
84+
# @info "Folder '$folder' doesn't exist - creating."
85+
# # create new folder
86+
# mkpath(folder)
87+
# end
88+
# return new(label, id, folder, hash, timestamp)
89+
# end
90+
# end
10891

10992

110-
##==============================================================================
111-
## InMemoryDataEntry Types
112-
##==============================================================================
113-
export InMemoryDataEntry
114-
"""
115-
$(TYPEDEF)
116-
Store data temporary in memory.
117-
NOTE: Neither Entry nor Blob will be persisted.
118-
"""
119-
struct InMemoryDataEntry{T} <: AbstractDataEntry
120-
label::Symbol
121-
id::UUID
122-
#hash::String #Is this needed?
123-
createdTimestamp::ZonedDateTime
124-
data::T
125-
end
93+
# ##==============================================================================
94+
# ## InMemoryDataEntry Types
95+
# ##==============================================================================
96+
# export InMemoryDataEntry
97+
# """
98+
# $(TYPEDEF)
99+
# Store data temporary in memory.
100+
# NOTE: Neither Entry nor Blob will be persisted.
101+
# """
102+
# struct InMemoryDataEntry{T} <: AbstractDataEntry
103+
# label::Symbol
104+
# id::UUID
105+
# #hash::String #Is this needed?
106+
# createdTimestamp::ZonedDateTime
107+
# data::T
108+
# end
126109

127110
# getHash(::InMemoryDataEntry) = UInt8[]
128111
assertHash(de::InMemoryDataEntry, db; hashfunction = sha256) = true

0 commit comments

Comments
 (0)