[svn-r30213] Add H5Aread_complex for reading arrays and compounds that are not VL strings.

This commit is contained in:
Allen Byrne 2016-07-20 14:40:42 -05:00
parent 2387b1efbd
commit 9b597a4855
4 changed files with 69 additions and 3 deletions

View File

@ -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.

View File

@ -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);

View File

@ -2008,6 +2008,60 @@ Java_hdf_hdf5lib_H5_H5AreadVL
return status;
} /* 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

View File

@ -65,6 +65,15 @@ JNIEXPORT jint JNICALL
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