Skip to content

Commit b0206f9

Browse files
authored
Merge pull request #285 from JuliaRobotics/1Q20/cgdfg_ppes
Efficient calls for PPEs (and general transaction pattern) for CGDFG
2 parents 3301d4f + ec31529 commit b0206f9

File tree

10 files changed

+436
-486
lines changed

10 files changed

+436
-486
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1010
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1111
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
1212
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
13+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1314
JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
1415
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
1516
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1617
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
1718
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1819
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1920
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
21+
Unmarshal = "cbff2730-442d-58d7-89d1-8e530c41eb02"
2022

2123
[compat]
2224
Colors = "0.8, 0.9, 0.10, 0.11"

src/CloudGraphsDFG/CloudGraphsDFG.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ include("services/CloudGraphsDFG.jl")
1212

1313
# Exports
1414
export Neo4jInstance, CloudGraphsDFG
15-
export toDot, toDotFile
1615

1716
# Additional exports for CGStructure
1817
export copySession!

src/CloudGraphsDFG/entities/CloudGraphsDFG.jl

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,55 @@ end
77

88
mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG
99
neo4jInstance::Neo4jInstance
10-
description::String
1110
userId::String
1211
robotId::String
1312
sessionId::String
1413
encodePackedTypeFunc
1514
getPackedTypeFunc
1615
decodePackedTypeFunc
1716
rebuildFactorMetadata!
18-
labelDict::Dict{Symbol, Int64}
19-
addHistory::Vector{Symbol} #TODO: Discuss more - is this an audit trail?
17+
addHistory::Vector{Symbol}
2018
solverParams::T # Solver parameters
2119
end
2220

21+
"""
22+
$(SIGNATURES)
23+
Create a new CloudGraphs-based DFG factor graph using a Neo4j.Connection.
24+
"""
25+
function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection,
26+
userId::String,
27+
robotId::String,
28+
sessionId::String,
29+
encodePackedTypeFunc,
30+
getPackedTypeFunc,
31+
decodePackedTypeFunc,
32+
rebuildFactorMetadata!;
33+
solverParams::T=NoSolverParams()) where T <: AbstractParams
34+
graph = Neo4j.getgraph(neo4jConnection)
35+
neo4jInstance = Neo4jInstance(neo4jConnection, graph)
36+
return CloudGraphsDFG{T}(neo4jInstance, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, Symbol[], solverParams)
37+
end
38+
"""
39+
$(SIGNATURES)
40+
Create a new CloudGraphs-based DFG factor graph by specifying the Neo4j connection information.
41+
"""
42+
function CloudGraphsDFG{T}(host::String,
43+
port::Int,
44+
dbUser::String,
45+
dbPassword::String,
46+
userId::String,
47+
robotId::String,
48+
sessionId::String,
49+
encodePackedTypeFunc,
50+
getPackedTypeFunc,
51+
decodePackedTypeFunc,
52+
rebuildFactorMetadata!;
53+
solverParams::T=NoSolverParams()) where T <: AbstractParams
54+
neo4jConnection = Neo4j.Connection(host, port=port, user=dbUser, password=dbPassword);
55+
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, solverParams=solverParams)
56+
end
57+
58+
2359
function show(io::IO, c::CloudGraphsDFG)
2460
println(io, "CloudGraphsDFG:")
2561
println(io, " - Neo4J instance: $(c.neo4jInstance.connection.host)")

src/CloudGraphsDFG/services/CGStructure.jl

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ function clearSession!!(dfg::CloudGraphsDFG)::Nothing
235235

236236
# Clearing history
237237
dfg.addHistory = Symbol[]
238-
empty!(dfg.labelDict)
239238
return nothing
240239
end
241240

@@ -249,7 +248,6 @@ function clearRobot!!(dfg::CloudGraphsDFG)::Nothing
249248

250249
# Clearing history
251250
dfg.addHistory = Symbol[]
252-
empty!(dfg.labelDict)
253251
return nothing
254252
end
255253

@@ -263,7 +261,6 @@ function clearUser!!(dfg::CloudGraphsDFG)::Nothing
263261

264262
# Clearing history
265263
dfg.addHistory = Symbol[]
266-
empty!(dfg.labelDict)
267264
return nothing
268265
end
269266

@@ -284,29 +281,3 @@ end
284281
DANGER: Copies the source to a new unique destination.
285282
"""
286283
copySession!(sourceDFG::CloudGraphsDFG)::CloudGraphsDFG = copySession!(sourceDFG, nothing)
287-
288-
289-
function getUserData(dfg::CloudGraphsDFG)::Dict{Symbol, String}
290-
propVal = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, "USER"], "data")
291-
return JSON2.read(String(base64decode(propVal)), Dict{Symbol, String})
292-
end
293-
function setUserData!(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool
294-
count = _setNodeProperty(dfg.neo4jInstance, [dfg.userId, "USER"], "data", base64encode(JSON2.write(data)))
295-
return count == 1
296-
end
297-
function getRobotData(dfg::CloudGraphsDFG)::Dict{Symbol, String}
298-
propVal = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, "ROBOT"], "data")
299-
return JSON2.read(String(base64decode(propVal)), Dict{Symbol, String})
300-
end
301-
function setRobotData!(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool
302-
count = _setNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, "ROBOT"], "data", base64encode(JSON2.write(data)))
303-
return count == 1
304-
end
305-
function getSessionData(dfg::CloudGraphsDFG)::Dict{Symbol, String}
306-
propVal = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, dfg.sessionId, "SESSION"], "data")
307-
return JSON2.read(String(base64decode(propVal)), Dict{Symbol, String})
308-
end
309-
function setSessionData!(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool
310-
count = _setNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, dfg.sessionId, "SESSION"], "data", base64encode(JSON2.write(data)))
311-
return count == 1
312-
end

0 commit comments

Comments
 (0)