1- # #==============================================================================
2- # # Blob CRUD interface
3- # #==============================================================================
4-
5- """
6- Get the data blob for the specified Blobstore or DFG.
7-
8- Related
9- [`getBlobentry`](@ref)
10- Implement
11- `getBlob(store::AbstractBlobstore, blobid::UUID)`
12-
13- $(METHODLIST)
14- """
15- function getBlob end
16-
17- """
18- Adds a blob to the Blobstore with the blobid.
19-
20- Related
21- [`addBlobentry!`](@ref)
22- Implement
23- `addBlob!(store::AbstractBlobstore, blobid::UUID, data)`
24- $(METHODLIST)
25- """
26- function addBlob! end
27-
28- """
29- Delete a blob from the blob store or dfg with the given entry.
30-
31- Related
32- [`deleteBlobentry!`](@ref)
33- Implement
34- `deleteBlob!(store::AbstractBlobstore, blobid::UUID)`
35- $(METHODLIST)
36- """
37- function deleteBlob! end
38-
39- """
40- $(SIGNATURES)
41- List all `blobid`s in the blob store.
42- Implement
43- `listBlobs(store::AbstractBlobstore)`
44- """
45- function listBlobs end
46-
47- """
48- $(SIGNATURES)
49- Check if the blob store has a blob with the given `blobid`.
50- """
51- function hasBlob end
52-
53- # #==============================================================================
54- # # AbstractBlobstore derived CRUD for Blob
55- # #==============================================================================
56- # TODO maybe we should generalize and move the cached Blobstore to DFG.
57- function getBlob (dfg:: AbstractDFG , entry:: Blobentry )
58- storeLabel = entry. storelabel
59- store = getBlobstore (dfg, storeLabel)
60- return getBlob (store, entry. blobid)
61- end
62-
63- function getBlob (store:: AbstractBlobstore , entry:: Blobentry )
64- return getBlob (store, entry. blobid)
65- end
66-
67- # add
68- function addBlob! (dfg:: AbstractDFG , entry:: Blobentry , data)
69- return addBlob! (getBlobstore (dfg, entry. storelabel), entry, data)
70- end
71-
72- function addBlob! (store:: AbstractBlobstore{T} , entry:: Blobentry , data:: T ) where {T}
73- return addBlob! (store, entry. blobid, data)
74- end
75-
76- # also creates an blobid as uuid4
77- addBlob! (store:: AbstractBlobstore , data) = addBlob! (store, uuid4 (), data)
781
79- # delete
80- function deleteBlob! (dfg:: AbstractDFG , entry:: Blobentry )
81- return deleteBlob! (getBlobstore (dfg, entry. storelabel), entry)
82- end
83-
84- function deleteBlob! (store:: AbstractBlobstore , entry:: Blobentry )
85- return deleteBlob! (store, entry. blobid)
86- end
87-
88- # has
89- function hasBlob (store:: AbstractBlobstore , entry:: Blobentry )
90- return hasBlob (store, entry. blobid)
91- end
92- function hasBlob (dfg:: AbstractDFG , entry:: Blobentry )
93- return hasBlob (getBlobstore (dfg, entry. storelabel), entry. blobid)
94- end
95-
96- # TODO
97- # """
98- # $(SIGNATURES)
99- # Copies all the entries from the source into the destination.
100- # Can specify which entries to copy with the `sourceEntries` parameter.
101- # Returns the list of copied entries.
102- # """
103- # function copyBlobstore(sourceStore::D1, destStore::D2; sourceEntries=listEntries(sourceStore))::Vector{E} where {T, D1 <: AbstractDataStore{T}, D2 <: AbstractDataStore{T}, E <: Blobentry}
104- # # Quick check
105- # destEntries = listBlobs(destStore)
106- # typeof(sourceEntries) != typeof(destEntries) && error("Can't copy stores, source has entries of type $(typeof(sourceEntries)), destination has entries of type $(typeof(destEntries)).")
107- # # Same source/destination check
108- # sourceStore == destStore && error("Can't specify same store for source and destination.")
109- # # Otherwise, continue
110- # for sourceEntry in sourceEntries
111- # addBlob!(destStore, deepcopy(sourceEntry), getBlob(sourceStore, sourceEntry))
112- # end
113- # return sourceEntries
114- # end
115-
116- # #==============================================================================
117- # # FolderStore
118- # #==============================================================================
2+ # ==============================================================================
3+ # FolderStore
4+ # TODO rename to FolderBlobstore
5+ # ==============================================================================
1196struct FolderStore{T} <: AbstractBlobstore{T}
1207 label:: Symbol
1218 folder:: String
@@ -200,9 +87,10 @@ function listBlobs(store::FolderStore)
20087 return blobids
20188end
20289
203- # #==============================================================================
204- # # InMemoryBlobstore
205- # #==============================================================================
90+ # ==============================================================================
91+ # InMemoryBlobstore
92+ # TODO rename to MemoryBlobstore
93+ # ==============================================================================
20694
20795struct InMemoryBlobstore{T} <: AbstractBlobstore{T}
20896 label:: Symbol
@@ -241,9 +129,10 @@ hasBlob(store::InMemoryBlobstore, blobid::UUID) = haskey(store.blobs, blobid)
241129
242130listBlobs (store:: InMemoryBlobstore ) = collect (keys (store. blobs))
243131
244- # #==============================================================================
245- # # LinkStore Link blobid to a existing local folder
246- # #==============================================================================
132+ # ==============================================================================
133+ # LinkStore Link blobid to a existing local folder
134+ # TODO Rename to LinkBlobstore
135+ # ==============================================================================
247136# TODO consider using a deterministic blobid (uuid5) with ns stored in the csv?
248137@tags struct LinkStore <: AbstractBlobstore{String}
249138 label:: Symbol
292181deleteBlob! (store:: LinkStore , :: Blobentry ) = deleteBlob! (store)
293182deleteBlob! (store:: LinkStore , :: UUID ) = deleteBlob! (store)
294183
295- # # ==============================================================================
296- # # RowBlobstore Ordered Dict Row Table Blob Store
297- # # ==============================================================================
184+ # ==============================================================================
185+ # RowBlobstore Ordered Dict Row Table Blob Store
186+ # ==============================================================================
298187
299188# RowBlob
300189# T must be compatable with the AbstactRow iterator
@@ -320,7 +209,7 @@ function Tables.columnnames(row::RowBlob)
320209 return (:id , Tables. columnnames (getfield (row, :blob ))... )
321210end
322211
323- # # RowBlobstore
212+ # RowBlobstore
324213
325214struct RowBlobstore{T} <: AbstractBlobstore{T}
326215 label:: Symbol
@@ -350,7 +239,7 @@ Tables.rows(store::RowBlobstore) = values(store.blobs)
350239# TODO
351240# Tables.materializer(::Type{RowBlobstore{T}}) where T = Tables.rowtable
352241
353- # #
242+ #
354243function getBlob (store:: RowBlobstore , blobid:: UUID )
355244 if ! haskey (store. blobs, blobid)
356245 throw (IdNotFoundError (" Blob" , blobid))
@@ -377,7 +266,7 @@ hasBlob(store::RowBlobstore, blobid::UUID) = haskey(store.blobs, blobid)
377266listBlobs (store:: RowBlobstore ) = collect (keys (store. blobs))
378267
379268# TODO also see about wrapping a table directly
380- # #
269+ #
381270if false
382271 rb = RowBlob (uuid4 (), (a = [1 , 2 ], b = [3 , 4 ]))
383272
@@ -399,7 +288,7 @@ if false
399288
400289 # Tables.materializer(tstore)
401290
402- # #
291+ #
403292 struct Foo
404293 a:: Float64
405294 b:: Float64
@@ -413,5 +302,5 @@ if false
413302
414303 Tables. rowtable (sstore)
415304end
416- # #
417- # #
305+ #
306+ #
0 commit comments