Skip to content

Commit a87352c

Browse files
authored
Merge pull request #550 from JuliaRobotics/maint/20Q3/datablob_concepts
DataEntry and BlobStore API Standardization
2 parents ce22180 + 2407a9e commit a87352c

25 files changed

+906
-529
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1616
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
1717
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1818
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
19+
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
1920
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2021
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
2122
Unmarshal = "cbff2730-442d-58d7-89d1-8e530c41eb02"

src/DataBlobs/DataBlobs.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
include("entities/AbstractDataStore.jl")
1+
# using DataFrames
2+
# using CSV
3+
using JSON
4+
using SHA
5+
26
include("entities/AbstractDataEntries.jl")
3-
include("entities/InMemoryDataStore.jl")
4-
include("entities/FileDataStore.jl")
7+
# include("entities/BlobStores.jl")
58

6-
include("services/AbstractDataStore.jl")
79
include("services/AbstractDataEntries.jl")
8-
include("services/InMemoryDataStore.jl")
9-
include("services/FileDataStore.jl")
10+
include("services/DataEntryBlob.jl")
11+
include("services/BlobStores.jl")
12+
13+
include("services/FileDataEntryBlob.jl")
14+
include("services/InMemoryDataEntryBlob.jl")
1015

11-
export AbstractDataStore
1216

1317
export AbstractDataEntry, GeneralDataEntry, MongodbDataEntry, FileDataEntry
1418
export InMemoryDataStore, FileDataStore
1519

1620
export getData, addData!, updateData!, deleteData!, listStoreEntries
1721
export getDataBlob, addDataBlob!, updateDataBlob!, deleteDataBlob!, listDataBlobs
1822
export copyStore
23+
24+
export getId, getHash, getCreatedTimestamp
Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
1-
"""
2-
$(TYPEDEF)
3-
GeneralDataEntry is a generic multipurpose data entry that creates a unique
4-
reproducible key using userId_robotId_sessionId_variableId_key.
5-
"""
6-
mutable struct GeneralDataEntry <: AbstractDataEntry
7-
key::Symbol
8-
storeKey::Symbol # Could swap this to string, but using it as an index later, so better as a symbol I believe.
9-
createdTimestamp::DateTime
10-
lastUpdatedTimestamp::DateTime
11-
mimeType::String
12-
end
1+
##==============================================================================
2+
## AbstractDataEntry - Defined in src/entities/AbstractDFG.jl
3+
##==============================================================================
4+
# Fields to be implemented
5+
# label
6+
# id
137

14-
"""
15-
$(SIGNATURES)
16-
Internal function to generate a unique key for the entry - userId_robotId_sessionId_variable_key.
17-
Simple symbol.
18-
"""
19-
function _uniqueKey(dfg::G, v::V, key::Symbol)::Symbol where {G <: AbstractDFG, V <: AbstractDFGVariable}
20-
key = join(String.([dfg.userId, dfg.robotId, dfg.sessionId, getLabel(v), String(key)]), "_")
21-
return Symbol(key)
22-
end
8+
getLabel(entry::AbstractDataEntry) = entry.label
9+
getId(entry::AbstractDataEntry) = entry.id
10+
getHash(entry::AbstractDataEntry) = hex2bytes(entry.hash)
11+
getCreatedTimestamp(entry::AbstractDataEntry) = entry.createdTimestamp
2312

2413

25-
GeneralDataEntry(key::Symbol, storeKey::Symbol;
26-
mimeType::String="application/octet-stream") =
27-
GeneralDataEntry(key, storeKey, now(), now(), mimeType)
14+
##==============================================================================
15+
## BlobStoreEntry
16+
##==============================================================================
17+
export BlobStoreEntry
2818

29-
function GeneralDataEntry(dfg::G, var::V, key::Symbol;
30-
mimeType::String="application/octet-stream") where {G <: AbstractDFG, V <: AbstractDFGVariable}
31-
return GeneralDataEntry(key, _uniqueKey(dfg, var, key), mimeType=mimeType)
19+
"""
20+
$(TYPEDEF)
21+
Genaral Data Store Entry.
22+
"""
23+
struct BlobStoreEntry <: AbstractDataEntry
24+
label::Symbol
25+
id::UUID
26+
blobstore::Symbol
27+
hash::String # Probably https://docs.julialang.org/en/v1/stdlib/SHA
28+
origin::String # E.g. user|robot|session|varlabel
29+
description::String
30+
mimeType::String
31+
createdTimestamp::ZonedDateTime # of when the entry was created
3232
end
3333

34+
# TODO
3435
"""
3536
$(TYPEDEF)
3637
Data Entry in MongoDB.
3738
"""
3839
struct MongodbDataEntry <: AbstractDataEntry
39-
key::Symbol
40-
oid::NTuple{12, UInt8} #mongodb object id
40+
label::Symbol
41+
id::UUID
42+
oid::NTuple{12, UInt8} #mongodb object id - TODO Not needed with id::UUID unique, but perhaps usefull
43+
hash::String
44+
createdTimestamp::ZonedDateTime
45+
# mongodb
46+
# mongoConfig::MongoConfig
4147
#maybe other fields such as:
4248
#flags::Bool ready, valid, locked, permissions
4349
#MIMEType::String
4450
end
45-
46-
47-
"""
48-
$(TYPEDEF)
49-
Data Entry in a file.
50-
"""
51-
struct FileDataEntry <: AbstractDataEntry
52-
key::Symbol
53-
filename::String
54-
end

src/DataBlobs/entities/AbstractDataStore.jl

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/DataBlobs/entities/FileDataStore.jl

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/DataBlobs/entities/InMemoryDataStore.jl

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)