Skip to content

Commit f71bfc8

Browse files
committed
Renamed Varaible and abstracts - TODO test
1 parent b09697f commit f71bfc8

23 files changed

+199
-151
lines changed

src/BigData/BigData.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
include("entities/AbstractDataStore.jl")
2+
#TODO Rename to AbstractDataEntries
23
include("entities/AbstractBigDataEntries.jl")
34
include("entities/InMemoryDataStore.jl")
45
include("entities/FileDataStore.jl")
56

67
include("services/AbstractDataStore.jl")
8+
#TODO Rename to AbstractDataEntries
79
include("services/AbstractBigDataEntries.jl")
810
include("services/InMemoryDataStore.jl")
911
include("services/FileDataStore.jl")
1012

1113
export AbstractDataStore
1214

13-
export AbstractBigDataEntry, GeneralDataEntry, MongodbDataEntry, FileDataEntry
15+
export AbstractDataEntry, GeneralDataEntry, MongodbDataEntry, FileDataEntry
1416
export InMemoryDataStore, FileDataStore
1517

1618
export getData, addData!, updateData!, deleteData!, listStoreEntries

src/BigData/entities/AbstractBigDataEntries.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
22
$(TYPEDEF)
3-
GeneralBigDataEntry is a generic multipurpose data entry that creates a unique
3+
GeneralDataEntry is a generic multipurpose data entry that creates a unique
44
reproducible key using userId_robotId_sessionId_variableId_key.
55
"""
6-
mutable struct GeneralDataEntry <: AbstractBigDataEntry
6+
mutable struct GeneralDataEntry <: AbstractDataEntry
77
key::Symbol
88
storeKey::Symbol # Could swap this to string, but using it as an index later, so better as a symbol I believe.
99
createdTimestamp::DateTime
@@ -31,29 +31,24 @@ function GeneralDataEntry(dfg::G, var::V, key::Symbol;
3131
return GeneralDataEntry(key, _uniqueKey(dfg, var, key), mimeType=mimeType)
3232
end
3333

34-
@deprecate GeneralBigDataEntry(args...; kwargs...) GeneralDataEntry(args...; kwargs...)
35-
3634
"""
3735
$(TYPEDEF)
38-
BigDataEntry in MongoDB.
36+
Data Entry in MongoDB.
3937
"""
40-
struct MongodbDataEntry <: AbstractBigDataEntry
38+
struct MongodbDataEntry <: AbstractDataEntry
4139
key::Symbol
4240
oid::NTuple{12, UInt8} #mongodb object id
4341
#maybe other fields such as:
4442
#flags::Bool ready, valid, locked, permissions
4543
#MIMEType::String
4644
end
4745

48-
@deprecate MongodbBigDataEntry(args...) MongodbDataEntry(args...)
4946

5047
"""
5148
$(TYPEDEF)
52-
BigDataEntry in a file.
49+
Data Entry in a file.
5350
"""
54-
struct FileDataEntry <: AbstractBigDataEntry
51+
struct FileDataEntry <: AbstractDataEntry
5552
key::Symbol
5653
filename::String
5754
end
58-
59-
@deprecate FileBigDataEntry(args...) FileDataEntry(args...)

src/BigData/entities/InMemoryDataStore.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$(TYPEDEF)
33
Simple in-memory data store with a specified data type and a specified key type.
44
"""
5-
struct InMemoryDataStore{T, E <: AbstractBigDataEntry} <: AbstractDataStore{T}
5+
struct InMemoryDataStore{T, E <: AbstractDataEntry} <: AbstractDataStore{T}
66
data::Dict{Symbol, T}
77
entries::Dict{Symbol, E}
88
end
@@ -11,7 +11,7 @@ end
1111
$(SIGNATURES)
1212
Create an in-memory store using a specific data type.
1313
"""
14-
function InMemoryDataStore{T, E}() where {T, E <: AbstractBigDataEntry}
14+
function InMemoryDataStore{T, E}() where {T, E <: AbstractDataEntry}
1515
return InMemoryDataStore{T, E}(Dict{Symbol, T}(), Dict{Symbol, E}())
1616
end
1717

src/BigData/services/AbstractBigDataEntries.jl

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ end
2020
$(SIGNATURES)
2121
Add Big Data Entry to a DFG variable
2222
"""
23-
function addDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)
24-
haskey(var.bigData,bde.key) && error("BigData entry $(bde.key) already exists in variable")
25-
var.bigData[bde.key] = bde
23+
function addDataEntry!(var::AbstractDFGVariable, bde::AbstractDataEntry)
24+
haskey(var.dataDict, bde.key) && error("Data entry $(bde.key) already exists in variable")
25+
var.dataDict[bde.key] = bde
2626
return bde
2727
end
2828

