int main(){ hid_t fprop; hid_t fid; hid_t vol_id = H5VL_memvol_init(); herr_t status; hid_t g1, g2; hid_t plist; char name[1024]; fprop = H5Pcreate(H5P_FILE_ACCESS); H5Pset_vol(fprop, vol_id, &fprop); fid = H5Fcreate("test", H5F_ACC_TRUNC, H5P_DEFAULT, fprop); H5VLget_plugin_name(fid, name, 1024); printf ("Using VOL %s\n", name); g1 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(g1); g2 = H5Gcreate2(fid, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); g1 = H5Gcreate2(g2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(g1); H5Gclose(g2); // is this allowed? //g3 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); //H5Gclose(g3); printf("Testing additional functions\n"); g1 = H5Gopen2(fid, "g1", H5P_DEFAULT ); plist = H5Gget_create_plist(g1); H5G_info_t group_info; H5Gget_info(g1, & group_info ); H5Gget_info_by_idx(fid, "g1", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, 0, & group_info, H5P_DEFAULT ) ; H5Gget_info_by_idx(fid, "g1", H5_INDEX_NAME, H5_ITER_NATIVE, 0, & group_info, H5P_DEFAULT ) ; H5Gget_info_by_name(fid, "g1", & group_info, H5P_DEFAULT); H5Pclose(plist); status = H5Gclose(g1); g1 = H5Gopen2(fid, "g2", H5P_DEFAULT ); H5Gclose(g1); //g1 = H5Gopen2(fid, "INVALID", H5P_DEFAULT ); //H5Gclose(g1); g1 = H5Gcreate_anon( fid, H5P_DEFAULT, H5P_DEFAULT ); H5Gclose(g1); H5Fclose(fid); H5VL_memvol_finalize(); printf("Status: %d\n", status); return 0; }
/*------------------------------------------------------------------------- * Function: group_stats * * Purpose: Gather statistics about the group * * Return: Success: 0 * * Failure: -1 * * Programmer: Quincey Koziol * Tuesday, August 16, 2005 * * Modifications: Refactored code from the walk_function * EIP, Wednesday, August 16, 2006 * * Vailin Choi 12 July 2007 * 1. Gathered storage info for btree and heap * (groups and attributes) * 2. Gathered info for attributes * * Vailin Choi 14 July 2007 * Cast "num_objs" and "num_attrs" to size_t * Due to the -Mbounds problem for the pgi-32 bit compiler on indexing * *------------------------------------------------------------------------- */ static herr_t group_stats(iter_t *iter, const char *name, const H5O_info_t *oi) { H5G_info_t ginfo; /* Group information */ unsigned bin; /* "bin" the number of objects falls in */ herr_t ret; /* Gather statistics about this type of object */ iter->uniq_groups++; /* Get object header information */ iter->group_ohdr_info.total_size += oi->hdr.space.total; iter->group_ohdr_info.free_size += oi->hdr.space.free; /* Get group information */ ret = H5Gget_info_by_name(iter->fid, name, &ginfo, H5P_DEFAULT); HDassert(ret >= 0); /* Update link stats */ if(ginfo.nlinks < SIZE_SMALL_GROUPS) (iter->num_small_groups[(size_t)ginfo.nlinks])++; if(ginfo.nlinks > iter->max_fanout) iter->max_fanout = ginfo.nlinks; /* Add group count to proper bin */ bin = ceil_log10((unsigned long)ginfo.nlinks); if((bin + 1) > iter->group_nbins) { /* Allocate more storage for info about dataset's datatype */ iter->group_bins = (unsigned long *)HDrealloc(iter->group_bins, (bin + 1) * sizeof(unsigned long)); HDassert(iter->group_bins); /* Initialize counts for intermediate bins */ while(iter->group_nbins < bin) iter->group_bins[iter->group_nbins++] = 0; iter->group_nbins++; /* Initialize count for new bin */ iter->group_bins[bin] = 1; } /* end if */ else (iter->group_bins[bin])++; /* Update group metadata info */ iter->groups_btree_storage_size += oi->meta_size.obj.index_size; iter->groups_heap_storage_size += oi->meta_size.obj.heap_size; /* Update attribute metadata info */ ret = attribute_stats(iter, oi); HDassert(ret >= 0); return 0; } /* end group_stats() */
/* * Class: hdf_hdf5lib_H5 * Method: H5Gget_info_by_name * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5G_info_t; */ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name(JNIEnv *env, jclass cls, jlong loc_id, jstring name, jlong lapl_id) { herr_t ret_val = -1; const char *gName; H5G_info_t group_info; PIN_JAVA_STRING(name, gName, NULL); ret_val = H5Gget_info_by_name((hid_t)loc_id, gName, &group_info, (hid_t)lapl_id); UNPIN_JAVA_STRING(name, gName); if (ret_val < 0) { h5libraryError(env); return NULL; } /* end if */ return create_H5G_info_t(env, group_info); } /* end Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name */
std::vector<std::string> fast5_get_multi_read_groups(fast5_file& fh) { std::vector<std::string> out; size_t buffer_size = 0; char* buffer = NULL; // get the number of groups in the root group H5G_info_t group_info; int ret = H5Gget_info_by_name(fh.hdf5_file, "/", &group_info, H5P_DEFAULT); if(ret < 0) { fprintf(stderr, "error getting group info\n"); exit(EXIT_FAILURE); } for(size_t group_idx = 0; group_idx < group_info.nlinks; ++group_idx) { // retrieve the size of this group name ssize_t size = H5Lget_name_by_idx(fh.hdf5_file, "/", H5_INDEX_NAME, H5_ITER_INC, group_idx, NULL, 0, H5P_DEFAULT); if(size < 0) { fprintf(stderr, "error getting group name size\n"); exit(EXIT_FAILURE); } size += 1; // for null terminator if(size > buffer_size) { buffer = (char*)realloc(buffer, size); buffer_size = size; } // copy the group name H5Lget_name_by_idx(fh.hdf5_file, "/", H5_INDEX_NAME, H5_ITER_INC, group_idx, buffer, buffer_size, H5P_DEFAULT); buffer[size] = '\0'; out.push_back(buffer); } free(buffer); buffer = NULL; buffer_size = 0; return out; }
med_err _MEDchecknSublinkFunc(med_idt id,const char *lname, const H5L_info_t *linfo, med_bool *data) { med_err _ret=-1; H5O_info_t oinfo; H5G_info_t _group_info; #ifdef _DEBUG_ SSCRUTE(lname); #endif if (!strcmp(lname,".")) return 0; switch ( (*linfo).type ) { case H5L_TYPE_SOFT: oinfo.type=H5G_LINK; break; case H5L_TYPE_HARD: if ( H5Oget_info_by_name( id, lname, &oinfo, H5P_DEFAULT ) <0) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"H5Oget_info_by_name"); SSCRUTE(lname); } break; case H5L_TYPE_EXTERNAL: case H5L_TYPE_ERROR: default: MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_HDFTYPE,lname); ISCRUTE_int((*linfo).type); goto ERROR; break; } switch ( oinfo.type ) { case H5G_GROUP: if ( H5Gget_info_by_name(id, lname, &_group_info, H5P_DEFAULT ) < 0 ){ MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_GROUP, MED_ERR_NAME_MSG ); SSCRUTE(lname);goto ERROR; } if ( _group_info.nlinks > 1 ) { *data=MED_TRUE; MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GROUP,lname); ISCRUTE_size(_group_info.nlinks);goto ERROR; } /* SSCRUTE(lname); */ /* ISCRUTE(*data); */ /* ISCRUTE(_group_info.nlinks); */ break; case H5G_DATASET: case H5G_LINK: MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_HDFTYPE,lname); goto ERROR; break; case H5G_TYPE: default: MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_HDFTYPE,lname); goto ERROR; } _ret = 0; ERROR: return _ret; }