Hi, i am trying create a compound dataset that uses variable length data as shown in the last 2 columns here:
For testing I tried to create a simple compound dataset having only one “column” of variable length 32-bit integers. I used this test
@Test
public void testCompoundDataSetIntVariableLength() throws Exception{
String fileName = "./test.h5";
FileFormat fileFormat = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5);
H5File file = (H5File) fileFormat.createFile(fileName, FileFormat.FILE_CREATE_DELETE);
// This is the total amount of entries for each type in the compound
int DIM_SIZE = 2;
String message = "";
Group pgroup = null;
// We set the dimensions we want to store the data in - the product of all values has to be the dimension size
long[] DIMs = { DIM_SIZE, 1 };
// Chunks the data is stored in
long[] CHUNKs = { 1, 1 };
// We create dummy arrays with default values
int[] array1 = new int[]{1,2};
int[] array2 = new int[]{1,2,3,4};
// Set up the data object
Vector<Object> data = new Vector<>();
data.add(array1);
data.add(array2);
//int[][] array = new int[][]{array1,array2};
//data.add(array);
// create groups
String[] mnames = { "int" };
H5Datatype intValueDataType = (H5Datatype)file.createDatatype(Datatype.CLASS_INTEGER, 4, Datatype.NATIVE, Datatype.NATIVE);
H5Datatype intValLengthDataType = (H5Datatype)file.createDatatype(Datatype.CLASS_VLEN, Datatype.NATIVE, Datatype.NATIVE, Datatype.NATIVE,intValueDataType);
Datatype[] mdtypes = new H5Datatype[1];
mdtypes[0] = intValLengthDataType;
int[] msizes = new int[]{1};
Dataset dset = file.createCompoundDS("/CompoundDS", pgroup, DIMs, null, CHUNKs, 0, mnames, mdtypes, msizes, data);
}
and tried different types how to fill data
, either as several 1D arrays or one 2D array. In both cases the result is the same, I get the correct data type definition in the dataset but the data itself is empty:
I would expect that {(1,2)}
is the content of row 1 and {(1,2,3,4)}
of row 2. What am I doing wrong? Storage: SIZE:0
seems to indicate that no data was actually written to the dataset or am I wrong? I guess the behavior is somewhat similar to the one explained for Fortran in this thread.