|
15 | 15 | function ==(a::FileBigDataEntry, b::FileBigDataEntry)
|
16 | 16 | return a.key == b.key && a.filename == b.filename
|
17 | 17 | end
|
| 18 | + |
| 19 | +""" |
| 20 | + $(SIGNATURES) |
| 21 | +Add Big Data Entry to a DFG variable |
| 22 | +""" |
| 23 | +function addBigDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)::AbstractBigDataEntry |
| 24 | + haskey(var.bigData,bde.key) && error("BigData entry $(bde.key) already exists in variable") |
| 25 | + var.bigData[bde.key] = bde |
| 26 | + return bde |
| 27 | +end |
| 28 | + |
| 29 | +""" |
| 30 | + $(SIGNATURES) |
| 31 | +Add Big Data Entry to distributed factor graph. |
| 32 | +Should be extended if DFG variable is not returned by reference. |
| 33 | +""" |
| 34 | +function addBigDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)::AbstractBigDataEntry |
| 35 | + return addBigDataEntry!(getVariable(dfg, label), bde) |
| 36 | +end |
| 37 | + |
| 38 | +""" |
| 39 | + $(SIGNATURES) |
| 40 | +Get big data entry |
| 41 | +""" |
| 42 | +function getBigDataEntry(var::AbstractDFGVariable, key::Symbol)::Union{Nothing, AbstractBigDataEntry} |
| 43 | + !haskey(var.bigData, key) && (error("BigData entry $(key) does not exist in variable"); return nothing) |
| 44 | + return var.bigData[key] |
| 45 | +end |
| 46 | + |
| 47 | +function getBigDataEntry(dfg::AbstractDFG, label::Symbol, key::Symbol)::Union{Nothing, AbstractBigDataEntry} |
| 48 | + return getBigDataEntry(getVariable(dfg, label), key) |
| 49 | +end |
| 50 | + |
| 51 | +""" |
| 52 | + $(SIGNATURES) |
| 53 | +Update big data entry |
| 54 | +""" |
| 55 | +function updateBigDataEntry!(var::AbstractDFGVariable, bde::AbstractBigDataEntry)::Union{Nothing, AbstractBigDataEntry} |
| 56 | + !haskey(var.bigData,bde.key) && (@warn "$(bde.key) does not exist in variable, adding") |
| 57 | + var.bigData[bde.key] = bde |
| 58 | + return bde |
| 59 | +end |
| 60 | +function updateBigDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractBigDataEntry)::Union{Nothing, AbstractBigDataEntry} |
| 61 | + # !isVariable(dfg, label) && return nothing |
| 62 | + return updateBigDataEntry!(getVariable(dfg, label), bde) |
| 63 | +end |
| 64 | + |
| 65 | +""" |
| 66 | + $(SIGNATURES) |
| 67 | +Delete big data entry from the factor graph. |
| 68 | +Note this doesn't remove it from any data stores. |
| 69 | +""" |
| 70 | +function deleteBigDataEntry!(var::AbstractDFGVariable, key::Symbol)::Union{Nothing, AbstractDFGVariable} #users responsibility to delete big data in db before deleting entry |
| 71 | + bde = getBigDataEntry(var, key) |
| 72 | + bde == nothing && return nothing |
| 73 | + delete!(var.bigData, key) |
| 74 | + return var |
| 75 | +end |
| 76 | +function deleteBigDataEntry!(dfg::AbstractDFG, label::Symbol, key::Symbol)::Union{Nothing, AbstractDFGVariable} #users responsibility to delete big data in db before deleting entry |
| 77 | + !isVariable(dfg, label) && return nothing |
| 78 | + return deleteBigDataEntry!(getVariable(dfg, label), key) |
| 79 | +end |
| 80 | + |
| 81 | +function deleteBigDataEntry!(var::AbstractDFGVariable, entry::AbstractBigDataEntry)::Union{Nothing, AbstractDFGVariable} #users responsibility to delete big data in db before deleting entry |
| 82 | + return deleteBigDataEntry!(var, entry.key) |
| 83 | +end |
| 84 | + |
| 85 | +""" |
| 86 | + $(SIGNATURES) |
| 87 | +Get big data entries, Vector{AbstractBigDataEntry} |
| 88 | +""" |
| 89 | +function getBigDataEntries(var::AbstractDFGVariable)::Vector{AbstractBigDataEntry} |
| 90 | + #or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBigDataEntry}}? |
| 91 | + collect(values(var.bigData)) |
| 92 | +end |
| 93 | +function getBigDataEntries(dfg::AbstractDFG, label::Symbol)::Union{Nothing, Vector{AbstractBigDataEntry}} |
| 94 | + !isVariable(dfg, label) && return nothing |
| 95 | + #or should we return the iterator, Base.ValueIterator{Dict{Symbol,AbstractBigDataEntry}}? |
| 96 | + getBigDataEntries(getVariable(dfg, label)) |
| 97 | +end |
| 98 | + |
| 99 | + |
| 100 | +""" |
| 101 | + $(SIGNATURES) |
| 102 | +getBigDataKeys |
| 103 | +""" |
| 104 | +function getBigDataKeys(var::AbstractDFGVariable)::Vector{Symbol} |
| 105 | + collect(keys(var.bigData)) |
| 106 | +end |
| 107 | +function getBigDataKeys(dfg::AbstractDFG, label::Symbol)::Union{Nothing, Vector{Symbol}} |
| 108 | + !isVariable(dfg, label) && return nothing |
| 109 | + getBigDataKeys(getVariable(dfg, label)) |
| 110 | +end |
0 commit comments