@@ -41,6 +41,14 @@ addDataEntry!(x...) = addBigDataEntry!(x...)
41
41
$(SIGNATURES)
42
42
Add Big Data Entry to distributed factor graph.
43
43
Should be extended if DFG variable is not returned by reference.
44
+
45
+ Example
46
+
47
+ See docs for `getDataEntryElement`.
48
+
49
+ Related
50
+
51
+ addData!, getDataEntryElement, fetchData
44
52
"""
45
53
function addDataEntry! (dfg:: AbstractDFG ,
46
54
lbl:: Symbol ,
@@ -51,12 +59,13 @@ function addDataEntry!(dfg::AbstractDFG,
51
59
#
52
60
node = isVariable (dfg, lbl) ? getVariable (dfg, lbl) : getFactor (dfg, lbl)
53
61
# Make a big data entry in the graph - use JSON2 to just write this
54
- element = GeneralBigDataEntry (dfg, node, descr, mimeType= mimeType)
62
+ entry = GeneralBigDataEntry (dfg, node, descr, mimeType= mimeType)
55
63
# Set it in the store
56
- addBigData! (datastore, element , data)
64
+ addBigData! (datastore, entry , data)
57
65
# Add the entry to the graph
58
- addBigDataEntry! (node, element )
66
+ addBigDataEntry! (node, entry )
59
67
end
68
+ const addData! = addDataEntry!
60
69
61
70
"""
62
71
$SIGNATURES
@@ -79,9 +88,63 @@ function getBigDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol)
79
88
return getBigDataEntry (getVariable (dfg, label), key)
80
89
end
81
90
91
+ """
92
+ $SIGNATURES
93
+ Get both the entry and raw data element from datastore returning as a tuple.
94
+
95
+ Notes:
96
+ - This is the counterpart to `addDataEntry!`.
97
+ - Data is identified by the node in the DFG object `dfglabel::Symbol` as well as `datalabel::Symbol`.
98
+ - The data should have been stored along with a `entry.mimeType::String` which describes the format of the data.
99
+ - ImageMagick.jl is useful for storing images in png or jpg compressed format.
100
+
101
+ Example
102
+
103
+ ```julia
104
+ # some dfg object
105
+ fg = initfg()
106
+ addVariable!(fg, :x0, IIF.ContinuousScalar) # using IncrementalInference
107
+ # FileDataStore (as example)
108
+ datastore = FileDataStore(joinLogPath(fg,"datastore"))
109
+
110
+ # now some data comes in
111
+ mydata = Dict(:soundBite => randn(Float32, 10000), :meta => "something about lazy foxes and fences.")
112
+
113
+ # store the data
114
+ addDataEntry!( fg, :x0, datastore, :SOUND_DATA, "application/json", Vector{UInt8}(JSON2.write( mydata )) )
115
+
116
+ # get/fetch the data
117
+
118
+ # unpack data to original format (this must be done by the user)
119
+ @show entry.mimeType # "applicatio/json"
120
+ userFormat = JSON2.read(IOBuffer(rawData))
121
+ ```
122
+
123
+ Related
124
+
125
+ addDataEntry!, addData!, fetchData, fetchDataEntryElement
126
+ """
127
+ function getDataEntryElement (dfg:: AbstractDFG , dfglabel:: Symbol , datastore:: DataStore , datalabel:: Symbol )
128
+ vari = getVariable (dfg, dfglabel)
129
+ if ! hasDataEntry (vari, datalabel)
130
+ @error " missing data entry $datalabel in $dfglabel "
131
+ return nothing , nothing
132
+ end
133
+ entry = getBigDataEntry (vari, datalabel)
134
+ element = getBigData (datastore, entry)
135
+ return entry, element
136
+ end
137
+ const fetchDataEntryElement = getDataEntryElement
138
+ const fetchData = getDataEntryElement
139
+
140
+
141
+
82
142
"""
83
143
$(SIGNATURES)
84
144
Update big data entry
145
+
146
+ DevNote
147
+ - DF, unclear if `update` verb is applicable in this case, see #404
85
148
"""
86
149
function updateBigDataEntry! (var:: AbstractDFGVariable , bde:: AbstractBigDataEntry )
87
150
! haskey (var. bigData,bde. key) && (@warn " $(bde. key) does not exist in variable, adding" )
0 commit comments