@@ -32,11 +32,10 @@ end
3232
Add Big Data Entry to distributed factor graph.
3333
Should be extended if DFG variable is not returned by reference.
3434
"""
35-
function addDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)
36-
return addBigDataEntry!(getVariable(dfg, label), bde)
35+
function addDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractDataEntry)
36+
return addDataEntry!(getVariable(dfg, label), bde)
3737
end
3838

39-
@deprecate addBigDataEntry!(args...) addDataEntry!(args...)
4039

4140
"""
4241
$(SIGNATURES)
@@ -73,24 +72,21 @@ end
7372
7473
Does a data entry (element) exist at `key`.
7574
"""
76-
hasDataEntry(var::DFGVariable, key::Symbol) = haskey(var.bigData, key)
77-
const hasBigDataEntry = hasDataEntry
75+
hasDataEntry(var::DFGVariable, key::Symbol) = haskey(var.dataDict, key)
7876

7977
"""
8078
$(SIGNATURES)
8179
Get big data entry
8280
"""
8381
function getDataEntry(var::AbstractDFGVariable, key::Symbol)
84-
!hasDataEntry(var, key) && (error("BigData entry $(key) does not exist in variable"); return nothing)
85-
return var.bigData[key]
82+
!hasDataEntry(var, key) && (error("Data entry $(key) does not exist in variable"); return nothing)
83+
return var.dataDict[key]
8684
end
8785

8886
function getDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol)
89-
return getBigDataEntry(getVariable(dfg, label), key)
87+
return getDataEntry(getVariable(dfg, label), key)
9088
end
9189

92-
@deprecate getBigDataEntry(args...) getDataEntry(args...)
93-
9490
"""
9591
$SIGNATURES
9692
Get both the entry and raw data element from datastore returning as a tuple.
@@ -147,7 +143,6 @@ const fetchDataEntryElement = getDataEntryBlob
147143
const fetchData = getDataEntryBlob
148144

149145
#
150-
@deprecate getDataEntryElement(args...) getDataEntryBlob(args...)
151146

152147
"""
153148
$(SIGNATURES)
@@ -156,18 +151,16 @@ Update big data entry
156151
DevNote
157152
- DF, unclear if `update` verb is applicable in this case, see #404
158153
"""
159-
function updateDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)
160-
!haskey(var.bigData,bde.key) && (@warn "$(bde.key) does not exist in variable, adding")
161-
var.bigData[bde.key] = bde
154+
function updateDataEntry!(var::AbstractDFGVariable, bde::AbstractDataEntry)
155+
!haskey(var.dataDict, bde.key) && (@warn "$(bde.key) does not exist in variable, adding")
156+
var.dataDict[bde.key] = bde
162157
return bde
163158
end
164-
function updateDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)
159+
function updateDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractDataEntry)
165160
# !isVariable(dfg, label) && return nothing
166161
return updateDataEntry!(getVariable(dfg, label), bde)
167162
end
168163

