HDF5.jl variable length string

thomaskroi1996
Sat, 13 May 2023 19:09:16 +0000
General Usage

Hello everyone!

I am currently trying to translate i python code to julia! What i am trying to do, broken down, is creating a dataset where dtype=“String”. I know that to do that in python you have to declare a special datatype from the “h5py” package, vlen.

In Julia, i first tried to use simply “String”, like so:
create_dataset(name,"my_dataset", String, (1,) ) #dt

which gave me the following error:
Type Symbol does not have a definite size.

Here is the Stacktrace:

ERROR: Type Symbol does not have a definite size.
Stacktrace:
  [1] sizeof(x::Type)
    @ Base .\essentials.jl:473
  [2] hdf5_type_id(#unused#::Type{Symbol}, isstruct::Val{true})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\typeconversions.jl:71
  [3] hdf5_type_id(#unused#::Type{Symbol})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\typeconversions.jl:69
  [4] hdf5_type_id(#unused#::Type{Core.TypeName}, isstruct::Val{true})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\typeconversions.jl:74
  [5] hdf5_type_id(#unused#::Type{Core.TypeName})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\typeconversions.jl:69
  [6] hdf5_type_id(#unused#::Type{DataType}, isstruct::Val{true})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\typeconversions.jl:74
  [7] hdf5_type_id(#unused#::Type{DataType})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\typeconversions.jl:69
  [8] datatype(#unused#::Type{String})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\typeconversions.jl:66
  [9] create_dataset(parent::HDF5.Group, path::String, dtype::Type, dspace_dims::Tuple{Int64}; pv::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\datasets.jl:103
 [10] create_dataset(parent::HDF5.Group, path::String, dtype::Type, dspace_dims::Tuple{Int64})
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\datasets.jl:103
 [11] (::var"#182#183"{result, String})(file::HDF5.File)
    @ Main c:\Users\Win10\Desktop\Arbeit\TU\work_env\read_vtk\export.jl:231
 [12] (::HDF5.var"#17#18"{HDF5.HDF5Context, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, var"#182#183"{result, String}, HDF5.File})()
    @ HDF5 C:\Users\Win10\.julia\packages\HDF5\HtnQZ\src\file.jl:98
 [13] task_local_storage(body::HDF5.var"#17#18"{HDF5.HDF5Context, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, var"#182#183"{result, String}, HDF5.File}, key::Symbol, val::HDF5.HDF5Context)
    @ Base .\task.jl:292
 [14] h5open(::var"#182#183"{result, String}, ::String, ::Vararg{String}; context::HDF5.HDF5Context, pv::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})

I tried again with the HDF5.VLen datatype that comes with the package, but had the same error.

Unfourtunately the HDF5.jl package is not very well documented when it comes to datatypes, or at least i didn’t find anyrthing.

Does somebody maybe have an idea what’s wrong here?

Thank you very much,
Thomas

11 posts - 3 participants