diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-07-20 19:40:42 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-07-20 19:40:42 (GMT) |
commit | 9b597a48552f5201b37793a4c6fece4fd9f1c346 (patch) | |
tree | 5844133fc279f1494a2804d454a8b8f9e2c7c26e /java | |
parent | 2387b1efbd526c23453749d161220bb717033e70 (diff) | |
download | hdf5-9b597a48552f5201b37793a4c6fece4fd9f1c346.zip hdf5-9b597a48552f5201b37793a4c6fece4fd9f1c346.tar.gz hdf5-9b597a48552f5201b37793a4c6fece4fd9f1c346.tar.bz2 |
[svn-r30213] Add H5Aread_complex for reading arrays and compounds that are not VL strings.
Diffstat (limited to 'java')
-rw-r--r-- | java/src/hdf/hdf5lib/H5.java | 3 | ||||
-rw-r--r-- | java/src/jni/h5dImp.c | 6 | ||||
-rw-r--r-- | java/src/jni/h5util.c | 54 | ||||
-rw-r--r-- | java/src/jni/h5util.h | 9 |
4 files changed, 69 insertions, 3 deletions
diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index e555a4f..e4144c9 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -1061,6 +1061,9 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5AreadVL(long attr_id, long mem_type_id, String[] buf) throws HDF5LibraryException, NullPointerException; + public synchronized static native int H5AreadComplex(long attr_id, long mem_type_id, String[] buf) + throws HDF5LibraryException, NullPointerException; + /** * H5Arename changes the name of attribute that is attached to the object specified by loc_id. The attribute named * old_attr_name is renamed new_attr_name. diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 9bcbd5f..2ef14df 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -1151,7 +1151,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings h5nullArgument(env, "H5Dread_VLStrings: buf is NULL"); } /* end if */ else { - isVlenStr = H5Tis_variable_str((hid_t)mem_type_id); + isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); if (isVlenStr) { status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, @@ -1786,7 +1786,7 @@ Java_hdf_hdf5lib_H5_H5Diterate */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dflush - (JNIEnv *env, jclass clss, jlong loc_id) + (JNIEnv *env, jclass clss, jlong loc_id) { if (H5Dflush((hid_t)loc_id) < 0) h5libraryError(env); @@ -1799,7 +1799,7 @@ Java_hdf_hdf5lib_H5_H5Dflush */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Drefresh - (JNIEnv *env, jclass clss, jlong loc_id) + (JNIEnv *env, jclass clss, jlong loc_id) { if (H5Drefresh((hid_t)loc_id) < 0) h5libraryError(env); diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index e39b342..f9bd291 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -2009,6 +2009,60 @@ Java_hdf_hdf5lib_H5_H5AreadVL } /* end Java_hdf_hdf5lib_H5_H5AreadVL */ /* + * Class: hdf_hdf5lib_H5 + * Method: H5AreadComplex + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AreadComplex +(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +{ + herr_t status = -1; + int i; + int n; + char *rdata; + size_t max_len = 0; + size_t size; + h5str_t h5str; + hid_t p_type = -1; + jstring jstr; + + p_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); + size = (((H5Tget_size(mem_type_id))>(H5Tget_size(p_type))) ? (H5Tget_size(mem_type_id)) : (H5Tget_size(p_type))); + H5Tclose(p_type); + + n = ENVPTR->GetArrayLength(ENVPAR buf); + rdata = (char *)malloc((size_t)n * size); + if (rdata == NULL) { + h5JNIFatalError(env, "H5AreadComplex: failed to allocate buff for read"); + } /* end if */ + else { + status = H5Aread(attr_id, mem_type_id, rdata); + if (status < 0) { + h5JNIFatalError(env, "H5AreadComplex: failed to read data"); + } /* end if */ + else { + HDmemset(&h5str, 0, sizeof(h5str_t)); + h5str_new(&h5str, 4 * size); + if (h5str.s == NULL) { + h5JNIFatalError(env, "H5AreadComplex: failed to allocate string buf"); + } /* end if */ + else { + for (i = 0; i < n; i++) { + h5str.s[0] = '\0'; + h5str_sprintf(&h5str, attr_id, mem_type_id, rdata + ((size_t)i * size), 0); + jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); + ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + } /* end for */ + } /* end else */ + h5str_free(&h5str); + } /* end else */ + HDfree(rdata); + } /* end else */ + return status; +} + +/* * Copies the content of one dataset to another dataset * Class: hdf_hdf5lib_H5 * Method: H5Acopy diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h index ab8da98..f690e8b 100644 --- a/java/src/jni/h5util.h +++ b/java/src/jni/h5util.h @@ -66,6 +66,15 @@ Java_hdf_hdf5lib_H5_H5AreadVL (JNIEnv *, jclass, jlong, jlong, jobjectArray); /* + * Class: hdf_hdf5lib_H5 + * Method: H5AreadComplex + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AreadComplex + (JNIEnv *, jclass, jlong, jlong, jobjectArray); + +/* * Copies the content of one dataset to another dataset * Class: hdf_hdf5lib_H5 * Method: H5Acopy |