169-
@deprecate updateBigDataEntry!(args...) updateDataEntry!(args...)
170-
171164
"""
172165
$(SIGNATURES)
173166
Delete big data entry from the factor graph.
@@ -179,7 +172,7 @@ Notes:
179172
function deleteDataEntry!(var::AbstractDFGVariable, key::Symbol)
180173
bde = getDataEntry(var, key)
181174
bde == nothing && return nothing
182-
delete!(var.bigData, key)
175+
delete!(var.dataDict, key)
183176
return var
184177
end
185178
function deleteDataEntry!(dfg::AbstractDFG, label::Symbol, key::Symbol)
@@ -188,40 +181,35 @@ function deleteDataEntry!(dfg::AbstractDFG, label::Symbol, key::Symbol)
188181
return deleteDataEntry!(getVariable(dfg, label), key)
189182
end
190183

191-
function deleteDataEntry!(var::AbstractDFGVariable, entry::AbstractBigDataEntry)
184+
function deleteDataEntry!(var::AbstractDFGVariable, entry::AbstractDataEntry)
192185
#users responsibility to delete big data in db before deleting entry
193186
return deleteDataEntry!(var, entry.key)
194187
end
195188

196-
@deprecate deleteBigDataEntry!(args...) deleteDataEntry!(args...)
197-
198189
"""
199190
$(SIGNATURES)
200-
Get big data entries, Vector{AbstractBigDataEntry}
191+
Get big data entries, Vector{AbstractDataEntry}
201192
"""
202193
function getDataEntries(var::AbstractDFGVariable)
203-
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBigDataEntry}}?
204-
collect(values(var.bigData))
194+
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractDataEntry}}?
195+
collect(values(var.dataDict))
205196
end
206197
function getDataEntries(dfg::AbstractDFG, label::Symbol)
207198
!isVariable(dfg, label) && return nothing
208-
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBigDataEntry}}?
199+
#or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractDataEntry}}?
209200
getDataEntries(getVariable(dfg, label))
210201
end
211202

212-
@deprecate getBigDataEntries(args...) getDataEntries(args...)
213-
214203

215204
"""
216205
$(SIGNATURES)
217206
listDataEntries
218207
"""
219208
function listDataEntries(var::AbstractDFGVariable)
220-
collect(keys(var.bigData))
209+
collect(keys(var.dataDict))
221210
end
211+
222212
function listDataEntries(dfg::AbstractDFG, label::Symbol)
223213
!isVariable(dfg, label) && return nothing
224214
listDataEntries(getVariable(dfg, label))
225215
end
226-
227-
@deprecate getBigDataKeys(args...) listDataEntries(args...)

src/BigData/services/AbstractDataStore.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$(SIGNATURES)
33
Get the data for the specified entry, returns the data or Nothing.
44
"""
5-
function getDataBlob(store::D, entry::E)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractBigDataEntry}
5+
function getDataBlob(store::D, entry::E)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractDataEntry}
66
error("$(typeof(store)) doesn't override 'getDataBlob'.")
77
end
88

@@ -11,7 +11,7 @@ end
1111
Adds the data to the store with the given entry. The function will warn if the entry already
1212
exists and will overwrite it.
1313
"""
14-
function addDataBlob!(store::D, entry::E, data::T)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractBigDataEntry}
14+
function addDataBlob!(store::D, entry::E, data::T)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractDataEntry}
1515
error("$(typeof(store)) doesn't override 'addDataBlob!'.")
1616
end
1717

@@ -20,7 +20,7 @@ end
2020
Update the data in the store. The function will error and return nothing if
2121
the entry does not exist.
2222
"""
23-
function updateDataBlob!(store::D, entry::E, data::T)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractBigDataEntry}
23+
function updateDataBlob!(store::D, entry::E, data::T)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractDataEntry}
2424
error("$(typeof(store)) doesn't override 'updateDataBlob!'.")
2525
end
2626

