/* * Class: hdf_hdf5lib_H5 * Method: H5Ovisit * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Ovisit (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, jobject callback_op, jobject op_data) { herr_t status = -1; ENVPTR->GetJavaVM(ENVPAR &jvm); visit_callback = callback_op; if (op_data == NULL) { h5nullArgument(env, "H5Ovisit: op_data is NULL"); } /* end if */ else if (callback_op == NULL) { h5nullArgument(env, "H5Ovisit: callback_op is NULL"); } /* end if */ else { status = H5Ovisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data); if (status < 0) h5libraryError(env); } return status; } /* end Java_hdf_hdf5lib_H5_H5Ovisit */
/****if* H5Of/h5ovisit_c * NAME * h5ovisit_c * PURPOSE * Calls H5Ovisit * INPUTS * object_id - Identifier specifying subject group * index_type - Type of index which determines the order * order - Order within index * idx - Iteration position at which to start * op - Callback function passing data regarding the link to the calling application * op_data - User-defined pointer to data required by the application for its processing of the link * * OUTPUTS * idx - Position at which an interrupted iteration may be restarted * * RETURNS * >0 on success, 0< on failure * AUTHOR * M. Scot Breitenfeld * November 19, 2008 * SOURCE */ int_f nh5ovisit_c(hid_t_f *group_id, int_f *index_type, int_f *order, H5O_iterate_t op, void *op_data ) /******/ { int_f ret_value = -1; /* Return value */ herr_t func_ret_value; /* H5Linterate return value */ /* * Call H5Ovisit */ func_ret_value = H5Ovisit( (hid_t)*group_id, (H5_index_t)*index_type, (H5_iter_order_t)*order, op, op_data); ret_value = (int_f)func_ret_value; return ret_value; }
//! Search an HDF5 file for the given dataset names. //! If 'exact' is true, failure to find a dataset in the list of names means that -1 is returned. //! If 'exact' is false and no datasets are found, -1 is returned. //! The number of dimensions is used to help prune down invalid datasets; //! 2 dimensions is a matrix, 1 dimension is a vector, and 3 dimensions is a cube. //! If the number of dimensions in a dataset is less than or equal to num_dims, //! it will be considered -- for instance, a one-dimensional HDF5 vector can be loaded as a single-column matrix. inline hid_t search_hdf5_file ( const std::vector<std::string>& names, hid_t hdf5_file, int num_dims = 2, bool exact = false ) { hdf5_search_info search_info = { names, num_dims, exact, -1, names.size() }; // We'll use the H5Ovisit to track potential entries. herr_t status = H5Ovisit(hdf5_file, H5_INDEX_NAME, H5_ITER_NATIVE, hdf5_search_callback, void_ptr(&search_info)); // Return the best match; it will be -1 if there was a problem. return (status < 0) ? -1 : search_info.best_match; }
int main(void) { hid_t file, group, gcpl; /* Handles */ herr_t status; /* * Create a new file using the default properties. */ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Create group creation property list and set it to allow creation * of intermediate groups. */ gcpl = H5Pcreate (H5P_LINK_CREATE); status = H5Pset_create_intermediate_group (gcpl, 1); /* * Create the group /G1/G2/G3. Note that /G1 and /G1/G2 do not * exist yet. This call would cause an error if we did not use the * previously created property list. */ group = H5Gcreate (file, "/G1/G2/G3", gcpl, H5P_DEFAULT, H5P_DEFAULT); /* * Print all the objects in the files to show that intermediate * groups have been created. See h5ex_g_visit for more information * on how to use H5Ovisit. */ printf ("Objects in the file:\n"); status = H5Ovisit (file, H5_INDEX_NAME, H5_ITER_NATIVE, op_func, NULL); /* * Close and release resources. */ status = H5Pclose (gcpl); status = H5Gclose (group); status = H5Fclose (file); return 0; }
/*------------------------------------------------------------------------- * Function: h5_verify_cached_stabs * * Purpose: Verify that all groups in every file in base_name have * their symbol table information cached (if present, and if * the parent group also uses a symbol table). Does not * check that the root group's symbol table information is * cached in the superblock. * * Return: Success: 0 * * Failure: -1 * * Programmer: Neil Fortner * Tuesday, April 12, 2011 * * Modifications: * *------------------------------------------------------------------------- */ herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl) { hid_t file = -1; char filename[1024]; int i = 0; while(base_name[i]) { if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) continue; H5E_BEGIN_TRY { file = H5Fopen(filename, H5F_ACC_RDONLY, fapl); } H5E_END_TRY if(file < 0) { i++; continue; } /* end if */ if(H5Ovisit(file, H5_INDEX_NAME, H5_ITER_NATIVE, h5_verify_cached_stabs_cb, NULL) < 0) goto error; if(H5Fclose(file) < 0) goto error; file = -1; i++; } /* end while */ return 0; error: H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; return -1; }
herr_t arma_H5Ovisit(hid_t object_id, H5_index_t index_type, H5_iter_order_t order, H5O_iterate_t op, void* op_data) { return H5Ovisit(object_id, index_type, order, op, op_data); }