@@ -299,9 +299,10 @@ function _packSolverData(
299
299
packtype = convertPackedType (fnctype)
300
300
try
301
301
packed = convert ( PackedFunctionNodeData{packtype}, getSolverData (f) )
302
- packedJson = JSON2. write (packed)
302
+ packedJson = packed # JSON2.write(packed) # NOTE SINGLE TOP LEVEL JSON.write ONLY
303
303
if base64Encode
304
- # 833
304
+ # 833, 848, Neo4jDFG still using base64(JSON2.write(solverdata))...
305
+ packedJson = JSON2. write (packed)
305
306
packedJson = base64encode (packedJson)
306
307
end
307
308
return packedJson
@@ -321,13 +322,13 @@ function packFactor(dfg::AbstractDFG, f::DFGFactor)
321
322
props[" label" ] = string (f. label)
322
323
props[" timestamp" ] = Dates. format (f. timestamp, " yyyy-mm-ddTHH:MM:SS.ssszzz" )
323
324
props[" nstime" ] = string (f. nstime. value)
324
- props[" tags" ] = JSON2. write (f. tags)
325
+ props[" tags" ] = String .(f . tags) # JSON2.write(f.tags)
325
326
# Pack the node data
326
327
fnctype = getSolverData (f). fnc. usrfnc!
327
328
props[" data" ] = _packSolverData (f, fnctype)
328
329
# Include the type
329
330
props[" fnctype" ] = String (_getname (fnctype))
330
- props[" _variableOrderSymbols" ] = JSON2. write (f. _variableOrderSymbols)
331
+ props[" _variableOrderSymbols" ] = String .(f . _variableOrderSymbols) # JSON2.write(f._variableOrderSymbols)
331
332
props[" solvable" ] = getSolvable (f)
332
333
props[" _version" ] = _getDFGVersion ()
333
334
return props
@@ -347,6 +348,26 @@ function decodePackedType(dfg::AbstractDFG, varOrder::AbstractVector{Symbol}, ::
347
348
return factordata
348
349
end
349
350
351
+ function Base. convert (:: Type{PF} , nt:: NamedTuple ) where {PF <: AbstractPackedFactor }
352
+ # Here we define a convention, must provide PackedType(;kw...) constructor, easiest is just use Base.@kwdef
353
+ PF (;nt... )
354
+ end
355
+
356
+ function Base. convert (:: Type{GenericFunctionNodeData{P}} , nt:: NamedTuple ) where P
357
+ GenericFunctionNodeData {P} (
358
+ nt. eliminated,
359
+ nt. potentialused,
360
+ nt. edgeIDs,
361
+ convert (P,nt. fnc),
362
+ nt. multihypo,
363
+ nt. certainhypo,
364
+ nt. nullhypo,
365
+ nt. solveInProgress,
366
+ nt. inflation,
367
+ )
368
+ end
369
+
370
+
350
371
# Returns `::DFGFactor`
351
372
function unpackFactor (dfg:: G , packedProps:: Dict{String, Any} ) where G <: AbstractDFG
352
373
# Version checking.
@@ -367,6 +388,14 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any}) where G <: Abstrac
367
388
tags = Vector {Symbol} ()
368
389
end
369
390
end
391
+
392
+ # Get the stored variable order
393
+ _variableOrderSymbols = if packedProps[" _variableOrderSymbols" ] isa String
394
+ JSON2. read (packedProps[" _variableOrderSymbols" ], Vector{Symbol})
395
+ else
396
+ Symbol .(packedProps[" _variableOrderSymbols" ])
397
+ end
398
+
370
399
data = packedProps[" data" ]
371
400
datatype = packedProps[" fnctype" ]
372
401
@debug " DECODING factor type = '$(datatype) ' for factor '$label '"
@@ -376,15 +405,10 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any}) where G <: Abstrac
376
405
packed = nothing
377
406
fullFactorData = nothing
378
407
379
- # Get the stored variable order
380
- _variableOrderSymbols = if packedProps[" _variableOrderSymbols" ] isa String
381
- JSON2. read (packedProps[" _variableOrderSymbols" ], Vector{Symbol})
382
- else
383
- Symbol .(packedProps[" _variableOrderSymbols" ])
384
- end
385
-
408
+ # @show packtype
409
+ # @show data
386
410
try
387
- packed = JSON2. read (data, GenericFunctionNodeData{packtype})
411
+ packed = convert (GenericFunctionNodeData{packtype}, data) # JSON2.read(data, GenericFunctionNodeData{packtype})
388
412
decodeType = getFactorOperationalMemoryType (dfg)
389
413
fullFactorData = decodePackedType (dfg, _variableOrderSymbols, decodeType, packed)
390
414
catch ex
0 commit comments