HDF5 API를 사용하고 있으며 가변 길이 문자열로 데이터 집합을 만들려고합니다. I 정적 하드 코딩 된 크기를 사용 하였다 char[256]
HDF5 : 문자열이있는 데이터 집합 만들기
struct dataX
{
std::string data;
};
구조체이다.
하지만 나는 HDF5 Doc를 읽은 후 동적이기를 바란다. 나는 H5T_VARIABLE
을 찾았고 다음과 같이 사용했다. 그러나 여전히 실패한다.
H5Dcreate
은 음수 값 (오류)을 반환합니다.
hid_t mem_type;
mem_type = H5Tcopy(H5T_C_S1);
H5Tset_size(mem_type,H5T_VARIABLE);
/* Create the memory data type. */
if ((mem_type_id = H5Tcreate (H5T_COMPOUND, mem_type)) < 0) {
return -1;
}
/* Insert fields. */
if (H5Tinsert(mem_type_id, "field", 0, mem_type_id) < 0) {
return -1;
}
/* Create a simple data space with unlimited size */
// hsize_t dims[1]={0};
// hsize_t maxdimsk[1]={ H5S_UNLIMITED };
if ((sid = H5Screate_simple(1, dims, maxdims)) < 0){
return -1;
}
/* Modify dataset creation properties, i.e. enable chunking */
plist_id = H5Pcreate (H5P_DATASET_CREATE);
//chunk==1
if (H5Pset_chunk (plist_id, 1, chunk) < 0){
return -1;
}
H5Pset_alloc_time(plist_id, H5D_ALLOC_TIME_EARLY)
/* Set the fill value using a struct as the data type. */
// fill_data=0
if (fill_data)
{
if (H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0){
LOG_ERROR << "cannot fill value " << LOG_ENDL;
return -1;
}
}
else {
if (H5Pset_fill_time(plist_id, H5D_FILL_TIME_NEVER) < 0) {
LOG_ERROR << "error" << LOG_ENDL;
}
}
/* Create the dataset. */
did = H5Dcreate(loc_id, dset_name, mem_type_id, sid, plist_id)
는 어쩌면 경우가 그저 잘되기를 쓰기 전에 메모리를 할당하지만 ... 그것을하지 않았다 생각,
H5D_ALLOC_TIME_LATE
했습니다.
이제 막혔어. 어떻게해야할지 모르겠다.
내가 뭔가를 놓쳤습니까?