Skip to content

Commit 974b3d4

Browse files
committed
Minor cleanup
1 parent 1bda3ab commit 974b3d4

File tree

4 files changed

+26
-39
lines changed

4 files changed

+26
-39
lines changed

src/BigData/BigData.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include("entities/InMemoryDataStore.jl")
44
include("entities/FileDataStore.jl")
55

66
include("services/AbstractDataStore.jl")
7+
include("services/AbstractBigDataEntries.jl")
78
include("services/InMemoryDataStore.jl")
89
include("services/FileDataStore.jl")
910

src/BigData/entities/AbstractBigDataEntries.jl

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,35 @@
1-
import Base: ==
2-
31
"""
42
$(TYPEDEF)
53
GeneralBigDataEntry is a generic multipurpose data entry that creates a unique
64
reproducible key using userId_robotId_sessionId_variableId_key.
75
"""
86
mutable struct GeneralBigDataEntry <: AbstractBigDataEntry
97
key::Symbol
10-
storeKey::Symbol # Could swap this to string, but using it as an index later, it's better as a symbol I believe.
8+
storeKey::Symbol # Could swap this to string, but using it as an index later, so better as a symbol I believe.
119
createdTimestamp::DateTime
1210
lastUpdatedTimestamp::DateTime
1311
mimeType::String
1412
end
1513

16-
## TODO: Move this
17-
function ==(a::GeneralBigDataEntry, b::GeneralBigDataEntry)
18-
return a.key == b.key &&
19-
a.storeKey == b.storeKey &&
20-
a.mimeType == b.mimeType &&
21-
Dates.value(a.createdTimestamp - b.createdTimestamp) < 1000 &&
22-
Dates.value(a.lastUpdatedTimestamp - b.lastUpdatedTimestamp) < 1000 #1 second
23-
end
24-
25-
26-
# Clean up and move this.
2714
"""
2815
$(SIGNATURES)
29-
Generates a unique key for the entry - userId_robotId_sessionId_variable_key.
16+
Internal function to generate a unique key for the entry - userId_robotId_sessionId_variable_key.
3017
Simple symbol.
3118
"""
32-
function uniqueKey(dfg::G, v::V, key::Symbol)::Symbol where {G <: AbstractDFG, V <: AbstractDFGVariable}
19+
function _uniqueKey(dfg::G, v::V, key::Symbol)::Symbol where {G <: AbstractDFG, V <: AbstractDFGVariable}
3320
key = join(String.([dfg.userId, dfg.robotId, dfg.sessionId, label(v), String(key)]), "_")
3421
return Symbol(key)
3522
end
3623

37-
GeneralBigDataEntry(key::Symbol,
38-
storeKey::Symbol;
24+
GeneralBigDataEntry(key::Symbol, storeKey::Symbol;
3925
mimeType::String="application/octet-stream") =
40-
GeneralBigDataEntry(key, storeKey, now(), now(), mimeType)
26+
GeneralBigDataEntry(key, storeKey, now(), now(), mimeType)
4127

42-
function GeneralBigDataEntry(dfg::G,
43-
var::V,
44-
key::Symbol;
28+
function GeneralBigDataEntry(dfg::G, var::V, key::Symbol;
4529
mimeType::String="application/octet-stream") where {G <: AbstractDFG, V <: AbstractDFGVariable}
46-
return GeneralBigDataEntry(key,
47-
uniqueKey(dfg, var, key),
48-
mimeType=mimeType)
30+
return GeneralBigDataEntry(key, _uniqueKey(dfg, var, key), mimeType=mimeType)
4931
end
5032

51-
# Types <: AbstractBigDataEntry
5233
"""
5334
$(TYPEDEF)
5435
BigDataEntry in MongoDB.
@@ -61,7 +42,6 @@ struct MongodbBigDataEntry <: AbstractBigDataEntry
6142
#MIMEType::Symbol
6243
end
6344

64-
6545
"""
6646
$(TYPEDEF)
6747
BigDataEntry in a file.

src/BigData/entities/FileDataStore.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,8 @@ struct FileDataStore <: AbstractDataStore{UInt8}
77
FileDataStore(folder::String) = begin
88
if !isdir(folder)
99
@warn "Folder '$folder' doesn't exist - creating."
10-
mkpath(folder)
10+
mkpath(folder)
1111
end
1212
return new(folder)
1313
end
1414
end
15-
#
16-
# """
17-
# $(SIGNATURES)
18-
# Create a file data store using a specific data type.
19-
# """
20-
# function FileDataStore(folder::String)
21-
# if !isdir(folder)
22-
# @warn "Folder '$folder' doesn't exist - creating."
23-
# end
24-
# return FileDataStore(folder)
25-
# end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Base: ==
2+
3+
function ==(a::GeneralBigDataEntry, b::GeneralBigDataEntry)
4+
return a.key == b.key &&
5+
a.storeKey == b.storeKey &&
6+
a.mimeType == b.mimeType &&
7+
Dates.value(a.createdTimestamp - b.createdTimestamp) < 1000 &&
8+
Dates.value(a.lastUpdatedTimestamp - b.lastUpdatedTimestamp) < 1000 #1 second
9+
end
10+
11+
function ==(a::MongodbBigDataEntry, b::MongodbBigDataEntry)
12+
return a.key == b.key && a.oid == b.oid
13+
end
14+
15+
function ==(a::FileBigDataEntry, b::FileBigDataEntry)
16+
return a.key == b.key && a.filename == b.filename
17+
end

0 commit comments

Comments
 (0)