@@ -29,7 +29,7 @@ end
2929
Delete the data in the store for the given entry. The function will error and return nothing if
3030
the entry does not exist.
3131
"""
32-
function deleteDataBlob!(store::D, entry::E)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractBigDataEntry}
32+
function deleteDataBlob!(store::D, entry::E)::Union{Nothing, T} where {T, D <: AbstractDataStore{T}, E <: AbstractDataEntry}
3333
error("$(typeof(store)) doesn't override 'deleteDataBlob!'.")
3434
end
3535

@@ -47,7 +47,7 @@ Copies all the entries from the source into the destination.
4747
Can specify which entries to copy with the `sourceEntries` parameter.
4848
Returns the list of copied entries.
4949
"""
50-
function copyStore(sourceStore::D1, destStore::D2; sourceEntries=listEntries(sourceStore))::Vector{E} where {T, D1 <: AbstractDataStore{T}, D2 <: AbstractDataStore{T}, E <: AbstractBigDataEntry}
50+
function copyStore(sourceStore::D1, destStore::D2; sourceEntries=listEntries(sourceStore))::Vector{E} where {T, D1 <: AbstractDataStore{T}, D2 <: AbstractDataStore{T}, E <: AbstractDataEntry}
5151
# Quick check
5252
destEntries = listDataBlobs(destStore)
5353
typeof(sourceEntries) != typeof(destEntries) && error("Can't copy stores, source has entries of type $(typeof(sourceEntries)), destination has entries of type $(typeof(destEntries)).")

src/BigData/services/FileDataStore.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
## FileDataStore Common
33
##==============================================================================
44
searchdir(path,key) = filter(x->occursin(key,x), readdir(path))
5-
filename(store::FileDataStore, entry::E) where E <: AbstractBigDataEntry = "$(store.folder)/$(entry.storeKey).dat"
5+
filename(store::FileDataStore, entry::E) where E <: AbstractDataEntry = "$(store.folder)/$(entry.storeKey).dat"
66

7-
function readentry(store::FileDataStore, entry::AbstractBigDataEntry)
7+
function readentry(store::FileDataStore, entry::AbstractDataEntry)
88
open(filename(store, entry)) do f
99
return read(f)
1010
end
1111
end
1212

13-
function writeentry(store::FileDataStore, entry::AbstractBigDataEntry, data::Vector{UInt8})
13+
function writeentry(store::FileDataStore, entry::AbstractDataEntry, data::Vector{UInt8})
1414
open(filename(store, entry), "w") do f
1515
write(f, data)
1616
end
@@ -20,20 +20,20 @@ end
2020
## FileDataStore CRUD
2121
##==============================================================================
2222

23-
function getDataBlob(store::FileDataStore, entry::AbstractBigDataEntry)::Union{Vector{UInt8}, Nothing}
23+
function getDataBlob(store::FileDataStore, entry::AbstractDataEntry)::Union{Vector{UInt8}, Nothing}
2424
length(searchdir(store.folder, String(entry.storeKey)*".dat")) !=1 && (@warn "Could not find unique file for key '$(entry.storeKey)'."; return nothing)
2525
return readentry(store, entry)
2626
end
2727

28-
function addDataBlob!(store::FileDataStore, entry::AbstractBigDataEntry, data::Vector{UInt8})::Vector{UInt8}
28+
function addDataBlob!(store::FileDataStore, entry::AbstractDataEntry, data::Vector{UInt8})::Vector{UInt8}
2929
length(searchdir(store.folder, String(entry.storeKey)*".dat")) !=0 && error("Key '$(entry.storeKey)' already exists.")
3030
writeentry(store, entry, data)
3131
# Update timestamp
3232
entry.lastUpdatedTimestamp = now()
3333
return getDataBlob(store, entry)
3434
end
3535

