summaryrefslogtreecommitdiffstats
path: root/java/src/jni
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2016-07-20 19:40:42 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2016-07-20 19:40:42 (GMT)
commit9b597a48552f5201b37793a4c6fece4fd9f1c346 (patch)
tree5844133fc279f1494a2804d454a8b8f9e2c7c26e /java/src/jni
parent2387b1efbd526c23453749d161220bb717033e70 (diff)
downloadhdf5-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/src/jni')
-rw-r--r--java/src/jni/h5dImp.c6
-rw-r--r--java/src/jni/h5util.c54
-rw-r--r--java/src/jni/h5util.h9
3 files changed, 66 insertions, 3 deletions
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