Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,30 @@ function solveGraphParametric! end

# delta timestamps
calcDeltatime(from::Nanosecond, to::Nanosecond) = Dates.value(to - from) / 10^9

function calcDeltatime_ns(from::TimeDateZone, to::TimeDateZone)
# TODO (-)(x::TimeDateZone, y::TimeDateZone) was very slow so manually calculated here
# return Dates.value(convert(Nanosecond, to - from)) / 10^9
# calculate the "fast part" (microsecond) of the delta timestamp in nanoseconds
fast_to = convert(Nanosecond, Microsecond(to)) + Nanosecond(to)
fast_from = convert(Nanosecond, Microsecond(from)) + Nanosecond(from)
delta_fast = fast_to - fast_from
# calculate the "slow part" (zoned date time) of the delta timestamp in nanoseconds
delta_zoned = convert(Nanosecond, ZonedDateTime(to) - ZonedDateTime(from))
return delta_zoned + delta_fast
end

function calcDeltatime(from::TimeDateZone, to::TimeDateZone)
return Dates.value(convert(Nanosecond, to - from)) / 10^9
# TODO (-)(x::TimeDateZone, y::TimeDateZone) was very slow so manually calculated here
# return Dates.value(convert(Nanosecond, to - from)) / 10^9
return Dates.value(calcDeltatime_ns(from, to)) / 10^9
end

calcDeltatime(from_node, to_node) = calcDeltatime(from_node.timestamp, to_node.timestamp)

Timestamp(args...) = TimeDateZone(args...)
Timestamp(t::Nanosecond, zone = tz"UTC") = Timestamp(Val(:unix), t, zone)
Timestamp(t::Microsecond, zone = tz"UTC") = Timestamp(Val(:unix), Nanosecond(t), zone)
function Timestamp(epoch::Val{:unix}, t::Nanosecond, zone = tz"UTC")
return TimeDateZone(TimeDate(1970) + t, zone)
end
Expand Down
4 changes: 2 additions & 2 deletions src/DataBlobs/entities/BlobEntry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ function Blobentry(
size::Int64 = entry.size,
origin::String = entry.origin,
description::String = entry.description,
mimetype::String = entry.mimetype,
mimetype::MIME = entry.mimetype,
metadata::JSONText = entry.metadata,
timestamp::ZonedDateTime = entry.timestamp,
timestamp::TimeDateZone = entry.timestamp,
version = entry.version,
)
return Blobentry(;
Expand Down
20 changes: 10 additions & 10 deletions src/DataBlobs/services/BlobStores.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ end
FolderStore(label::Symbol, folder::String) = FolderStore{Vector{UInt8}}(label, folder)

function FolderStore(foldername::String; label::Symbol = :default, createfolder = true)
storepath = joinpath(foldername, string(label))
storepath = expanduser(joinpath(foldername, string(label)))
if createfolder && !isdir(storepath)
@info "Folder '$storepath' doesn't exist - creating."
# create new folder
Expand All @@ -134,11 +134,11 @@ function FolderStore(foldername::String; label::Symbol = :default, createfolder
end

function blobfilename(store::FolderStore, blobid::UUID)
return joinpath(store.folder, string(store.label), string(blobid))
return expanduser(joinpath(store.folder, string(store.label), string(blobid)))
end

function getBlob(store::FolderStore{T}, blobid::UUID) where {T}
blobfilename = joinpath(store.folder, string(store.label), string(blobid))
blobfilename = expanduser(joinpath(store.folder, string(store.label), string(blobid)))
tombstonefile = blobfilename * ".deleted"
if isfile(tombstonefile)
throw(IdNotFoundError("Blob (deleted)", blobid))
Expand All @@ -152,7 +152,7 @@ function getBlob(store::FolderStore{T}, blobid::UUID) where {T}
end

function addBlob!(store::FolderStore{T}, blobid::UUID, data::T) where {T}
blobfilename = joinpath(store.folder, string(store.label), string(blobid))
blobfilename = expanduser(joinpath(store.folder, string(store.label), string(blobid)))
if isfile(blobfilename)
throw(IdExistsError("Blob", blobid))
else
Expand All @@ -165,7 +165,7 @@ end

function deleteBlob!(store::FolderStore{T}, blobid::UUID) where {T}
# Tombstone pattern: instead of deleting the file, create a tombstone marker file
blobfilename = joinpath(store.folder, string(store.label), string(blobid))
blobfilename = expanduser(joinpath(store.folder, string(store.label), string(blobid)))
tombstonefile = blobfilename * ".deleted"
if isfile(blobfilename)
# Remove the actual blob file
Expand All @@ -185,14 +185,14 @@ function deleteBlob!(store::FolderStore{T}, blobid::UUID) where {T}
end

function hasBlob(store::FolderStore, blobid::UUID)
blobfilename = joinpath(store.folder, string(store.label), string(blobid))
blobfilename = expanduser(joinpath(store.folder, string(store.label), string(blobid)))
return isfile(blobfilename)
end

hasBlob(store::FolderStore, entry::Blobentry) = hasBlob(store, entry.blobid)

function listBlobs(store::FolderStore)
folder = joinpath(store.folder, string(store.label))
folder = expanduser(joinpath(store.folder, string(store.label)))
# Parse folder to only include UUIDs automatically excluding tombstone files this way.
blobids = UUID[]
for filename in readdir(folder)
Expand Down Expand Up @@ -249,11 +249,11 @@ listBlobs(store::InMemoryBlobstore) = collect(keys(store.blobs))
##==============================================================================
## LinkStore Link blobid to a existing local folder
##==============================================================================

struct LinkStore <: AbstractBlobstore{String}
#TODO consider using a deterministic blobid (uuid5) with ns stored in the csv?
@tags struct LinkStore <: AbstractBlobstore{String}
label::Symbol
csvfile::String
cache::Dict{UUID, String}
cache::Dict{UUID, String} & (json = (ignore = true,),)

function LinkStore(label, csvfile)
if !isfile(csvfile)
Expand Down
7 changes: 7 additions & 0 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,10 @@ end
args...;
kwargs...,
)

function getVariable(dfg::AbstractDFG, label::Symbol, stateLabel::Symbol)
Base.depwarn("getVariable with stateLabel is deprecated", :getVariable)
#TODO DFG v1.x will maybe use getVariable(dfg, label; stateLabelFilter) instead.
return getVariable(dfg, label)
# return getVariable(dfg, label; stateLabelFilter = ==(stateLabel))
end
Loading
Loading