HDFFV-10876 Merge from develop

This commit is contained in:
Allen Byrne
2019-12-09 15:44:38 -06:00
parent dbd6fb0ba6
commit 310b42e35a
93 changed files with 6249 additions and 3916 deletions
+332 -5
View File
@@ -1107,7 +1107,9 @@ public class H5 implements java.io.Serializable {
log.trace("H5Aread_dname_D");
status = H5Aread_double(attr_id, mem_type_id, (double[]) obj, isCriticalPinning);
}
else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && (is1D && (dataClass.getComponentType() == String.class))) || H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) {
else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) &&
(is1D && (dataClass.getComponentType() == String.class))) ||
H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) {
log.trace("H5Aread_reg_ref");
status = H5Aread_reg_ref(attr_id, mem_type_id, (String[]) obj);
}
@@ -2005,7 +2007,9 @@ public class H5 implements java.io.Serializable {
status = H5Dread_double(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id,
(double[]) obj, isCriticalPinning);
}
else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && (is1D && (dataClass.getComponentType() == String.class))) || H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) {
else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) &&
(is1D && (dataClass.getComponentType() == String.class))) ||
H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) {
log.trace("H5Dread_reg_ref");
status = H5Dread_reg_ref(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id,
(String[]) obj);
@@ -8093,6 +8097,331 @@ public class H5 implements java.io.Serializable {
**/
public synchronized static native int H5PLsize() throws HDF5LibraryException;
// ////////////////////////////////////////////////////////////
// //
// H5R: HDF5 1.12 Reference API Functions //
// //
// ////////////////////////////////////////////////////////////
// Constructors //
/**
* H5Rcreate_object creates a reference pointing to the object named name located at loc id.
*
* @param loc_id
* IN: Location identifier used to locate the object being pointed to.
* @param name
* IN: Name of object at location loc_id.
* @param access_id
* IN: Object access identifier to the object being pointed to.
*
* @return the reference (byte[]) if successful
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native byte[] H5Rcreate_object(long loc_id, String name, long access_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Rcreate_region creates the reference, pointing to the region represented by
* space id within the object named name located at loc id.
*
* @param loc_id
* IN: Location identifier used to locate the object being pointed to.
* @param name
* IN: Name of object at location loc_id.
* @param space_id
* IN: Identifies the dataset region that a dataset region reference points to.
* @param access_id
* IN: Object access identifier to the object being pointed to.
*
* @return the reference (byte[]) if successful
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native byte[] H5Rcreate_region(long loc_id, String name, long space_id, long access_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Rcreate_attr creates the reference, pointing to the attribute named attr name
* and attached to the object named name located at loc id.
*
* @param loc_id
* IN: Location identifier used to locate the object being pointed to.
* @param name
* IN: Name of object at location loc_id.
* @param attr_name
* IN: Name of the attribute within the object.
* @param access_id
* IN: Object access identifier to the object being pointed to.
*
* @return the reference (byte[]) if successful
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native byte[] H5Rcreate_attr(long loc_id, String name, String attr_name, long access_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Rdestroy destroys a reference and releases resources.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native void H5Rdestroy(byte[] ref_ptr)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
// Info //
/**
* H5Rget_type retrieves the type of a reference.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
*
* @return a valid reference type if successful; otherwise returns H5R UNKNOWN.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native int H5Rget_type(byte[] ref_ptr)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Requal determines whether two references point to the same object, region or attribute.
*
* @param ref1_ptr
* IN: Reference to an object, region or attribute attached to an object.
* @param ref2_ptr
* IN: Reference to an object, region or attribute attached to an object.
*
* @return true if equal, else false
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native boolean H5Requal(byte[] ref1_ptr, byte[] ref2_ptr)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Rcopy creates a copy of an existing reference.
*
* @param src_ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
*
* @return a valid copy of the reference (byte[]) if successful.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native byte[] H5Rcopy(byte[] src_ref_ptr)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
// Dereference //
/**
* H5Ropen_object opens that object and returns an identifier.
* The object opened with this function should be closed when it is no longer needed
* so that resource leaks will not develop. Use the appropriate close function such
* as H5Oclose or H5Dclose for datasets.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
* @param rapl_id
* IN: A reference access property list identifier for the reference. The access property
* list can be used to access external files that the reference points
* to (through a file access property list).
* @param oapl_id
* IN: An object access property list identifier for the reference. The access property
* property list must be of the same type as the object being referenced,
* that is a group or dataset property list.
*
* @return a valid identifier if successful
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native long H5Ropen_object(byte[] ref_ptr, long rapl_id, long oapl_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Ropen region creates a copy of the dataspace of the dataset pointed to by a region reference,
* ref ptr, and defines a selection matching the selection pointed to by ref ptr within the dataspace copy.
* Use H5Sclose to release the dataspace identifier returned by this function when the identifier is no longer needed.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
* @param rapl_id
* IN: A reference access property list identifier for the reference. The access property
* list can be used to access external files that the reference points
* to (through a file access property list).
* @param oapl_id
* IN: An object access property list identifier for the reference. The access property
* property list must be of the same type as the object being referenced,
* that is a group or dataset property list.
*
* @return a valid dataspace identifier if successful
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native long H5Ropen_region(byte[] ref_ptr, long rapl_id, long oapl_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Ropen_attr opens the attribute attached to the object and returns an identifier.
* The attribute opened with this function should be closed with H5Aclose when it is no longer needed
* so that resource leaks will not develop.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
* @param rapl_id
* IN: A reference access property list identifier for the reference. The access property
* list can be used to access external files that the reference points
* to (through a file access property list).
* @param aapl_id
* IN: An attribute access property list identifier for the reference. The access property
* property list must be of the same type as the object being referenced,
* that is a group or dataset property list.
*
* @return a valid attribute identifier if successful
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - an input array is null.
* @exception IllegalArgumentException
* - an input array is invalid.
**/
public synchronized static native long H5Ropen_attr(byte[] ref_ptr, long rapl_id, long aapl_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
// Get type //
/**
* H5Rget obj type3 retrieves the type of the referenced object pointed to.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
* @param rapl_id
* IN: A reference access property list identifier for the reference. The access property
* list can be used to access external files that the reference points
* to (through a file access property list).
*
* @return Returns the object type
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - array is null.
* @exception IllegalArgumentException
* - array is invalid.
**/
public synchronized static native int H5Rget_obj_type3(byte[] ref_ptr, long rapl_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
// Get name //
/**
* H5Rget_file_name retrieves the file name for the object, region or attribute reference pointed to.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
*
* @return Returns the file name of the reference
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - array is null.
* @exception IllegalArgumentException
* - array is invalid.
**/
public synchronized static native String H5Rget_file_name(byte[] ref_ptr)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Rget_obj_name retrieves the object name for the object, region or attribute reference pointed to.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
* @param rapl_id
* IN: A reference access property list identifier for the reference. The access property
* list can be used to access external files that the reference points
* to (through a file access property list).
*
* @return Returns the object name of the reference
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - array is null.
* @exception IllegalArgumentException
* - array is invalid.
**/
public synchronized static native String H5Rget_obj_name(byte[] ref_ptr, long rapl_id)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
/**
* H5Rget_attr_name retrieves the attribute name for the object, region or attribute reference pointed to.
*
* @param ref_ptr
* IN: Reference to an object, region or attribute attached to an object.
*
* @return Returns the attribute name of the reference
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - array is null.
* @exception IllegalArgumentException
* - array is invalid.
**/
public synchronized static native String H5Rget_attr_name(byte[] ref_ptr)
throws HDF5LibraryException, NullPointerException, IllegalArgumentException;
// ////////////////////////////////////////////////////////////
// //
// H5R: HDF5 1.8 Reference API Functions //
@@ -10328,14 +10657,12 @@ public class H5 implements java.io.Serializable {
* @param buf
* Buffer with data to be reclaimed.
*
* @return a non-negative value if successful
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - buf is null.
**/
public synchronized static native int H5Treclaim(long type_id, long space_id, long xfer_plist_id, byte[] buf)
public synchronized static native void H5Treclaim(long type_id, long space_id, long xfer_plist_id, byte[] buf)
throws HDF5LibraryException, NullPointerException;
/**
+22
View File
@@ -406,11 +406,18 @@ public class HDF5Constants {
public static final int H5PL_VOL_PLUGIN = H5PL_VOL_PLUGIN();
public static final int H5PL_ALL_PLUGIN = H5PL_ALL_PLUGIN();
public static final int H5R_ATTR = H5R_ATTR();
public static final int H5R_BADTYPE = H5R_BADTYPE();
public static final int H5R_DATASET_REGION = H5R_DATASET_REGION();
public static final int H5R_DATASET_REGION1 = H5R_DATASET_REGION1();
public static final int H5R_DATASET_REGION2 = H5R_DATASET_REGION2();
public static final int H5R_MAXTYPE = H5R_MAXTYPE();
public static final int H5R_REF_BUF_SIZE = H5R_REF_BUF_SIZE();
public static final int H5R_OBJ_REF_BUF_SIZE = H5R_OBJ_REF_BUF_SIZE();
public static final int H5R_OBJECT = H5R_OBJECT();
public static final int H5R_OBJECT1 = H5R_OBJECT1();
public static final int H5R_OBJECT2 = H5R_OBJECT2();
public static final int H5S_ALL = H5S_ALL();
public static final int H5S_MAX_RANK = H5S_MAX_RANK();
public static final int H5S_NO_CLASS = H5S_NO_CLASS();
@@ -605,6 +612,7 @@ public class HDF5Constants {
public static final long H5T_STD_I8LE = H5T_STD_I8LE();
public static final long H5T_STD_REF_DSETREG = H5T_STD_REF_DSETREG();
public static final long H5T_STD_REF_OBJ = H5T_STD_REF_OBJ();
public static final long H5T_STD_REF = H5T_STD_REF();
public static final long H5T_STD_U16BE = H5T_STD_U16BE();
public static final long H5T_STD_U16LE = H5T_STD_U16LE();
public static final long H5T_STD_U32BE = H5T_STD_U32BE();
@@ -1417,16 +1425,28 @@ public class HDF5Constants {
private static native final int H5PL_VOL_PLUGIN();
private static native final int H5R_ATTR();
private static native final int H5R_BADTYPE();
private static native final int H5R_DATASET_REGION();
private static native final int H5R_DATASET_REGION1();
private static native final int H5R_DATASET_REGION2();
private static native final int H5R_MAXTYPE();
private static native final int H5R_REF_BUF_SIZE();
private static native final int H5R_OBJ_REF_BUF_SIZE();
private static native final int H5R_OBJECT();
private static native final int H5R_OBJECT1();
private static native final int H5R_OBJECT2();
private static native final int H5S_ALL();
private static native final int H5S_MAX_RANK();
@@ -1815,6 +1835,8 @@ public class HDF5Constants {
private static native final long H5T_STD_REF_OBJ();
private static native final long H5T_STD_REF();
private static native final long H5T_STD_U16BE();
private static native final long H5T_STD_U16LE();
+14
View File
@@ -811,13 +811,25 @@ Java_hdf_hdf5lib_HDF5Constants_H5R_1BADTYPE(JNIEnv *env, jclass cls) { return H5
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1MAXTYPE(JNIEnv *env, jclass cls) { return H5R_MAXTYPE; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_REF_BUF_SIZE; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJ_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_OBJ_REF_BUF_SIZE; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1DSET_1REG_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_DSET_REG_REF_BUF_SIZE; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1ATTR(JNIEnv *env, jclass cls) { return H5R_ATTR; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT(JNIEnv *env, jclass cls) { return H5R_OBJECT; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT1(JNIEnv *env, jclass cls) { return H5R_OBJECT1; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT2(JNIEnv *env, jclass cls) { return H5R_OBJECT2; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION(JNIEnv *env, jclass cls) { return H5R_DATASET_REGION; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION1(JNIEnv *env, jclass cls) { return H5R_DATASET_REGION1; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION2(JNIEnv *env, jclass cls) { return H5R_DATASET_REGION2; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5S_1ALL(JNIEnv *env, jclass cls) { return H5S_ALL; }
@@ -1209,6 +1221,8 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1DSETREG(JNIEnv *env, jclass cls) {
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1OBJ(JNIEnv *env, jclass cls) { return H5T_STD_REF_OBJ; }
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF(JNIEnv *env, jclass cls) { return H5T_STD_REF; }
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16BE(JNIEnv *env, jclass cls) { return H5T_STD_U16BE; }
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16LE(JNIEnv *env, jclass cls) { return H5T_STD_U16LE; }
+4 -4
View File
@@ -1304,7 +1304,7 @@ H5AwriteVL_asstr
{
const char *utf8 = NULL;
hsize_t dims[H5S_MAX_RANK];
jstring jstr;
jstring jstr = NULL;
size_t typeSize;
size_t i;
hid_t sid = H5I_INVALID_HID;
@@ -1390,7 +1390,7 @@ JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref
(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf)
{
hdset_reg_ref_t *ref_data = NULL;
H5R_ref_t *ref_data = NULL;
h5str_t h5str;
jstring jstr;
jsize i, n;
@@ -1405,7 +1405,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_reg_ref: buf length < 0");
}
if (NULL == (ref_data = (hdset_reg_ref_t *) HDcalloc(1, (size_t)n * sizeof(hdset_reg_ref_t))))
if (NULL == (ref_data = (H5R_ref_t *) HDcalloc(1, (size_t)n * sizeof(H5R_ref_t))))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate read buffer");
if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, ref_data)) < 0)
@@ -1419,7 +1419,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref
for (i = 0; i < n; i++) {
h5str.s[0] = '\0';
if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)attr_id, (hid_t)mem_type_id, ref_data[i], 0, 0))
if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)attr_id, (hid_t)mem_type_id, (void*)&ref_data[i], 0, 0))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s)))
+4 -4
View File
@@ -1502,7 +1502,7 @@ H5DwriteVL_asstr
(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
{
const char *utf8 = NULL;
jstring obj;
jstring obj = NULL;
hbool_t close_mem_space = FALSE;
size_t typeSize;
size_t i;
@@ -1630,7 +1630,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{
hdset_reg_ref_t *ref_data = NULL;
H5R_ref_t *ref_data = NULL;
h5str_t h5str;
jstring jstr;
jsize i, n;
@@ -1645,7 +1645,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_reg_ref: buf length < 0");
}
if (NULL == (ref_data = (hdset_reg_ref_t *) HDcalloc(1, (size_t)n * sizeof(hdset_reg_ref_t))))
if (NULL == (ref_data = (H5R_ref_t *) HDcalloc(1, (size_t)n * sizeof(H5R_ref_t))))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate read buffer");
if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, xfer_plist_id, ref_data)) < 0)
@@ -1659,7 +1659,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
for (i = 0; i < n; i++) {
h5str.s[0] = '\0';
if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)dataset_id, (hid_t)mem_type_id, &ref_data[i], 0, 0))
if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)dataset_id, (hid_t)mem_type_id, (void*)&ref_data[i], 0, 0))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s)))
+10
View File
@@ -425,6 +425,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs
CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_hdfs_fapl_t", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V", args, ret_obj);
#else
UNUSED(fapl_id);
H5_UNIMPLEMENTED(ENVONLY, "H5Pget_fapl_hdfs: not implemented");
#endif /* H5_HAVE_LIBHDFS */
@@ -532,6 +534,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs
if (H5Pset_fapl_hdfs((hid_t)fapl_id, &instance) < 0)
H5_LIBRARY_ERROR(ENVONLY);
#else
UNUSED(fapl_id);
UNUSED(fapl_config);
H5_UNIMPLEMENTED(ENVONLY, "H5Pset_fapl_hdfs: not implemented");
#endif /* H5_HAVE_LIBHDFS */
@@ -841,6 +846,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3
CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_ros3_fapl_t", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, ret_obj);
#else
UNUSED(fapl_id);
H5_UNIMPLEMENTED(ENVONLY, "H5Pget_fapl_ros3: not implemented");
#endif /* H5_HAVE_ROS3_VFD */
@@ -939,6 +946,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3
if (H5Pset_fapl_ros3((hid_t)fapl_id, &instance) < 0)
H5_LIBRARY_ERROR(ENVONLY);
#else
UNUSED(fapl_id);
UNUSED(fapl_config);
H5_UNIMPLEMENTED(ENVONLY, "H5Pset_fapl_ros3: not implemented");
#endif /* H5_HAVE_ROS3_VFD */
+588 -2
View File
@@ -26,10 +26,596 @@ extern "C" {
#include "h5jni.h"
#include "h5rImp.h"
/* H5R: HDF5 1.12 Reference API Functions */
/*
* Pointer to the JNI's Virtual Machine; used for callback functions.
* Class: hdf_hdf5lib_H5
* Method: H5Rcreate_object
* Signature: (JLjava/lang/String;)[B
*/
/* extern JavaVM *jvm; */
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcreate_1object
(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong aid)
{
const char *refName = NULL;
jbyteArray ref = NULL;
jbyte *refBuf = NULL;
herr_t status = FAIL;
UNUSED(clss);
if (NULL == name)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcreate_object: name is NULL");
PIN_JAVA_STRING(ENVONLY, name, refName, NULL, "H5Rcreate_object: reference name not pinned");
if (NULL == (refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_object: failed to allocate reference buffer");
if ((status = H5Rcreate_object((hid_t)loc_id, refName, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (ref = ENVPTR->NewByteArray(ENVONLY, (jsize)H5R_REF_BUF_SIZE)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
ENVPTR->SetByteArrayRegion(ENVONLY, ref, 0, (jsize)H5R_REF_BUF_SIZE, (jbyte *)refBuf);
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (refName)
UNPIN_JAVA_STRING(ENVONLY, name, refName);
if (refBuf)
HDfree(refBuf);
return ref;
} /* end Java_hdf_hdf5lib_H5_H5Rcreate_1object */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcreate_region
* Signature: (JLjava/lang/String;J)[B
*/
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcreate_1region
(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong space_id, jlong aid)
{
const char *refName = NULL;
jbyteArray ref = NULL;
jbyte *refBuf = NULL;
herr_t status = FAIL;
UNUSED(clss);
if (NULL == name)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcreate_region: name is NULL");
PIN_JAVA_STRING(ENVONLY, name, refName, NULL, "H5Rcreate_region: reference name not pinned");
if (NULL == (refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_region: failed to allocate reference buffer");
if ((status = H5Rcreate_region((hid_t)loc_id, refName, space_id, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (ref = ENVPTR->NewByteArray(ENVONLY, (jsize)H5R_REF_BUF_SIZE)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
ENVPTR->SetByteArrayRegion(ENVONLY, ref, 0, (jsize)H5R_REF_BUF_SIZE, (jbyte *)refBuf);
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (refName)
UNPIN_JAVA_STRING(ENVONLY, name, refName);
if (refBuf)
HDfree(refBuf);
return ref;
} /* end Java_hdf_hdf5lib_H5_H5Rcreate_1region */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcreate_attr
* Signature: (JLjava/lang/String;Ljava/lang/String;)[B
*/
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcreate_1attr
(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jstring attr_name, jlong aid)
{
const char *refName = NULL;
const char *attrName = NULL;
jbyteArray ref = NULL;
jbyte *refBuf = NULL;
herr_t status = FAIL;
UNUSED(clss);
if (NULL == name)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcreate_attr: name is NULL");
if (NULL == attr_name)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcreate_attr: attribute name is NULL");
PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Rcreate_attr: attribute name not pinned");
PIN_JAVA_STRING(ENVONLY, name, refName, NULL, "H5Rcreate_attr: reference name not pinned");
if (NULL == (refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_attr: failed to allocate reference buffer");
if ((status = H5Rcreate_attr((hid_t)loc_id, refName, attrName, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (ref = ENVPTR->NewByteArray(ENVONLY, (jsize)H5R_REF_BUF_SIZE)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
ENVPTR->SetByteArrayRegion(ENVONLY, ref, 0, (jsize)H5R_REF_BUF_SIZE, (jbyte *)refBuf);
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (attrName)
UNPIN_JAVA_STRING(ENVONLY, attr_name, attrName);
if (refName)
UNPIN_JAVA_STRING(ENVONLY, name, refName);
if (refBuf)
HDfree(refBuf);
return ref;
} /* end Java_hdf_hdf5lib_H5_H5Rcreate_1attr */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rdestroy
* Signature: ([B)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Rdestroy
(JNIEnv *env, jclass clss, jbyteArray ref)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jsize refBufLen;
herr_t status = FAIL;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rdestroy: reference is NULL");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdestroy: reference array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rdestroy: reference buffer not pinned");
if ((status = H5Rdestroy((const H5R_ref_t *)refBuf)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
done:
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (status < 0) ? JNI_ABORT : 0);
} /* end Java_hdf_hdf5lib_H5_H5Rdestroy */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_type
* Signature: ([B)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1type
(JNIEnv *env, jclass clss, jbyteArray ref)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jsize refBufLen;
H5R_type_t ref_type = -1;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_type: reference is NULL");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_type: reference array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_type: reference buffer not pinned");
if ((ref_type = H5Rget_type((const H5R_ref_t *)refBuf)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
done:
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (ref_type < 0) ? JNI_ABORT : 0);
return (jint)ref_type;
} /* end Java_hdf_hdf5lib_H5_H5Rget_1type */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Requal
* Signature: ([B[B)Z
*/
JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5Requal
(JNIEnv *env, jclass clss, jbyteArray ref1, jbyteArray ref2)
{
jboolean isCopy;
jbyte *refBuf1 = NULL;
jbyte *refBuf2 = NULL;
jsize refBufLen;
htri_t bval = JNI_FALSE;
herr_t status = FAIL;
UNUSED(clss);
if (NULL == ref1)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Requal: reference1 is NULL");
if (NULL == ref2)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Requal: reference2 is NULL");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref1)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Requal: reference1 array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, ref1, refBuf1, &isCopy, "H5Requal: reference1 buffer not pinned");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref2)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Requal: reference2 array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, ref2, refBuf2, &isCopy, "H5Requal: reference2 buffer not pinned");
if ((bval = H5Requal((const H5R_ref_t *)refBuf1, (const H5R_ref_t *)refBuf2)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
status = bval;
bval = (bval > 0) ? JNI_TRUE : JNI_FALSE;
done:
if (refBuf2)
UNPIN_BYTE_ARRAY(ENVONLY, ref2, refBuf2, (status < 0) ? JNI_ABORT : 0);
if (refBuf1)
UNPIN_BYTE_ARRAY(ENVONLY, ref1, refBuf1, (status < 0) ? JNI_ABORT : 0);
return (jboolean)bval;
} /* end Java_hdf_hdf5lib_H5_H5Requal */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcopy
* Signature: ([B)[B
*/
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcopy
(JNIEnv *env, jclass clss, jbyteArray src_ref)
{
jboolean isCopy;
jbyte *src_refBuf = NULL;
jsize refBufLen;
jbyteArray dst_ref = NULL;
jbyte *dst_refBuf = NULL;
herr_t status = FAIL;
UNUSED(clss);
if (NULL == src_ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcopy: src reference is NULL");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, src_ref)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcopy: src reference array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, src_ref, src_refBuf, &isCopy, "H5Rcopy: src reference buffer not pinned");
if (NULL == (dst_refBuf = (unsigned char *) HDcalloc((size_t) 1, H5R_REF_BUF_SIZE)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Rcreate_attr: failed to allocate dst reference buffer");
if ((status = H5Rcopy((const H5R_ref_t *)src_refBuf, (const H5R_ref_t *)dst_refBuf)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (dst_ref = ENVPTR->NewByteArray(ENVONLY, (jsize)H5R_REF_BUF_SIZE)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
ENVPTR->SetByteArrayRegion(ENVONLY, dst_ref, 0, (jsize)H5R_REF_BUF_SIZE, (jbyte *)dst_refBuf);
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (src_refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, src_ref, src_refBuf, (status < 0) ? JNI_ABORT : 0);
if (dst_refBuf)
HDfree(dst_refBuf);
return dst_ref;
} /* end Java_hdf_hdf5lib_H5_H5Rcopy */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ropen_object
* Signature: ([BJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ropen_1object
(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jsize refBufLen;
hid_t retVal = H5I_INVALID_HID;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ropen_object: reference is NULL");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Ropen_object: reference array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Ropen_object: reference buffer not pinned");
if ((retVal = H5Ropen_object((const H5R_ref_t *)refBuf, (hid_t)rapl_id, (hid_t)oapl_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
done:
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (retVal < 0) ? JNI_ABORT : 0);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Ropen_1object */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ropen_region
* Signature: ([BJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ropen_1region
(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jsize refBufLen;
hid_t retVal = H5I_INVALID_HID;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ropen_region: reference is NULL");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Ropen_region: reference array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Ropen_region: reference buffer not pinned");
if ((retVal = H5Ropen_region((const H5R_ref_t *)refBuf, (hid_t)rapl_id, (hid_t)oapl_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
done:
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (retVal < 0) ? JNI_ABORT : 0);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Ropen_1region */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ropen_attr
* Signature: ([BJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ropen_1attr
(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong aapl_id)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jsize refBufLen;
hid_t retVal = H5I_INVALID_HID;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ropen_attr: reference is NULL");
if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Ropen_attr: reference array length < 0");
}
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Ropen_attr: reference buffer not pinned");
if ((retVal = H5Ropen_attr((const H5R_ref_t *)refBuf, (hid_t)rapl_id, (hid_t)aapl_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
done:
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (retVal < 0) ? JNI_ABORT : 0);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Ropen_1attr */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_obj_type3
* Signature: ([BJ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1obj_1type3
(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id)
{
H5O_type_t object_info;
jboolean isCopy;
jbyte *refBuf = NULL;
int retVal = -1;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_obj_type3: reference buffer is NULL");
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_obj_type3: reference buffer not pinned");
if ((retVal = H5Rget_obj_type3((const H5R_ref_t *)refBuf, (hid_t)rapl_id, &object_info)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (retVal >= 0)
retVal = object_info;
done:
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (retVal < 0) ? JNI_ABORT : 0);
return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Rget_1obj_1type3 */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_file_name
* Signature: ([B)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1file_1name
(JNIEnv *env, jclass clss, jbyteArray ref)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jstring str = NULL;
ssize_t buf_size;
ssize_t check_size = -1;
char *namePtr = NULL;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_file_name: reference buffer is NULL");
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_file_name: reference buffer not pinned");
/* Get the length of the name */
if ((buf_size = H5Rget_file_name((const H5R_ref_t *)refBuf, NULL, 0)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_file_name: malloc failed");
if ((check_size = H5Rget_file_name((const H5R_ref_t *)refBuf, namePtr, (size_t)buf_size + 1)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
namePtr[buf_size] = '\0';
if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (namePtr)
HDfree(namePtr);
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (check_size < 0) ? JNI_ABORT : 0);
return str;
} /* end Java_hdf_hdf5lib_H5_H5Rget_1file_1name */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_obj_name
* Signature: ([BJ)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1obj_1name
(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jstring str = NULL;
ssize_t buf_size;
ssize_t check_size = -1;
char *namePtr = NULL;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_obj_name: reference buffer is NULL");
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_obj_name: reference buffer not pinned");
/* Get the length of the name */
if ((buf_size = H5Rget_obj_name((const H5R_ref_t *)refBuf, (hid_t)rapl_id, NULL, 0)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_obj_name: malloc failed");
if ((check_size = H5Rget_obj_name((const H5R_ref_t *)refBuf, (hid_t)rapl_id, namePtr, (size_t)buf_size + 1)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
namePtr[buf_size] = '\0';
if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (namePtr)
HDfree(namePtr);
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (check_size < 0) ? JNI_ABORT : 0);
return str;
} /* end Java_hdf_hdf5lib_H5_H5Rget_1obj_1name */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_attr_name
* Signature: ([B)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1attr_1name
(JNIEnv *env, jclass clss, jbyteArray ref)
{
jboolean isCopy;
jbyte *refBuf = NULL;
jstring str = NULL;
ssize_t buf_size;
ssize_t check_size = -1;
char *namePtr = NULL;
UNUSED(clss);
if (NULL == ref)
H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_attr_name: reference buffer is NULL");
PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_attr_name: reference buffer not pinned");
/* Get the length of the name */
if ((buf_size = H5Rget_attr_name((const H5R_ref_t *)refBuf, NULL, 0)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_attr_name: malloc failed");
if ((check_size = H5Rget_attr_name((const H5R_ref_t *)refBuf, namePtr, (size_t)buf_size + 1)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
namePtr[buf_size] = '\0';
if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr)))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (namePtr)
HDfree(namePtr);
if (refBuf)
UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (check_size < 0) ? JNI_ABORT : 0);
return str;
} /* end Java_hdf_hdf5lib_H5_H5Rget_1attr_1name */
/* H5R: HDF5 1.8 Reference API Functions */
/*
* Class: hdf_hdf5lib_H5
+130
View File
@@ -21,6 +21,136 @@
extern "C" {
#endif /* __cplusplus */
/* H5R: HDF5 1.12 Reference API Functions */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcreate_object
* Signature: (JLjava/lang/String;)[B
*/
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcreate_1object
(JNIEnv *, jclass, jlong, jstring, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcreate_region
* Signature: (JLjava/lang/String;J)[B
*/
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcreate_1region
(JNIEnv *, jclass, jlong, jstring, jlong, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcreate_attr
* Signature: (JLjava/lang/String;Ljava/lang/String;)[B
*/
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcreate_1attr
(JNIEnv *, jclass, jlong, jstring, jstring, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rdestroy
* Signature: ([B)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Rdestroy
(JNIEnv *, jclass, jbyteArray);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_type
* Signature: ([B)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1type
(JNIEnv *, jclass, jbyteArray);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Requal
* Signature: ([B[B)Z
*/
JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5Requal
(JNIEnv *, jclass, jbyteArray, jbyteArray);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcopy
* Signature: ([B)[B
*/
JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_H5_H5Rcopy
(JNIEnv *, jclass, jbyteArray);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ropen_object
* Signature: ([BJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ropen_1object
(JNIEnv *, jclass, jbyteArray, jlong, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ropen_region
* Signature: ([BJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ropen_1region
(JNIEnv *, jclass, jbyteArray, jlong, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ropen_attr
* Signature: ([BJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Ropen_1attr
(JNIEnv *, jclass, jbyteArray, jlong, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_obj_type3
* Signature: ([BJ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1obj_1type3
(JNIEnv *, jclass, jbyteArray, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_file_name
* Signature: ([B)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1file_1name
(JNIEnv *, jclass, jbyteArray);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_obj_name
* Signature: ([BJ)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1obj_1name
(JNIEnv *, jclass, jbyteArray, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rget_attr_name
* Signature: ([B)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Rget_1attr_1name
(JNIEnv *, jclass, jbyteArray);
/* H5R: HDF5 1.8 Reference API Functions */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Rcreate
+3 -3
View File
@@ -162,9 +162,9 @@ done:
} /* end Java_hdf_hdf5lib_H5__1H5Scopy */
#ifdef notdef
// 10/28/99 -- added code to copy the array -- this is not used,
// but serves as a reminder in case we try to implement this in
// the future....
/* 10/28/99 -- added code to copy the array -- this is not used,
* but serves as a reminder in case we try to implement this in
*/ the future....
/*
* Note: the argument coord is actually long coord[][], which has been
* flattened by the caller.
+3 -3
View File
@@ -49,9 +49,9 @@ Java_hdf_hdf5lib_H5__1H5Scopy
(JNIEnv *, jclass, jlong);
#ifdef notdef
// 10/28/99 -- added code to copy the array -- this is not used,
// but serves as a reminder in case we try to implement this in
// the future....
/* 10/28/99 -- added code to copy the array -- this is not used,
* but serves as a reminder in case we try to implement this in
*/ the future....
/*
* Note: the argument coord is actually long coord[][], which has been
* flattened by the caller.
+2 -4
View File
@@ -981,9 +981,9 @@ done:
/*
* Class: hdf_hdf5lib_H5
* Method: H5Treclaim
* Signature: (JJJ[B)I
* Signature: (JJJ[B)V
*/
JNIEXPORT jint JNICALL
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Treclaim
(JNIEnv *env, jclass clss, jlong type_id, jlong space_id,
jlong xfer_plist_id, jbyteArray buf)
@@ -1005,8 +1005,6 @@ Java_hdf_hdf5lib_H5_H5Treclaim
done:
if (pinBuf)
UNPIN_BYTE_ARRAY(ENVONLY, buf, pinBuf, (status < 0) ? JNI_ABORT : 0);
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Treclaim */
/*
+2 -2
View File
@@ -402,9 +402,9 @@ Java_hdf_hdf5lib_H5_H5Tpack
/*
* Class: hdf_hdf5lib_H5
* Method: H5Treclaim
* Signature: (JJJ[B)I
* Signature: (JJJ[B)V
*/
JNIEXPORT jint JNICALL
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Treclaim
(JNIEnv*, jclass, jlong, jlong, jlong, jbyteArray);
+222 -120
View File
@@ -71,6 +71,12 @@ static int render_bin_output_region_data_points(FILE *stream, hid_t region_s
static int render_bin_output_region_points(FILE *stream, hid_t region_space,
hid_t region_id, hid_t container);
/* Strings for output */
#define H5_TOOLS_GROUP "GROUP"
#define H5_TOOLS_DATASET "DATASET"
#define H5_TOOLS_DATATYPE "DATATYPE"
#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE"
/** frees memory held by array of strings */
void
h5str_array_free
@@ -217,7 +223,7 @@ h5str_convert
switch (typeSize) {
case sizeof(float):
{
float tmp_float = 0.0;
float tmp_float = 0.0f;
sscanf(token, "%f", &tmp_float);
HDmemcpy(cptr, &tmp_float, sizeof(float));
@@ -625,6 +631,69 @@ done:
return retVal;
} /* end h5str_convert */
/*-------------------------------------------------------------------------
* Function: h5str_sprint_reference
*
* Purpose: Object reference -- show the name of the referenced object.
*
* Return: Nothing
*-------------------------------------------------------------------------
*/
void
h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, hid_t container, void *ref_p)
{
ssize_t buf_size;
char *ref_name = NULL;
const H5R_ref_t *ref_vp = (H5R_ref_t *)ref_p;
UNUSED(container);
if (!h5str_append(out_str, " \""))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
buf_size = H5Rget_file_name(ref_vp, NULL, 0);
if (buf_size) {
ref_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
if (H5Rget_file_name(ref_vp, ref_name, buf_size + 1) >= 0) {
ref_name[buf_size] = '\0';
if (!h5str_append(out_str, ref_name))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
HDfree(ref_name);
ref_name = NULL;
}
buf_size = H5Rget_obj_name(ref_vp, H5P_DEFAULT, NULL, 0);
if (buf_size) {
ref_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, ref_name, buf_size + 1) >= 0) {
ref_name[buf_size] = '\0';
if (!h5str_append(out_str, ref_name))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
HDfree(ref_name);
ref_name = NULL;
}
if (H5Rget_type(ref_vp) == H5R_ATTR) {
buf_size = H5Rget_attr_name(ref_vp, NULL, 0);
if (buf_size) {
ref_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
if (H5Rget_attr_name(ref_vp, ref_name, buf_size + 1) >= 0) {
ref_name[buf_size] = '\0';
if (!h5str_append(out_str, ref_name))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
HDfree(ref_name);
ref_name = NULL;
}
}
if (!h5str_append(out_str, "\""))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
done:
if (ref_name)
HDfree(ref_name);
}
/*
* Prints the value of a data point into a string.
*
@@ -639,8 +708,11 @@ h5str_sprintf
unsigned char *ucptr = (unsigned char *) in_buf;
static char fmt_llong[8], fmt_ullong[8];
H5T_class_t tclass = H5T_NO_CLASS;
H5T_str_t pad;
size_t typeSize = 0;
H5T_sign_t nsign = H5T_SGN_ERROR;
hid_t mtid = H5I_INVALID_HID;
hid_t obj = H5I_INVALID_HID;
char *cptr = (char *) in_buf;
char *this_str = NULL;
int n;
@@ -655,12 +727,14 @@ h5str_sprintf
H5_LIBRARY_ERROR(ENVONLY);
if (!(typeSize = H5Tget_size(tid)))
H5_LIBRARY_ERROR(ENVONLY);
if (!(nsign = H5Tget_sign(tid)))
H5_LIBRARY_ERROR(ENVONLY);
/* Build default formats for long long types */
if (!fmt_llong[0]) {
if (HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH) < 0)
if (HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure");
if (HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH) < 0)
if (HDsnprintf(fmt_ullong, sizeof(fmt_ullong), "%%%su", H5_PRINTF_LL_WIDTH) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure");
} /* end if */
@@ -670,7 +744,7 @@ h5str_sprintf
switch (typeSize) {
case sizeof(float):
{
float tmp_float = 0.0;
float tmp_float = 0.0f;
HDmemcpy(&tmp_float, cptr, sizeof(float));
@@ -724,27 +798,28 @@ h5str_sprintf
case H5T_STRING:
{
htri_t is_variable;
char *tmp_str;
typeSize = 0;
htri_t is_variable;
char *tmp_str;
if ((is_variable = H5Tis_variable_str(tid)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (is_variable) {
if (NULL != (tmp_str = *(char **) in_buf))
/* cp_vp is the pointer into the struct where a `char*' is stored. So we have
* to dereference the pointer to get the `char*' to pass to HDstrlen(). */
tmp_str = *(char **)in_buf;
if (NULL != tmp_str)
typeSize = HDstrlen(tmp_str);
}
else {
tmp_str = cptr;
}
pad = H5Tget_strpad(tid);
/* Check for NULL pointer for string */
if (!tmp_str) {
if (NULL == (this_str = (char *) HDmalloc(5)))
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
HDstrncpy(this_str, "NULL", 5);
}
else {
@@ -762,7 +837,6 @@ h5str_sprintf
case H5T_INTEGER:
{
H5T_sign_t nsign = H5T_SGN_ERROR;
if (H5T_SGN_ERROR == (nsign = H5Tget_sign(tid)))
H5_LIBRARY_ERROR(ENVONLY);
@@ -779,7 +853,7 @@ h5str_sprintf
if (NULL == (this_str = (char *) HDmalloc(7)))
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
if (HDsprintf(this_str, "%u", tmp_uchar) < 0)
if (HDsprintf(this_str, "%hhu", tmp_uchar) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure");
}
else {
@@ -806,7 +880,7 @@ h5str_sprintf
if (NULL == (this_str = (char *) HDmalloc(9)))
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
if (HDsprintf(this_str, "%u", tmp_ushort) < 0)
if (HDsprintf(this_str, "%hu", tmp_ushort) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure");
}
else {
@@ -815,7 +889,7 @@ h5str_sprintf
if (NULL == (this_str = (char *) HDmalloc(9)))
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
if (HDsprintf(this_str, "%d", tmp_short) < 0)
if (HDsprintf(this_str, "%hd", tmp_short) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure");
}
@@ -984,96 +1058,122 @@ h5str_sprintf
break;
}
if (H5R_DSET_REG_REF_BUF_SIZE == typeSize) {
H5S_sel_type region_type = H5S_SEL_ERROR;
hid_t region_obj = H5I_INVALID_HID;
hid_t region = H5I_INVALID_HID;
char ref_name[1024];
if (H5Tequal(tid, H5T_STD_REF)) {
H5O_type_t obj_type; /* Object type */
H5R_type_t ref_type; /* Reference type */
const H5R_ref_t *ref_vp = (H5R_ref_t *)cptr;
/*
* Dataset region reference --
* show the type and the referenced object
*/
ref_type = H5Rget_type(ref_vp);
H5Rget_obj_type3(ref_vp, H5P_DEFAULT, &obj_type);
switch (ref_type) {
case H5R_OBJECT1:
{
/* Object references -- show the type and OID of the referenced object. */
H5O_info_t oi;
/* Get name of the dataset the region reference points to using H5Rget_name */
if ((region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, cptr)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if ((region = H5Rget_region(container, H5R_DATASET_REGION, cptr)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (expand_data) {
if (H5S_SEL_ERROR == (region_type = H5Sget_select_type(region)))
H5_LIBRARY_ERROR(ENVONLY);
if (H5S_SEL_POINTS == region_type) {
if (h5str_dump_region_points_data(ENVONLY, out_str, region, region_obj) < 0)
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
else {
if (h5str_dump_region_blocks_data(ENVONLY, out_str, region, region_obj) < 0)
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
}
else {
if (H5Rget_name(region_obj, H5R_DATASET_REGION, cptr, (char *)ref_name, 1024) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (!h5str_append(out_str, ref_name))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
if (H5S_SEL_ERROR == (region_type = H5Sget_select_type(region)))
H5_LIBRARY_ERROR(ENVONLY);
if (H5S_SEL_POINTS == region_type) {
if (!h5str_append(out_str, " REGION_TYPE POINT"))
if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
H5Oget_info2(obj, &oi, H5O_INFO_BASIC);
if(H5Oclose(obj) < 0)
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
else
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
if (h5str_dump_region_points(ENVONLY, out_str, region, region_obj) < 0)
if (NULL == (this_str = (char *) HDmalloc(14)))
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
if (HDsprintf(this_str, "%u-", (unsigned) oi.type) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure");
if (!h5str_append(out_str, this_str))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
else {
if (!h5str_append(out_str, " REGION_TYPE BLOCK"))
HDfree(this_str);
this_str = NULL;
switch (obj_type) {
case H5O_TYPE_GROUP:
if (!h5str_append(out_str, H5_TOOLS_GROUP))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
case H5O_TYPE_DATASET:
if (!h5str_append(out_str, H5_TOOLS_DATASET))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
case H5O_TYPE_NAMED_DATATYPE:
if (!h5str_append(out_str, H5_TOOLS_DATATYPE))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
case H5O_TYPE_MAP:
case H5O_TYPE_UNKNOWN:
case H5O_TYPE_NTYPES:
default:
break;
} /* end switch */
H5Oclose(obj);
h5str_sprint_reference(ENVONLY, out_str, container, ref_vp);
/* Print OID */
if (NULL == (this_str = (char *) HDmalloc(64)))
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
if (HDsprintf(this_str, "%lu:"H5_PRINTF_HADDR_FMT" ", oi.fileno, oi.addr) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure");
}
break;
case H5R_DATASET_REGION1:
if (!h5str_append(out_str, H5_TOOLS_DATASET))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr);
break;
case H5R_OBJECT2:
switch (obj_type) {
case H5O_TYPE_GROUP:
if (!h5str_append(out_str, H5_TOOLS_GROUP))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
if (h5str_dump_region_blocks(ENVONLY, out_str, region, region_obj) < 0)
case H5O_TYPE_DATASET:
if (!h5str_append(out_str, H5_TOOLS_DATASET))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
case H5O_TYPE_NAMED_DATATYPE:
if (!h5str_append(out_str, H5_TOOLS_DATATYPE))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
case H5O_TYPE_MAP:
case H5O_TYPE_UNKNOWN:
case H5O_TYPE_NTYPES:
default:
break;
} /* end switch */
h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr);
break;
case H5R_DATASET_REGION2:
if (!h5str_append(out_str, H5_TOOLS_DATASET))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
}
}
if (H5Sclose(region) < 0)
H5_LIBRARY_ERROR(ENVONLY);
region = H5I_INVALID_HID;
if (H5Dclose(region_obj) < 0)
H5_LIBRARY_ERROR(ENVONLY);
region_obj = H5I_INVALID_HID;
h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr);
break;
case H5R_ATTR:
if (!h5str_append(out_str, H5_TOOLS_ATTRIBUTE))
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr);
break;
case H5R_BADTYPE:
case H5R_MAXTYPE:
default:
break;
} /* end switch */
}
else if (H5R_OBJ_REF_BUF_SIZE == typeSize) {
H5O_info_t oi;
hid_t obj = H5I_INVALID_HID;
/*
* Object references -- show the type and OID of the referenced
* object.
*/
if (NULL == (this_str = (char *) HDmalloc(64)))
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
if ((obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, cptr)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (H5Oget_info2(obj, &oi, H5O_INFO_ALL) < 0)
H5_LIBRARY_ERROR(ENVONLY);
/* Print object data and close object */
if (HDsprintf(this_str, "%u-%lu", (unsigned) oi.type, oi.addr) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure");
if (H5Oclose(obj) < 0)
H5_LIBRARY_ERROR(ENVONLY);
obj = H5I_INVALID_HID;
else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
/* (H5R_DSET_REG_REF_BUF_SIZE == typeSize) */
H5_LIBRARY_ERROR(ENVONLY);
}
else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
/* (H5R_OBJ_REF_BUF_SIZE == typeSize) */
H5_LIBRARY_ERROR(ENVONLY);
}
break;
@@ -2204,20 +2304,28 @@ h5str_render_bin_output
case H5T_REFERENCE:
{
if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
if (H5Tequal(tid, H5T_STD_REF)) {
hid_t region_id = H5I_INVALID_HID;
hid_t region_space = H5I_INVALID_HID;
H5S_sel_type region_type;
hid_t region_id, region_space;
/* Region data */
for (block_index = 0; block_index < block_nelmts; block_index++) {
mem = ((unsigned char*)_mem) + block_index * size;
if ((region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem)) < 0)
if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0)
continue;
if ((region_space = H5Rget_region(container, H5R_DATASET_REGION, mem)) < 0) {
else {
if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
if (!h5str_is_zero(mem, H5Tget_size(H5T_STD_REF))) {
region_type = H5Sget_select_type(region_space);
if (region_type == H5S_SEL_POINTS)
ret_value = render_bin_output_region_points(stream, region_space, region_id, container);
else
ret_value = render_bin_output_region_blocks(stream, region_space, region_id, container);
}
H5Sclose(region_space);
} /* end if (region_space >= 0) */
H5Dclose(region_id);
continue;
}
if ((region_type = H5Sget_select_type(region_space)) < 0) {
@@ -2225,19 +2333,13 @@ h5str_render_bin_output
H5Dclose(region_id);
continue;
}
if (region_type == H5S_SEL_POINTS)
ret_value = render_bin_output_region_points(stream, region_space, region_id, container);
else
ret_value = render_bin_output_region_blocks(stream, region_space, region_id, container);
H5Sclose(region_space);
H5Dclose(region_id);
if (ret_value < 0)
break;
}
}
else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
;
}
else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
;
}
@@ -3091,15 +3193,15 @@ done:
} /* end Java_hdf_hdf5lib_H5_H5Dcopy */
/*
/////////////////////////////////////////////////////////////////////////////////
//
//
// Add these methods so that we don't need to call H5Gget_objtype_by_idx
// in a loop to get information for all the objects in a group, which takes
// a lot of time to finish if the number of objects is more than 10,000
//
/////////////////////////////////////////////////////////////////////////////////
*/
* /////////////////////////////////////////////////////////////////////////////////
* //
* //
* // Add these methods so that we don't need to call H5Gget_objtype_by_idx
* // in a loop to get information for all the objects in a group, which takes
* // a lot of time to finish if the number of objects is more than 10,000
* //
* /////////////////////////////////////////////////////////////////////////////////
*/
#ifdef __cplusplus
herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data);
+1
View File
@@ -40,6 +40,7 @@ extern void h5str_free(h5str_t *str);
extern void h5str_resize(h5str_t *str, size_t new_len);
extern char* h5str_append(h5str_t *str, const char* cstr);
extern size_t h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, size_t out_buf_offset);
extern void h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, hid_t container, void *ref_p);
extern size_t h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, size_t in_buf_len, int expand_data);
extern void h5str_array_free(char **strs, size_t len);
extern int h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order);
+20 -20
View File
@@ -101,7 +101,7 @@ JNIEXPORT jfloatArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B
(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */
{
jfloatArray rarray;
jfloatArray rarray = NULL;
jboolean bb;
jfloat *farray = NULL;
jfloat *iap = NULL;
@@ -152,7 +152,7 @@ JNIEXPORT jshortArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B
(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */
{
jshortArray rarray;
jshortArray rarray = NULL;
jboolean bb;
jshort *sarray = NULL;
jshort *iap = NULL;
@@ -203,7 +203,7 @@ JNIEXPORT jlongArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B
(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */
{
jlongArray rarray;
jlongArray rarray = NULL;
jboolean bb;
jlong *larray = NULL;
jlong *iap = NULL;
@@ -254,7 +254,7 @@ JNIEXPORT jdoubleArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B
(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */
{
jdoubleArray rarray;
jdoubleArray rarray = NULL;
jboolean bb;
jdouble *darray = NULL;
jdouble *iap = NULL;
@@ -305,7 +305,7 @@ JNIEXPORT jintArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B
(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */
{
jintArray rarray;
jintArray rarray = NULL;
jboolean bb;
jint *iarray = NULL;
jint *iap = NULL;
@@ -357,7 +357,7 @@ JNIEXPORT jshortArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B
(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */
{
jshortArray rarray;
jshortArray rarray = NULL;
jboolean bb;
jshort *sarray = NULL;
jshort *iap = NULL;
@@ -409,7 +409,7 @@ JNIEXPORT jfloatArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B
(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */
{
jfloatArray rarray;
jfloatArray rarray = NULL;
jboolean bb;
jfloat *farray = NULL;
jfloat *iap = NULL;
@@ -461,7 +461,7 @@ JNIEXPORT jlongArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B
(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */
{
jlongArray rarray;
jlongArray rarray = NULL;
jboolean bb;
jlong *larray = NULL;
jlong *iap = NULL;
@@ -513,7 +513,7 @@ JNIEXPORT jdoubleArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B
(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */
{
jdoubleArray rarray;
jdoubleArray rarray = NULL;
jboolean bb;
jdouble *darray = NULL;
jdouble *iap = NULL;
@@ -565,7 +565,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I
(JNIEnv *env, jclass clss, jint start, jint len, jintArray idata) /* IN: array of int */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jbyte *barray = NULL;
jbyte *bap = NULL;
@@ -627,7 +627,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S
(JNIEnv *env, jclass clss, jint start, jint len, jshortArray sdata) /* IN: array of short */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jshort *ip = NULL;
jshort *sarr = NULL;
@@ -689,7 +689,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F
(JNIEnv *env, jclass clss, jint start, jint len, jfloatArray fdata) /* IN: array of float */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jfloat *ip = NULL;
jfloat *farr = NULL;
@@ -751,7 +751,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D
(JNIEnv *env, jclass clss, jint start, jint len, jdoubleArray ddata) /* IN: array of double */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jdouble *ip = NULL;
jdouble *darr = NULL;
@@ -813,7 +813,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J
(JNIEnv *env, jclass clss, jint start, jint len, jlongArray ldata) /* IN: array of long */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jlong *ip = NULL;
jlong *larr = NULL;
@@ -875,7 +875,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_intToByte__I
(JNIEnv *env, jclass clss, jint idata) /* IN: int */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jbyte *barray = NULL;
jbyte *bap = NULL;
@@ -911,7 +911,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_floatToByte__F
(JNIEnv *env, jclass clss, jfloat fdata) /* IN: float */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jbyte *barray = NULL;
jbyte *bap = NULL;
@@ -947,7 +947,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_shortToByte__S
(JNIEnv *env, jclass clss, jshort sdata) /* IN: short */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jbyte *barray = NULL;
jbyte *bap = NULL;
@@ -983,7 +983,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D
(JNIEnv *env, jclass clss, jdouble ddata) /* IN: double */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jbyte *barray = NULL;
jbyte *bap = NULL;
@@ -1019,7 +1019,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_longToByte__J
(JNIEnv *env, jclass clss, jlong ldata) /* IN: long */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jbyte *barray = NULL;
jbyte *bap = NULL;
@@ -1055,7 +1055,7 @@ JNIEXPORT jbyteArray JNICALL
Java_hdf_hdf5lib_HDFNativeData_byteToByte__B
(JNIEnv *env, jclass clss, jbyte bdata) /* IN: byte */
{
jbyteArray rarray;
jbyteArray rarray = NULL;
jboolean bb;
jbyte *barray = NULL;
jbyte *bap = NULL;
+143
View File
@@ -22,12 +22,17 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Reader;
import java.io.StreamTokenizer;
import hdf.hdf5lib.H5;
import hdf.hdf5lib.HDF5Constants;
import hdf.hdf5lib.exceptions.HDF5LibraryException;
import org.junit.After;
import org.junit.Before;
@@ -50,6 +55,81 @@ public class TestH5 {
public void nextTestName() {
System.out.println();
}
private static final String H5_FILE = "testData.h5";
private static final String EXPORT_FILE = "testExport.txt";
private static final int DIM_X = 4;
private static final int DIM_Y = 6;
private static final int RANK = 2;
long H5fid = -1;
long H5dsid = -1;
long H5did = -1;
long[] H5dims = { DIM_X, DIM_Y };
private final void _deleteFile(String filename) {
File file = null;
try {
file = new File(filename);
}
catch (Throwable err) {}
if (file.exists()) {
try {file.delete();} catch (SecurityException e) {}
}
}
private final long _createDataset(long fid, long dsid, String name, long dapl) {
long did = -1;
try {
did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32LE, dsid,
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, dapl);
}
catch (Throwable err) {
err.printStackTrace();
fail("H5.H5Dcreate: " + err);
}
assertTrue("TestH5._createDataset: ", did > 0);
return did;
}
private final void _createH5File() {
try {
H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC,
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
H5dsid = H5.H5Screate_simple(2, H5dims, null);
H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
fail("TestH5Pfapl.createH5file: " + err);
}
assertTrue("TestH5.createH5file: H5.H5Fcreate: ", H5fid > 0);
assertTrue("TestH5.createH5file: H5.H5Screate_simple: ", H5dsid > 0);
assertTrue("TestH5.createH5file: _createDataset: ", H5did > 0);
try {
H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL);
}
catch (Throwable err) {
err.printStackTrace();
}
}
public final void _closeH5File() throws HDF5LibraryException {
if (H5did >= 0)
try {H5.H5Dclose(H5did);} catch (Exception ex) {}
if (H5dsid > 0)
try {H5.H5Sclose(H5dsid);} catch (Exception ex) {}
if (H5fid > 0)
try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
H5fid = -1;
H5dsid = -1;
H5did = -1;
}
public final void _deleteH5file() {
_deleteFile(H5_FILE);
}
/**
* Test method for {@link hdf.hdf5lib.H5#J2C(int)}.
@@ -268,4 +348,67 @@ public class TestH5 {
fail("Exception thrown during test: " + ex.toString());
}
}
@Test
public void testH5export_dataset() {
int[][] dset_data = new int[DIM_X][DIM_Y];
int[][] dset_indata = new int[DIM_X][DIM_Y];
int FILLVAL = 99;
_createH5File();
// Initialize the dataset.
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++)
dset_data[indx][jndx] = FILLVAL;
try {
if (H5did >= 0)
H5.H5Dwrite(H5did, HDF5Constants.H5T_STD_I32LE,
HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, dset_data);
}
catch (Exception e) {
e.printStackTrace();
}
_closeH5File();
try {
H5.H5export_dataset(EXPORT_FILE, H5_FILE, "/dset", 99);
}
catch (HDF5LibraryException err) {
err.printStackTrace();
fail("H5export_dataset failed: " + err);
}
File file = new File(EXPORT_FILE);
try {
Reader reader = new FileReader(EXPORT_FILE);
StreamTokenizer streamTokenizer = new StreamTokenizer(reader);
int indx = 0;
int jndx = 0;
while(streamTokenizer.nextToken() != StreamTokenizer.TT_EOF){
if(streamTokenizer.ttype == StreamTokenizer.TT_NUMBER) {
dset_indata[indx][jndx] = (int)streamTokenizer.nval;
jndx++;
if (jndx >= DIM_Y) {
jndx = 0;
indx++;
}
}
}
reader.close();
}
catch (IOException err) {
err.printStackTrace();
fail("read file failed: " + err);
}
for(int row = 0; row < DIM_X; row++)
for(int col = 0; col < DIM_Y; col++) {
assertTrue("H5export_dataset: <"+row+","+col+">"+dset_indata[row][col]+"=99", dset_indata[row][col]==99);
}
_deleteH5file();
}
}
+1 -1
View File
@@ -366,7 +366,7 @@ public class TestH5Edefault {
}
assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
// Se the current stack to be the default and try that again
// Set the current stack to be the default and try that again
try {
H5.H5Eset_current_stack(stack_id);
num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
+384 -33
View File
@@ -14,6 +14,7 @@
package test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -24,9 +25,11 @@ import hdf.hdf5lib.H5;
import hdf.hdf5lib.HDF5Constants;
import hdf.hdf5lib.exceptions.HDF5Exception;
import hdf.hdf5lib.exceptions.HDF5LibraryException;
import hdf.hdf5lib.exceptions.HDF5FunctionArgumentException;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@@ -42,6 +45,8 @@ public class TestH5R {
long H5gid = -1;
long H5did2 = -1;
long[] H5dims = { DIM_X, DIM_Y };
int[][] dset_data = new int[DIM_X][DIM_Y];
int FILLVAL = 99;
private final void _deleteFile(String filename) {
File file = null;
@@ -51,8 +56,9 @@ public class TestH5R {
catch (Throwable err) {}
if (file.exists()) {
try {file.delete();} catch (SecurityException e) {}
try {file.delete();} catch (SecurityException e) {e.printStackTrace();}
}
assertFalse("TestH5R._deleteFile file still exists ", file.exists());
}
private final long _createDataset(long fid, long dsid, String name, long dapl) {
@@ -66,7 +72,7 @@ public class TestH5R {
err.printStackTrace();
fail("H5.H5Dcreate: " + err);
}
assertTrue("TestH5R._createDataset: ",did > 0);
assertTrue("TestH5R._createDataset: ", did > 0);
return did;
}
@@ -100,6 +106,21 @@ public class TestH5R {
H5did2 = _createDataset(H5gid, H5dsid, "dset2", HDF5Constants.H5P_DEFAULT);
H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
// Initialize the dataset.
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++)
dset_data[indx][jndx] = FILLVAL;
try {
if (H5did >= 0)
H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT,
HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, dset_data[0]);
}
catch (Exception e) {
e.printStackTrace();
}
}
catch (Throwable err) {
err.printStackTrace();
@@ -129,13 +150,15 @@ public class TestH5R {
System.out.println();
}
@Test
// Test v1.8 APIs params
@Ignore
public void testH5Rget_name() {
long loc_id=H5fid;
int ref_type=HDF5Constants.H5R_OBJECT;
long ret_val=-1;
byte[] ref=null;
String[] name= {""};
long loc_id = H5fid;
int ref_type = HDF5Constants.H5R_OBJECT;
long ret_val = -1;
byte[] ref = null;
String[] name = {""};
String objName = "/dset";
try {
@@ -158,13 +181,13 @@ public class TestH5R {
assertTrue("The name of the object: ", objName.equals(name[0]));
}
@Test
@Ignore
public void testH5Rget_obj_type2() {
int ref_type=HDF5Constants.H5R_OBJECT;
byte[] ref=null;
String objName = "/dset";
int obj_type = -1;;
int obj_type = -1;
try {
ref = H5.H5Rcreate(H5fid, objName, ref_type, -1);
@@ -183,7 +206,7 @@ public class TestH5R {
assertEquals(obj_type, HDF5Constants.H5O_TYPE_DATASET);
}
@Test
@Ignore
public void testH5Rcreate_refobj() {
byte[] ref = null;
@@ -197,7 +220,7 @@ public class TestH5R {
assertNotNull(ref);
}
@Test
@Ignore
public void testH5Rcreate_regionrefobj() {
byte[] ref = null;
try {
@@ -210,7 +233,7 @@ public class TestH5R {
assertNotNull(ref);
}
@Test
@Ignore
public void testH5Rdereference() {
byte[] ref1 = null;
byte[] ref2 = null;
@@ -226,8 +249,8 @@ public class TestH5R {
group_id= H5.H5Rdereference(H5gid, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5R_OBJECT, ref2);
assertNotNull(ref1);
assertNotNull(ref2);
assertTrue(dataset_id>=0);
assertTrue(group_id>=0);
assertTrue(dataset_id >= 0);
assertTrue(group_id >= 0);
}
catch (Throwable err) {
err.printStackTrace();
@@ -239,7 +262,7 @@ public class TestH5R {
}
}
@Test
@Ignore
public void testH5Rget_region() {
byte[] ref = null;
long dsid = -1;
@@ -247,7 +270,7 @@ public class TestH5R {
ref = H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_DATASET_REGION, H5dsid);
dsid = H5.H5Rget_region(H5fid, HDF5Constants.H5R_DATASET_REGION, ref);
assertNotNull(ref);
assertTrue(dsid>=0);
assertTrue(dsid >= 0);
}
catch (Throwable err) {
err.printStackTrace();
@@ -258,70 +281,70 @@ public class TestH5R {
}
}
@Test(expected = IllegalArgumentException.class)
@Ignore//(expected = IllegalArgumentException.class)
public void testH5Rget_name_Invalidreftype() throws Throwable {
byte[] ref = null;
String[] name= {""};
String[] name = {""};
ref = H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_OBJECT, -1);
H5.H5Rget_name(H5fid, HDF5Constants.H5R_DATASET_REGION, ref, name, 16);
}
@Test(expected = NullPointerException.class)
@Ignore//(expected = NullPointerException.class)
public void testH5Rget_name_NULLreference() throws Throwable {
byte[] ref = null;
String[] name= {""};
String[] name = {""};
H5.H5Rget_name(H5fid, HDF5Constants.H5R_OBJECT, ref, name, 16);
}
@Test(expected = HDF5LibraryException.class)
@Ignore//(expected = HDF5LibraryException.class)
public void testH5Rget_obj_type2_Invalidreftype() throws Throwable {
byte[] ref = null;
ref = H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_OBJECT, -1);
H5.H5Rget_obj_type(H5fid, HDF5Constants.H5R_DATASET_REGION, ref);
}
@Test(expected = HDF5LibraryException.class)
@Ignore//(expected = HDF5LibraryException.class)
public void testH5Rcreate_InvalidObjectName() throws Throwable {
H5.H5Rcreate(H5fid, "/GROUPS", HDF5Constants.H5R_OBJECT, -1);
byte[] ref=H5.H5Rcreate(H5fid, "/GROUPS", HDF5Constants.H5R_OBJECT, -1);
}
@Test(expected = HDF5LibraryException.class)
@Ignore//(expected = HDF5LibraryException.class)
public void testH5Rcreate_Invalidspace_id() throws Throwable {
H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_DATASET_REGION, -1);
byte[] ref=H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_DATASET_REGION, -1);
}
@Test(expected = IllegalArgumentException.class)
@Ignore//(expected = IllegalArgumentException.class)
public void testH5Rcreate_Invalidreftype() throws Throwable {
H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_BADTYPE, -1);
byte[] ref=H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_BADTYPE, -1);
}
@Test(expected = IllegalArgumentException.class)
@Ignore//(expected = IllegalArgumentException.class)
public void testH5Rgetregion_Invalidreftype() throws Throwable {
byte[] ref = null;
ref = H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_OBJECT, H5dsid);
H5.H5Rget_region(H5fid, HDF5Constants.H5R_DATASET_REGION, ref);
}
@Test(expected = IllegalArgumentException.class)
@Ignore//(expected = IllegalArgumentException.class)
public void testH5Rgetregion_Badreferencetype() throws Throwable {
byte[] ref = null;
ref = H5.H5Rcreate(H5fid, "/dset", HDF5Constants.H5R_OBJECT, H5dsid);
H5.H5Rget_region(H5fid, HDF5Constants.H5R_OBJECT, ref);
}
@Test(expected = NullPointerException.class)
@Ignore//(expected = NullPointerException.class)
public void testH5Rgetregion_Nullreference() throws Throwable {
byte[] ref = null;
H5.H5Rget_region(H5fid, HDF5Constants.H5R_DATASET_REGION, ref);
}
@Test(expected = NullPointerException.class)
@Ignore//(expected = NullPointerException.class)
public void testH5Rdereference_Nullreference() throws Throwable {
byte[] ref = null;
H5.H5Rdereference(H5did2, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5R_OBJECT, ref);
}
@Test(expected = IllegalArgumentException.class)
@Ignore//(expected = IllegalArgumentException.class)
public void testH5Rdereference_Invalidreference() throws Throwable {
byte[] ref1 = null;
byte[] ref2 = null;
@@ -330,4 +353,332 @@ public class TestH5R {
H5.H5Rdereference(H5gid, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5R_OBJECT, ref1);
}
// Test v1.12 APIs params
@Test
public void testH5Rget_object() {
int ref_type = HDF5Constants.H5R_OBJECT2;
long ret_val = -1;
byte[] ref = null;
String name = "";
String objName = "/dset";
try {
ref = H5.H5Rcreate_object(H5fid, objName, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_object: H5Rcreate_object " + err);
}
try {
ret_val = H5.H5Rget_type(ref);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_object: H5Rget_type: " + err);
}
assertTrue("testH5Rget_object: H5Rget_type", ret_val == ref_type);
try {
name = H5.H5Rget_file_name(ref);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_object: H5Rget_file_name: " + err);
}
assertTrue("testH5Rget_object: H5Rget_file_name", H5_FILE.equals(name));
try {
name = H5.H5Rget_obj_name(ref, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_object: H5Rget_obj_name: " + err);
}
assertTrue("The name of the object: ", objName.equals(name));
}
@Test
public void testH5Rget_obj_type3() {
int obj_type = -1;
byte[] ref = null;
String objName = "/dset";
try {
ref = H5.H5Rcreate_object(H5fid, objName, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_obj_type3: H5Rcreate_object " + err);
}
try {
obj_type = H5.H5Rget_obj_type3(ref, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_obj_type3: H5.H5Rget_obj_type3: " + err);
}
assertEquals(obj_type, HDF5Constants.H5O_TYPE_DATASET);
}
@Test
public void testH5Rcreate_regionref_object() {
byte[] ref = null;
String objName = "/dset";
long start[] = {2,2}; // Starting location of hyperslab
long stride[] = {1,1}; // Stride of hyperslab
long count[] = {1,1}; // Element count of hyperslab
long block[] = {3,3}; // Block size of hyperslab
// Select 3x3 hyperslab for reference
try {
H5.H5Sselect_hyperslab(H5dsid, HDF5Constants.H5S_SELECT_SET, start, stride, count, block);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_object: H5Sselect_hyperslab " + err);
}
try {
ref = H5.H5Rcreate_region(H5fid, objName, H5dsid, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
fail("testH5Rget_object: H5Rcreate_region " + err);
}
assertNotNull(ref);
}
// These tests need to be updated with new APIs
// @Test//
// public void testH5Rget_group() {
// long loc_id = H5fid;
// int ref_type = HDF5Constants.H5R_OBJECT2;
// long ret_val = -1;
// byte[] ref = null;
// String name = "";
// String objName = "/dset";
//
// try {
// ref = H5.H5Rcreate_object(H5fid, objName, HDF5Constants.H5P_DEFAULT);
// }
// catch (Throwable err) {
// err.printStackTrace();
// fail("testH5Rget_object: H5Rcreate_object " + err);
// }
// try {
// dataset_id= H5.H5Rdereference(H5fid, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5R_DATASET_REGION, ref1);
//
// //Create reference on group
// ref2 = H5.H5Rcreate(H5gid, "/Group1", HDF5Constants.H5R_OBJECT, -1);
// group_id= H5.H5Rdereference(H5gid, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5R_OBJECT, ref2);
// assertNotNull(ref1);
// assertNotNull(ref2);
// assertTrue(dataset_id >= 0);
// assertTrue(group_id >= 0);
// }
// catch (Throwable err) {
// err.printStackTrace();
// fail("TestH5Rdereference " + err);
// }
// finally {
// try {H5.H5Dclose(dataset_id);} catch (Exception ex) {}
// try {H5.H5Gclose(group_id);} catch (Exception ex) {}
// }
// }
// @Test//
// public void testH5Rget_region_dataset() {
// long loc_id = H5fid;
// int ref_type = HDF5Constants.H5R_OBJECT2;
// long ret_val = -1;
// byte[] ref = null;
// String name = "";
// String objName = "/dset";
//
// try {
// ref = H5.H5Rcreate_object(H5fid, objName, HDF5Constants.H5P_DEFAULT);
// }
// catch (Throwable err) {
// err.printStackTrace();
// fail("testH5Rget_object: H5Rcreate_object " + err);
// }
// try {
// dsid = H5.H5Rget_region(H5fid, HDF5Constants.H5R_DATASET_REGION, ref);
// assertNotNull(ref);
// assertTrue(dsid >= 0);
// }
// catch (Throwable err) {
// err.printStackTrace();
// fail("TestH5Rget_region: " + err);
// }
// finally {
// try {H5.H5Sclose(dsid);} catch (Exception ex) {}
// }
// }
// @Test//
// public void testH5Rget_attr() {
// long loc_id = H5fid;
// int ref_type = HDF5Constants.H5R_OBJECT2;
// long ret_val = -1;
// byte[] ref = null;
// String name = "";
// String objName = "/dset";
//
// try {
// ref = H5.H5Rcreate_object(H5fid, objName, HDF5Constants.H5P_DEFAULT);
// }
// catch (Throwable err) {
// err.printStackTrace();
// fail("testH5Rget_object: H5Rcreate_object " + err);
// }
// try {
// dsid = H5.H5Rget_region(H5fid, HDF5Constants.H5R_DATASET_REGION, ref);
// assertNotNull(ref);
// assertTrue(dsid >= 0);
// }
// catch (Throwable err) {
// err.printStackTrace();
// fail("TestH5Rget_region: " + err);
// }
// finally {
// try {H5.H5Sclose(dsid);} catch (Exception ex) {}
// }
// }
// Test parameters to H5Rcreate_object
@Test(expected = NullPointerException.class)
public void testH5Rcreate_object_Nullname() throws Throwable {
String name = null;
H5.H5Rcreate_object(H5fid, name, HDF5Constants.H5P_DEFAULT);
}
@Test(expected = HDF5FunctionArgumentException.class)
public void testH5Rget_name_Invalidloc() throws Throwable {
String name= "";
H5.H5Rcreate_object(-1, name, HDF5Constants.H5P_DEFAULT);
}
// Test parameters to H5Rcreate_region
@Test(expected = NullPointerException.class)
public void testH5Rcreate_region_Nullname() throws Throwable {
String name = null;
H5.H5Rcreate_region(H5fid, name, -1, HDF5Constants.H5P_DEFAULT);
}
@Test(expected = HDF5FunctionArgumentException.class)
public void testH5Rcreate_region_Invalidloc() throws Throwable {
String name= "";
H5.H5Rcreate_region(-1, name, -1, HDF5Constants.H5P_DEFAULT);
}
// Test parameters to H5Rcreate_attr
@Test(expected = NullPointerException.class)
public void testH5Rcreate_attr_Nullname() throws Throwable {
String name = null;
String attrname = "";
H5.H5Rcreate_attr(H5fid, name, attrname, HDF5Constants.H5P_DEFAULT);
}
@Test(expected = NullPointerException.class)
public void testH5Rcreate_attr_Nullattrname() throws Throwable {
String name = "";
String attrname = null;
H5.H5Rcreate_attr(H5fid, name, attrname, HDF5Constants.H5P_DEFAULT);
}
@Test(expected = HDF5FunctionArgumentException.class)
public void testH5Rcreate_attr_Invalidloc() throws Throwable {
String name= "";
String attrname= "";
H5.H5Rcreate_attr(-1, name, attrname, HDF5Constants.H5P_DEFAULT);
}
// Test parameters to H5Rdestroy
@Test(expected = NullPointerException.class)
public void testH5Rdestroy_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Rdestroy(ref);
}
// Test parameters to H5Rget_type
@Test(expected = NullPointerException.class)
public void testH5Rget_type_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Rget_type(ref);
}
// Test parameters to H5Requal
@Test(expected = NullPointerException.class)
public void testH5Requal_Nullref1() throws Throwable {
byte[] ref1 = null;
byte[] ref2 = {0,0,0,0};
H5.H5Requal(ref1, ref2);
}
@Test(expected = NullPointerException.class)
public void testH5Requal_Nullref2() throws Throwable {
byte[] ref1 = {0,0,0,0};
byte[] ref2 = null;
H5.H5Requal(ref1, ref2);
}
// Test parameters to H5Rcopy
@Test(expected = NullPointerException.class)
public void testH5Rcopy_Nullref1() throws Throwable {
byte[] ref1 = null;
byte[] ref2 = H5.H5Rcopy(ref1);
}
// Test parameters to H5Ropen_object
@Test(expected = NullPointerException.class)
public void testH5Ropen_object_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Ropen_object(ref, -1, -1);
}
// Test parameters to H5Ropen_region
@Test(expected = NullPointerException.class)
public void testH5Ropen_region_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Ropen_region(ref, -1, -1);
}
// Test parameters to H5Ropen_attr
@Test(expected = NullPointerException.class)
public void testH5Ropen_attr_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Ropen_attr(ref, -1, -1);
}
// Test parameters to H5Rget_obj_type3
@Test(expected = NullPointerException.class)
public void testH5Rget_obj_type3_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Rget_obj_type3(ref, -1);
}
// Test parameters to H5Rget_file_name
@Test(expected = NullPointerException.class)
public void testH5Rget_file_name_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Rget_file_name(ref);
}
// Test parameters to H5Rget_obj_name
@Test(expected = NullPointerException.class)
public void testH5Rget_obj_name_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Rget_obj_name(ref, -1);
}
// Test parameters to H5Rget_attr_name
@Test(expected = NullPointerException.class)
public void testH5Rget_attr_name_Nullref() throws Throwable {
byte[] ref = null;
H5.H5Rget_attr_name(ref);
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
JUnit version 4.11
.testH5get_libversion_null_param
.testJ2C
.testH5export_dataset
.testIsSerializable
.testH5garbage_collect
.testH5error_off
@@ -12,5 +13,5 @@ JUnit version 4.11
Time: XXXX
OK (10 tests)
OK (11 tests)
+23 -18
View File
@@ -1,23 +1,28 @@
JUnit version 4.11
.testH5Rgetregion_Nullreference
.testH5Rget_obj_type2_Invalidreftype
.testH5Rdereference
.testH5Rget_name
.testH5Rcreate_Invalidreftype
.testH5Rget_name_NULLreference
.testH5Rget_region
.testH5Rdereference_Nullreference
.testH5Rcreate_refobj
.testH5Rcreate_Invalidspace_id
.testH5Rdereference_Invalidreference
.testH5Rgetregion_Badreferencetype
.testH5Rcreate_regionrefobj
.testH5Rget_name_Invalidreftype
.testH5Rgetregion_Invalidreftype
.testH5Rget_obj_type2
.testH5Rcreate_InvalidObjectName
.testH5Ropen_attr_Nullref
.testH5Rget_attr_name_Nullref
.testH5Ropen_region_Nullref
.testH5Requal_Nullref1
.testH5Requal_Nullref2
.testH5Rget_object
.testH5Rget_obj_type3_Nullref
.testH5Ropen_object_Nullref
.testH5Rdestroy_Nullref
.testH5Rcreate_object_Nullname
.testH5Rget_obj_type3
.testH5Rget_name_Invalidloc
.testH5Rcopy_Nullref1
.testH5Rcreate_attr_Invalidloc
.testH5Rget_file_name_Nullref
.testH5Rget_obj_name_Nullref
.testH5Rcreate_region_Nullname
.testH5Rcreate_regionref_object
.testH5Rcreate_attr_Nullattrname
.testH5Rcreate_region_Invalidloc
.testH5Rget_type_Nullref
.testH5Rcreate_attr_Nullname
Time: XXXX
OK (17 tests)
OK (22 tests)