* OESS-98 convert plugin option to FetchContent, add tests * Fixes for pkcfg files because of plugin option * OESS-98 fix tools test for plugins * Keep doxygen comments under 100 chars long - format hint * Whitespace * HDFFV-11144 - Reclassify CMake messages * HDFFV-11099/11100 added help text * Reworked switch statement to compare string instead * Fix typo * Update CDash mode * Correct name of threadsafe * Correct option name * Undo accidental commit * Note LLVM 10 to 11 format default changes * Update format plugin * Undo clang-format version 11 changes * One more correction * Update supported platforms * Revert whitespace changes * Correct whitespace * Changes from PR#3 * HDFFV-11213 added option to control gcc10 warnings diagnostics * HDFFV-11212 Use the new references correctly in JNI utility and tests * format source * Fix typo * Add new test file * HDFFV-11212 - update test and remove unused arg * Minor non-space formatting changes * Use H5I_INVALID_ID instead of "-1" * source formatting * add missing testfile, update jni function * Undo commit of debug code * remove mislocated file * Fix h5repack test for handling of fapls and id close * Update h5diff test files usage text * HDFFV-11212 add new ref tests for JNI export dataset * src format update * Remove blank line typo * src format typo * long double requires %Lg * Another long double foramt specifer S.B. %Lg * issue with t128bit test * Windows issue with h5dump and type. * Fix review issues * refactor function nesting and fix error checks * format fixes * Remove untested functions and javadoc quiet comments * Restore TRY block. * Change string append errors to memory exception * revert to H5_JNI_FATAL_ERROR - support functions need work * Add assertion error for h5util functions * remove duplicate function * format fix * Revert HD function error handling * Update copyright comments * GH #386 java folder copyright corrections * Whitespace
119 lines
5.3 KiB
Java
119 lines
5.3 KiB
Java
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* Copyright by The HDF Group. *
|
|
* All rights reserved. *
|
|
* *
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
* the COPYING file, which can be found at the root of the source code *
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
|
* If you do not have access to either file, you may request a copy from *
|
|
* help@hdfgroup.org. *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
/************************************************************
|
|
Creating a file with creation properties and traverse the
|
|
groups in alpabetical and creation order.
|
|
************************************************************/
|
|
|
|
package examples.groups;
|
|
|
|
import hdf.hdf5lib.H5;
|
|
import hdf.hdf5lib.HDF5Constants;
|
|
import hdf.hdf5lib.structs.H5G_info_t;
|
|
|
|
public class H5Ex_G_Corder {
|
|
private static String FILE = "H5Ex_G_Corder.h5";
|
|
|
|
private static void CreateGroup() throws Exception {
|
|
long file_id = HDF5Constants.H5I_INVALID_HID;
|
|
long group_id = HDF5Constants.H5I_INVALID_HID;
|
|
long subgroup_id = HDF5Constants.H5I_INVALID_HID;
|
|
long gcpl_id = HDF5Constants.H5I_INVALID_HID;
|
|
int status;
|
|
H5G_info_t ginfo;
|
|
int i;
|
|
String name;
|
|
|
|
try {
|
|
// Create a new file using default properties.
|
|
file_id = H5.H5Fcreate(FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
|
HDF5Constants.H5P_DEFAULT);
|
|
|
|
// Create group creation property list and enable link creation order tracking.
|
|
gcpl_id = H5.H5Pcreate(HDF5Constants.H5P_GROUP_CREATE);
|
|
status = H5.H5Pset_link_creation_order(gcpl_id, HDF5Constants.H5P_CRT_ORDER_TRACKED
|
|
+ HDF5Constants.H5P_CRT_ORDER_INDEXED);
|
|
|
|
// Create primary group using the property list.
|
|
if (status >= 0)
|
|
group_id = H5.H5Gcreate(file_id, "index_group", HDF5Constants.H5P_DEFAULT, gcpl_id,
|
|
HDF5Constants.H5P_DEFAULT);
|
|
|
|
try {
|
|
/*
|
|
* Create subgroups in the primary group. These will be tracked by creation order. Note that these
|
|
* groups do not have to have the creation order tracking property set.
|
|
*/
|
|
subgroup_id = H5.H5Gcreate(group_id, "H", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
|
HDF5Constants.H5P_DEFAULT);
|
|
status = H5.H5Gclose(subgroup_id);
|
|
subgroup_id = H5.H5Gcreate(group_id, "D", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
|
HDF5Constants.H5P_DEFAULT);
|
|
status = H5.H5Gclose(subgroup_id);
|
|
subgroup_id = H5.H5Gcreate(group_id, "F", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
|
HDF5Constants.H5P_DEFAULT);
|
|
status = H5.H5Gclose(subgroup_id);
|
|
subgroup_id = H5.H5Gcreate(group_id, "5", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
|
HDF5Constants.H5P_DEFAULT);
|
|
status = H5.H5Gclose(subgroup_id);
|
|
|
|
// Get group info.
|
|
ginfo = H5.H5Gget_info(group_id);
|
|
|
|
// Traverse links in the primary group using alphabetical indices (H5_INDEX_NAME).
|
|
System.out.println("Traversing group using alphabetical indices:");
|
|
for (i = 0; i < ginfo.nlinks; i++) {
|
|
// Retrieve the name of the ith link in a group
|
|
name = H5.H5Lget_name_by_idx(group_id, ".", HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_INC,
|
|
i, HDF5Constants.H5P_DEFAULT);
|
|
System.out.println("Index " + i + ": " + name);
|
|
}
|
|
|
|
// Traverse links in the primary group by creation order (H5_INDEX_CRT_ORDER).
|
|
System.out.println("Traversing group using creation order indices:");
|
|
for (i = 0; i < ginfo.nlinks; i++) {
|
|
// Retrieve the name of the ith link in a group
|
|
name = H5.H5Lget_name_by_idx(group_id, ".", HDF5Constants.H5_INDEX_CRT_ORDER,
|
|
HDF5Constants.H5_ITER_INC, i, HDF5Constants.H5P_DEFAULT);
|
|
System.out.println("Index " + i + ": " + name);
|
|
}
|
|
|
|
}
|
|
catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
finally {
|
|
// Close and release resources.
|
|
if (gcpl_id >= 0)
|
|
H5.H5Pclose(gcpl_id);
|
|
if (group_id >= 0)
|
|
H5.H5Gclose(group_id);
|
|
if (file_id >= 0)
|
|
H5.H5Fclose(file_id);
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
try {
|
|
H5Ex_G_Corder.CreateGroup();
|
|
}
|
|
catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|