Skip to content

Commit 94a7aa5

Browse files
committed
Adding in callback for factor metadata rebuild
1 parent 759e590 commit 94a7aa5

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/CloudGraphsDFG/entities/CloudGraphsDFG.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG
1414
encodePackedTypeFunc
1515
getPackedTypeFunc
1616
decodePackedTypeFunc
17+
rebuildFactorMetadata!
1718
labelDict::Dict{Symbol, Int64}
1819
variableCache::Dict{Symbol, DFGVariable}
1920
factorCache::Dict{Symbol, DFGFactor}
@@ -23,8 +24,8 @@ mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG
2324
end
2425

2526
function show(io::IO, c::CloudGraphsDFG)
26-
println("CloudGraphsDFG:")
27-
println(" - Neo4J instance: $(c.neo4jInstance.connection.host)")
28-
println(" - Session: $(c.userId):$(c.robotId):$(c.sessionId)")
29-
println(" - Caching: $(c.useCache)")
27+
println(io, "CloudGraphsDFG:")
28+
println(io, " - Neo4J instance: $(c.neo4jInstance.connection.host)")
29+
println(io, " - Session: $(c.userId):$(c.robotId):$(c.sessionId)")
30+
println(io, " - Caching: $(c.useCache)")
3031
end

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ end
4141
$(SIGNATURES)
4242
Create a new CloudGraphs-based DFG factor graph using a Neo4j.Connection.
4343
"""
44-
function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection, userId::String, robotId::String, sessionId::String, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc; description::String="CloudGraphs DFG", solverParams::T=NoSolverParams(), useCache::Bool=false) where T <: AbstractParams
44+
function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection, userId::String, robotId::String, sessionId::String, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!; description::String="CloudGraphs DFG", solverParams::T=NoSolverParams(), useCache::Bool=false) where T <: AbstractParams
4545
graph = Neo4j.getgraph(neo4jConnection)
4646
neo4jInstance = Neo4jInstance(neo4jConnection, graph)
47-
return CloudGraphsDFG{T}(neo4jInstance, description, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, Dict{Symbol, Int64}(), Dict{Symbol, DFGVariable}(), Dict{Symbol, DFGFactor}(), Symbol[], solverParams, useCache)
47+
return CloudGraphsDFG{T}(neo4jInstance, description, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, Dict{Symbol, Int64}(), Dict{Symbol, DFGVariable}(), Dict{Symbol, DFGFactor}(), Symbol[], solverParams, useCache)
4848
end
4949
"""
5050
$(SIGNATURES)
5151
Create a new CloudGraphs-based DFG factor graph by specifying the Neo4j connection information.
5252
"""
53-
function CloudGraphsDFG{T}(host::String, port::Int, dbUser::String, dbPassword::String, userId::String, robotId::String, sessionId::String, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc; description::String="CloudGraphs DFG", solverParams::T=NoSolverParams(), useCache::Bool=false) where T <: AbstractParams
53+
function CloudGraphsDFG{T}(host::String, port::Int, dbUser::String, dbPassword::String, userId::String, robotId::String, sessionId::String, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!; description::String="CloudGraphs DFG", solverParams::T=NoSolverParams(), useCache::Bool=false) where T <: AbstractParams
5454
neo4jConnection = Neo4j.Connection(host, port=port, user=dbUser, password=dbPassword);
55-
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, description=description, solverParams=solverParams, useCache=useCache)
55+
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, description=description, solverParams=solverParams, useCache=useCache)
5656
end
5757

5858
"""
@@ -323,10 +323,10 @@ function getFactor(dfg::CloudGraphsDFG, factorId::Int64)::DFGFactor
323323

324324
data = props["data"]
325325
datatype = props["fnctype"]
326-
fulltype = getfield(Main, Symbol(datatype))
326+
# fulltype = getfield(Main, Symbol(datatype))
327327
packtype = getfield(Main, Symbol("Packed"*datatype))
328328
packed = JSON2.read(data, GenericFunctionNodeData{packtype,String})
329-
fullFactor = dfg.decodePackedTypeFunc(packed, "")
329+
fullFactor = dfg.decodePackedTypeFunc(dfg, packed)
330330

331331
# Include the type
332332
_variableOrderSymbols = JSON2.read(props["_variableOrderSymbols"], Vector{Symbol})
@@ -341,6 +341,9 @@ function getFactor(dfg::CloudGraphsDFG, factorId::Int64)::DFGFactor
341341
factor.ready = ready
342342
factor.backendset = backendset
343343

344+
# Lastly, rebuild the metadata
345+
factor = dfg.rebuildFactorMetadata!(dfg, factor)
346+
344347
# Add to cache
345348
push!(dfg.factorCache, factor.label=>factor)
346349

src/entities/DFGFactor.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ mutable struct DFGFactor{T, S} <: DFGNode
4343
DFGFactor{T, S}(label::Symbol, _internalId::Int64) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, 0, _internalId, Symbol[])
4444
end
4545

46-
# const FunctionNodeData{T} = GenericFunctionNodeData{T, Symbol}
47-
# FunctionNodeData(x1, x2, x3, x4, x5::Symbol, x6::T, x7::String="", x8::Vector{Int}=Int[]) where {T <: Union{FunctorInferenceType, ConvolutionObject}}= GenericFunctionNodeData{T, Symbol}(x1, x2, x3, x4, x5, x6, x7, x8)
48-
4946
label(f::F) where F <: DFGFactor = f.label
5047
data(f::F) where F <: DFGFactor = f.data
5148
id(f::F) where F <: DFGFactor = f._internalId

0 commit comments

Comments
 (0)