36-
function updateDataBlob!(store::FileDataStore, entry::AbstractBigDataEntry, data::Vector{UInt8})::Union{Vector{UInt8}, Nothing}
36+
function updateDataBlob!(store::FileDataStore, entry::AbstractDataEntry, data::Vector{UInt8})::Union{Vector{UInt8}, Nothing}
3737
n_entries = length(searchdir(store.folder, String(entry.storeKey)*".dat"))
3838
if n_entries > 1
3939
error("Could not find unique file for key '$(entry.storeKey)'.")
@@ -49,7 +49,7 @@ function updateDataBlob!(store::FileDataStore, entry::AbstractBigDataEntry, data
4949
end
5050
end
5151

52-
function deleteDataBlob!(store::FileDataStore, entry::AbstractBigDataEntry)::Vector{UInt8}
52+
function deleteDataBlob!(store::FileDataStore, entry::AbstractDataEntry)::Vector{UInt8}
5353
data = getDataBlob(store, entry)
5454
data == nothing && return nothing
5555
rm(filename(store, entry))
@@ -58,6 +58,6 @@ end
5858

5959
# TODO: Manifest file
6060
#
61-
# function listDataBlobs(store::FileDataStore)::Vector{E} where {E <: AbstractBigDataEntry}
61+
# function listDataBlobs(store::FileDataStore)::Vector{E} where {E <: AbstractDataEntry}
6262
# return collect(values(store.entries))
6363
# end
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
##==============================================================================
22
## InMemoryDataStore CRUD
33
##==============================================================================
4-
function getDataBlob(store::InMemoryDataStore{T, E}, entry::E)::Union{T, Nothing} where {T, E <: AbstractBigDataEntry}
4+
function getDataBlob(store::InMemoryDataStore{T, E}, entry::E)::Union{T, Nothing} where {T, E <: AbstractDataEntry}
55
!haskey(store.data, entry.storeKey) && return nothing
66
return store.data[entry.storeKey]
77
end
88

9-
function addDataBlob!(store::InMemoryDataStore{T, E}, entry::E, data::T)::T where {T, E <: AbstractBigDataEntry}
9+
function addDataBlob!(store::InMemoryDataStore{T, E}, entry::E, data::T)::T where {T, E <: AbstractDataEntry}
1010
haskey(store.entries, entry.storeKey) && @warn "Key '$(entry.storeKey)' already exists in the data store, overwriting!"
1111
store.entries[entry.storeKey] = entry
1212
# Update timestamp
1313
entry.lastUpdatedTimestamp = now()
1414
return store.data[entry.storeKey] = data
1515
end
1616

17-
function updateDataBlob!(store::InMemoryDataStore{T, E}, entry::E, data::T)::Union{T, Nothing} where {T, E <: AbstractBigDataEntry}
17+
function updateDataBlob!(store::InMemoryDataStore{T, E}, entry::E, data::T)::Union{T, Nothing} where {T, E <: AbstractDataEntry}
1818
!haskey(store.entries, entry.storeKey) && (@error "Key '$(entry.storeKey)' doesn't exist in the data store!"; return nothing)
1919
store.entries[entry.storeKey] = entry
2020
# Update timestamp
2121
entry.lastUpdatedTimestamp = now()
2222
return store.data[entry.storeKey] = data
2323
end
2424

25-
function deleteDataBlob!(store::InMemoryDataStore{T, E}, entry::E)::T where {T, E <: AbstractBigDataEntry}
25+
function deleteDataBlob!(store::InMemoryDataStore{T, E}, entry::E)::T where {T, E <: AbstractDataEntry}
2626
data = getDataBlob(store, entry)
2727
data == nothing && return nothing
2828
delete!(store.data, entry.storeKey)
2929
delete!(store.entries, entry.storeKey)
3030
return data
3131
end
3232

33-
function listDataBlobs(store::InMemoryDataStore{T, E})::Vector{E} where {T, E <: AbstractBigDataEntry}
33+
function listDataBlobs(store::InMemoryDataStore{T, E})::Vector{E} where {T, E <: AbstractDataEntry}
3434
return collect(values(store.entries))
3535
end

src/CloudGraphsDFG/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import ...DistributedFactorGraphs: setSolverParams!,
3939
_getDuplicatedEmptyDFG,
4040
toDot,
4141
toDotFile,
42-
AbstractBigDataEntry,
42+
AbstractDataEntry,
4343
isValidLabel,
4444
_invalidIds,#TODO Export from DFG
4545
_validLabelRegex, #TODO Export from DFG

0 commit comments

Comments
 (0)