This is the code to create the dataset:
// Create compound type for headers
// Variable length string for model name type
hid_t header_model_name_t = H5T.create(H5T.class_t.STRING, H5T.VARIABLE);
Debug.Assert(STRING_TYPE_SIZE == (int)H5T.get_size(header_model_name_t));
// Variable length string for message name type
hid_t header_message_name_t = H5T.create(H5T.class_t.STRING, H5T.VARIABLE);
Debug.Assert(STRING_TYPE_SIZE == (int)H5T.get_size(header_message_name_t));
// a variable-length array type
hid_t eight_bit_t = H5T.copy(H5T.NATIVE_UINT8);
hid_t header_vlba = H5T.vlen_create(eight_bit_t);
int data_payload_size = (int)H5T.get_size(header_vlba);
// Size for Model name (string), Message name (string) and variable length data
int temp_header_size = STRING_TYPE_SIZE + STRING_TYPE_SIZE + data_payload_size;
_header_kvt = H5T.create(H5T.class_t.COMPOUND, temp_header_size);
int header_offset = 0;
Check_HDF(H5T.insert(_header_kvt, “header_model_name”, header_offset, header_model_name_t));
header_offset += STRING_TYPE_SIZE;
Check_HDF(H5T.insert(_header_kvt, “header_message_name”, header_offset, header_message_name_t));
header_offset += STRING_TYPE_SIZE;
Check_HDF(H5T.insert(_header_kvt, “header_message_data”, header_offset, header_vlba));
// Fixed length timestamp type
hid_t timestamp_t = H5T.copy(H5T.IEEE_F64LE);
Debug.Assert(TIMESTAMP_SIZE == (int)H5T.get_size(timestamp_t));
// Connection type
hid_t connection_t = H5T.copy(H5T.NATIVE_INT32);
Debug.Assert(CONNECTION_SIZE == (int)H5T.get_size(connection_t));
// Variable length string for message name type
hid_t message_name_t = H5T.create(H5T.class_t.STRING, H5T.VARIABLE);
Debug.Assert(MESSAGE_NAME_SIZE == (int)H5T.get_size(message_name_t));
// Variable length string for the publisher type
hid_t publisher_t = H5T.create(H5T.class_t.STRING, H5T.VARIABLE);
Debug.Assert(MESSAGE_NAME_SIZE == (int)H5T.get_size(publisher_t));
// a variable-length array type
hid_t vlba = H5T.vlen_create(eight_bit_t);
int vl_data_size = (int)H5T.get_size(vlba);
// One dimensional array of compound types
hsize_t[] max_dims = { H5S.UNLIMITED };
hid_t header_array = H5T.array_create(_header_kvt, 1, max_dims);
Check_HDF(header_array);
Check_HDF(H5T.set_size(header_array, 32));
int header_data_size = 32; // (int)H5T.get_size(header_array);
//Check_HDF(header_data_size);
// Create compound type
int temp_size = TIMESTAMP_SIZE + CONNECTION_SIZE + MESSAGE_NAME_SIZE + PUBLISHER_SIZE + vl_data_size + (int)header_data_size;
_kvt = H5T.create(H5T.class_t.COMPOUND, temp_size);
int offset = 0;
Check_HDF(H5T.insert(_kvt, “time stamp us”, offset, timestamp_t));
offset += TIMESTAMP_SIZE;
Check_HDF(H5T.insert(_kvt, “connection”, offset, connection_t));
offset += CONNECTION_SIZE;
Check_HDF(H5T.insert(_kvt, “message_name”, offset, message_name_t));
offset += MESSAGE_NAME_SIZE;
Check_HDF(H5T.insert(_kvt, “publisher”, offset, publisher_t));
offset += PUBLISHER_SIZE;
Check_HDF(H5T.insert(_kvt, “data”, offset, vlba));
offset += (int)vl_data_size;
Check_HDF(H5T.insert(_kvt, “headers”, offset, header_array));