summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5dImp.c
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2017-04-13 21:40:56 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2017-04-13 21:40:56 (GMT)
commitb77e601996ea89c8a25f0ce12e3a6a0058fac63e (patch)
treee0ba810f8994d14e5b984d0519f4f3c0bbd0fcc4 /java/src/jni/h5dImp.c
parentf6920ad11c9c9b9033bbc9af1c6f08aacca15316 (diff)
parentb03e41146a3e15c7a287ab98f1963bf7944719a8 (diff)
downloadhdf5-b77e601996ea89c8a25f0ce12e3a6a0058fac63e.zip
hdf5-b77e601996ea89c8a25f0ce12e3a6a0058fac63e.tar.gz
hdf5-b77e601996ea89c8a25f0ce12e3a6a0058fac63e.tar.bz2
Merge pull request #425 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:hdf5_1_10 to hdf5_1_10
* commit 'b03e41146a3e15c7a287ab98f1963bf7944719a8': Skip tests for page buffering in test/fheap.c for parallel build Skip the two tests for page buffering in test/fheap.c because this feature is disabled in parallel. Activate full testing when this feature is re-enabled in the future for parallel build. Due to HDFVIEW-19 add read VL as string function Fix URL name updated with README changes DAILYTEST-250 change test props to reduce timeout Combined the README_DEVEL and README, and removed out-dated README material Fix for H5Dset_extent test failure with extensive array indexing (HDFFV-9771) 1) Calculate chunk index for extensive array index based on swizzled max chunks when unlim_dim > 0 2) Minor fixes to test/fheap.c that somehow were missed from last check in. See pull request #396 review comments.
Diffstat (limited to 'java/src/jni/h5dImp.c')
-rw-r--r--java/src/jni/h5dImp.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c
index 9765dc8..0bb015e 100644
--- a/java/src/jni/h5dImp.c
+++ b/java/src/jni/h5dImp.c
@@ -55,6 +55,7 @@ extern jobject visit_callback;
/* Local Prototypes */
/********************/
+static herr_t H5DreadVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DreadVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DreadVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DwriteVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
@@ -994,6 +995,96 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1double
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5DreadVL
+ * Signature: (JJJJJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5DreadVL
+ (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
+ jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
+{
+ herr_t status = -1;
+ htri_t isVlenStr=0;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5DreadVL: buf is NULL");
+ } /* end if */
+ else {
+ isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
+
+ if (isVlenStr)
+ h5badArgument(env, "H5DreadVL: type is not variable length non-string");
+ else
+ status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id,
+ (hid_t)mem_space_id, (hid_t)file_space_id,
+ (hid_t)xfer_plist_id, buf);
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Dread_1VLStrings */
+
+herr_t
+H5DreadVL_asstr
+ (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
+{
+ jint i;
+ jint n;
+ jstring jstr;
+ h5str_t h5str;
+ hvl_t *rdata;
+ size_t size;
+ size_t max_len = 0;
+ herr_t status = -1;
+
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+ if (rdata == NULL) {
+ h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buff for read");
+ } /* end if */
+ else {
+ status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, rdata);
+
+ if (status < 0) {
+ H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
+ HDfree(rdata);
+ h5JNIFatalError(env, "H5DreadVL_notstr: failed to read data");
+ } /* end if */
+ else {
+ max_len = 1;
+ for (i=0; i < n; i++) {
+ if ((rdata + i)->len > max_len)
+ max_len = (rdata + i)->len;
+ }
+
+ size = H5Tget_size(tid) * max_len;
+ HDmemset(&h5str, 0, sizeof(h5str_t));
+ h5str_new(&h5str, 4 * size);
+
+ if (h5str.s == NULL) {
+ H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
+ HDfree(rdata);
+ h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buf");
+ } /* end if */
+ else {
+ for (i=0; i < n; i++) {
+ h5str.s[0] = '\0';
+ h5str_sprintf(&h5str, did, tid, rdata+i, 0);
+ jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
+ ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
+ } /* end for */
+ h5str_free(&h5str);
+
+ H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
+ HDfree(rdata);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return status;
+}
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Dread_string
* Signature: (JJJJJ[Ljava/lang/String;)I
*/