summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Willmore <Frank.Willmore@hdfgroup.org>2018-01-02 04:49:19 (GMT)
committerFrank Willmore <Frank.Willmore@hdfgroup.org>2018-01-02 04:49:19 (GMT)
commit0a5e7250a71733c8884d41713462c478e691f1bc (patch)
treef1829a6b1f8f2fb5fb067c07f88ebee36350223f
parent8621088e16255325826a5ba027b071e54934ed73 (diff)
downloadhdf5-0a5e7250a71733c8884d41713462c478e691f1bc.zip
hdf5-0a5e7250a71733c8884d41713462c478e691f1bc.tar.gz
hdf5-0a5e7250a71733c8884d41713462c478e691f1bc.tar.bz2
dataset read works for 1D H5T_NATIVE_INT
-rw-r--r--src/H5VLjson.c99
1 files changed, 33 insertions, 66 deletions
diff --git a/src/H5VLjson.c b/src/H5VLjson.c
index a4ab970..775b6b0 100644
--- a/src/H5VLjson.c
+++ b/src/H5VLjson.c
@@ -1447,7 +1447,7 @@ done:
* Return: Non-negative on success/Negative on failure
*
* Programmer: Frank Willmore
- * November, 2017
+ * January, 2018
*
*/
static herr_t
@@ -1456,14 +1456,11 @@ H5VL_json_dataset_read(void *_dataset, hid_t mem_type_id, hid_t mem_space_id,
{
H5VL_json_object_t *dataset = (H5VL_json_object_t *) _dataset;
H5T_class_t dtype_class;
- hssize_t mem_select_npoints, file_select_npoints;
- hbool_t must_close_memspace = FALSE, must_close_filespace = FALSE;
-//FTW hbool_t is_transfer_binary = FALSE;
- hbool_t is_variable_str;
+// hssize_t mem_select_npoints, file_select_npoints;
+ hbool_t must_close_memspace = FALSE;//, must_close_filespace = FALSE;
+// hbool_t is_variable_str;
size_t read_data_size, dtype_size;
-//FTW char host_header[HOST_HEADER_MAX_LENGTH] = "Host: ";
- char *selection_body = NULL;
-//FTW char temp_url[URL_MAX_LENGTH];
+// char *selection_body = NULL;
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT
@@ -1473,20 +1470,45 @@ H5VL_json_dataset_read(void *_dataset, hid_t mem_type_id, hid_t mem_space_id,
#ifdef PLUGIN_DEBUG
printf("Receive Dataset read call with following parameters:\n");
-// printf(" - Dataset URI: %s\n", dataset->URI);
+ printf(" - Dataset UUID: %s\n", dataset->object_uuid);
printf(" - mem_type_id: %ld\n", mem_space_id);
printf(" - is all mem: %s\n", (mem_space_id == H5S_ALL) ? "yes" : "no");
printf(" - file_space_id: %ld\n", file_space_id);
printf(" - is all file: %s\n", (file_space_id == H5S_ALL) ? "yes" : "no");
#endif
+
+ /* check for valid datatype */
+ if (H5T_NO_CLASS == (dtype_class = H5Tget_class(mem_type_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid datatype")
- if (H5S_ALL == mem_space_id) {
+ if (0 == (dtype_size = H5Tget_size(mem_type_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid datatype")
+
+ /* for now, the mem_space selection is always H5S_ALL */
+// hid_t space_id = H5Scopy(attribute->u.attribute.space_id);
+// HDassert(space_id);
+// H5Sselect_all(space_id);
+
+if (H5S_ALL == mem_space_id) {
/* Set up a valid memory dataspace to use for the dataset read */
mem_space_id = H5Scopy(dataset->u.dataset.space_id);
H5Sselect_all(mem_space_id);
must_close_memspace = true;
} /* end if */
+ else {
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "only H5S_ALL supported.")
+ }
+
+ /*** reading the value ***/
+ json_t* value = json_object_get(dataset->object_json, "value");
+ // This function will fill the given buffer with data from the value array.
+ printf("FTW dataset json value = %s\n", json_dumps(value, JSON_INDENT(4)));
+ H5VL_json_read_value(value, mem_type_id, mem_space_id, buf);
+ printf("FTW after H5VL_json_read_value\n");
+
+//FTW ignore file_space for now
+#if 0
if (H5S_ALL == file_space_id) {
/* Set up a valid file dataspace to use for the dataset read */
file_space_id = H5Scopy(dataset->u.dataset.space_id);
@@ -1512,73 +1534,18 @@ H5VL_json_dataset_read(void *_dataset, hid_t mem_type_id, hid_t mem_space_id,
if (0 == (dtype_size = H5Tget_size(mem_type_id)))
HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid datatype")
- /* Determine whether it's possible to send the data as a binary blob instead of a JSON array */
- if (H5T_NO_CLASS == (dtype_class = H5Tget_class(mem_type_id)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid datatype")
-
if ((is_variable_str = H5Tis_variable_str(mem_type_id)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid datatype")
-
-#if 0
- is_transfer_binary = !(H5T_VLEN == dtype_class) && !is_variable_str;
-
- /* Setup the "Host: " headers */
- curl_headers = curl_slist_append(curl_headers, strncat(host_header, dataset->domain->u.file.filepath_name, HOST_HEADER_MAX_LENGTH));
-
- /* Disable use of Expect: 100 Continue HTTP response */
- curl_headers = curl_slist_append(curl_headers, "Expect:");
-
- /* If the datatype of the dataset is fixed-length, request that the server
- * send the data as binary */
- curl_headers = curl_slist_append(curl_headers, is_transfer_binary ? "Accept: application/octet-stream" : "Accept: application/json");
-
- /* Redirect from base URL to "/datasets/<id>/value" to get the dataset data values */
- snprintf(temp_url, URL_MAX_LENGTH,
- "%s/datasets/%s/value%s%s",
- base_URL,
- dataset->URI,
- selection_body ? "?select=" : "",
- selection_body ? selection_body : "");
-
-#ifdef PLUGIN_DEBUG
- printf("Accessing link: %s\n\n", temp_url);
-#endif
-
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers);
- curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
- curl_easy_setopt(curl, CURLOPT_URL, temp_url);
-
- CURL_PERFORM(curl, H5E_DATASET, H5E_READERROR, FAIL);
-
- read_data_size = (size_t) mem_select_npoints * dtype_size;
- if (H5Dscatter(dataset_read_scatter_op, &read_data_size, mem_type_id, mem_space_id, buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't scatter data to read buffer")
#endif
done:
-#if 0
-#ifdef PLUGIN_DEBUG
- printf("Dataset read URL: %s\n\n", temp_url);
- printf("Dataset read response buffer: %s\n\n", response_buffer.buffer);
-#endif
-
if (must_close_memspace)
if (H5Sclose(mem_space_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close memspace")
+#if 0
if (must_close_filespace)
if (H5Sclose(file_space_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close filespace")
-
- if (selection_body)
- H5MM_free(selection_body);
-
- /* Restore cURL URL to the base URL */
- curl_easy_setopt(curl, CURLOPT_URL, base_URL);
-
- if (curl_headers) {
- curl_slist_free_all(curl_headers);
- curl_headers = NULL;
- } /* end if */
#endif
FUNC_LEAVE_NOAPI(ret_value)