Skip to content

Error with handling variable length data (H5T_VLEN) #99

@janblumenkamp

Description

@janblumenkamp

I have a dataset that was created with h5py and which contains variable length data (utilizing the H5T_VLEN type). The python script I used to generate it:

import numpy as np
import h5py

with h5py.File('testdata.hdf5', 'a') as hdf:
  if 'real' in hdf:
    del hdf['real']
  
  hdf_group = hdf.create_group('real')
  hdf_labels = hdf_group.create_dataset('labels', (3,), h5py.special_dtype(vlen = np.uint8))
  
  for i in range(3):
    labels = np.empty(i + 1, np.uint8)
    for j in range(i + 1):
      labels[j] = j
    hdf_labels[i] = labels

The output of h5dump:

HDF5 "testdata.hdf5" {
GROUP "/" {
   GROUP "real" {
      DATASET "labels" {
         DATATYPE  H5T_VLEN { H5T_STD_U8LE}
         DATASPACE  SIMPLE { ( 3 ) / ( 3 ) }
         DATA {
         (0): (0), (0, 1), (0, 1, 2)
         }
      }
   }
}
}

Reading the generated HDF file in JS:

const hdf5 = require('hdf5').hdf5;
const h5tb = require('hdf5').h5tb;

var Access = require('hdf5/lib/globals').Access;
var file = new hdf5.File('testdata.hdf5', Access.ACC_READ);
var group = file.openGroup('real');
var readBuffer=h5tb.getTableInfo(group.id, 'labels');
console.log(readBuffer);

And the output:

HDF5-DIAG: Error detected in HDF5 (1.10.4) thread 0:
  #000: H5Tfields.c line 63 in H5Tget_nmembers(): cannot return member number
    major: Invalid arguments to routine
    minor: Inappropriate type
  #001: H5Tfields.c line 104 in H5T_get_nmembers(): operation not supported for type class
    major: Invalid arguments to routine
    minor: Inappropriate type
{ nfields: 1213911376, nrecords: -781860838 }

where the numbers in the last line are different every time.
What is the problem? I would be surprised if H5T_VLEN is not implemented, as it should also be used for strings?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions