summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c8
-rw-r--r--src/H5P.c33
-rw-r--r--src/H5Ppublic.h8
-rw-r--r--src/H5T.c4
-rw-r--r--src/H5Z.c2
5 files changed, 48 insertions, 7 deletions
diff --git a/src/H5D.c b/src/H5D.c
index a49727a..45ed334 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -969,6 +969,14 @@ H5D_open(H5G_t *loc, const char *name)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"unable to load type or space info from dataset header");
}
+
+ /* Get the optional compression message */
+ if (NULL==H5O_read (&(dataset->ent), H5O_COMPRESS, 0,
+ &(dataset->create_parms->compress))) {
+ H5E_clear ();
+ HDmemset (&(dataset->create_parms->compress), 0,
+ sizeof(dataset->create_parms->compress));
+ }
/*
* Get the raw data layout info. It's actually stored in two locations:
diff --git a/src/H5P.c b/src/H5P.c
index b141853..3c802e4 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -1859,6 +1859,10 @@ H5Pget_preserve (hid_t plist_id)
* specific compression initialization functions like
* H5Pset_deflate().
*
+ * The FLAGS, CD_SIZE, and CLIENT_DATA are copied to the
+ * property list and eventually to the file and passed to the
+ * compression functions.
+ *
* Return: Success: SUCCEED
*
* Failure: FAIL
@@ -1871,7 +1875,8 @@ H5Pget_preserve (hid_t plist_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Pset_compression (hid_t plist_id, H5Z_method_t method)
+H5Pset_compression (hid_t plist_id, H5Z_method_t method, unsigned int flags,
+ size_t cd_size, const void *client_data)
{
H5D_create_t *plist = NULL;
@@ -1891,7 +1896,12 @@ H5Pset_compression (hid_t plist_id, H5Z_method_t method)
/* Clear any previous compression method info, then set new value */
H5O_reset (H5O_COMPRESS, &(plist->compress));
plist->compress.method = method;
-
+ plist->compress.flags = flags;
+ plist->compress.cd_size = cd_size;
+ if (cd_size) {
+ plist->compress.client_data = H5MM_xmalloc (cd_size);
+ HDmemcpy (plist->compress.client_data, client_data, cd_size);
+ }
FUNC_LEAVE (SUCCEED);
}
@@ -1900,7 +1910,11 @@ H5Pset_compression (hid_t plist_id, H5Z_method_t method)
* Function: H5Pget_compression
*
* Purpose: Gets the compression method information from a dataset
- * creation property list.
+ * creation property list. The CLIENT_DATA buffer is initially
+ * CD_SIZE bytes. On return, CLIENT_DATA will be initialized
+ * with at most that many bytes, and CD_SIZE will contain the
+ * actual size of the client data, which might be larger than
+ * its original value.
*
* Return: Success: Compression method.
*
@@ -1914,7 +1928,8 @@ H5Pset_compression (hid_t plist_id, H5Z_method_t method)
*-------------------------------------------------------------------------
*/
H5Z_method_t
-H5Pget_compression (hid_t plist_id)
+H5Pget_compression (hid_t plist_id, unsigned int *flags/*out*/,
+ size_t *cd_size/*in,out*/, void *client_data/*out*/)
{
H5D_create_t *plist = NULL;
@@ -1927,6 +1942,16 @@ H5Pget_compression (hid_t plist_id)
"not a dataset creation property list");
}
+ /* Output values */
+ if (flags) *flags = plist->compress.flags;
+ if (cd_size) {
+ if (*cd_size>0 && client_data) {
+ HDmemcpy (client_data, plist->compress.client_data,
+ MIN(plist->compress.cd_size, *cd_size));
+ }
+ *cd_size = plist->compress.cd_size;
+ }
+
FUNC_LEAVE (plist->compress.method);
}
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index bd87342..503f8c5 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -88,8 +88,12 @@ herr_t H5Pset_buffer (hid_t plist_id, size_t size, void *tconv, void *bkg);
size_t H5Pget_buffer (hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/);
herr_t H5Pset_preserve (hid_t plist_id, hbool_t status);
int H5Pget_preserve (hid_t plist_id);
-herr_t H5Pset_compression (hid_t plist_id, H5Z_method_t method);
-H5Z_method_t H5Pget_compression (hid_t plist_id);
+herr_t H5Pset_compression (hid_t plist_id, H5Z_method_t method,
+ unsigned int flags, size_t cd_size,
+ const void *client_data);
+H5Z_method_t H5Pget_compression (hid_t plist_id, unsigned int *flags/*out*/,
+ size_t *cd_size/*in,out*/,
+ void *client_data/*out*/);
herr_t H5Pset_deflate (hid_t plist_id, int level);
int H5Pget_deflate (hid_t plist_id);
diff --git a/src/H5T.c b/src/H5T.c
index 488e30d..0ca0377 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3424,6 +3424,10 @@ H5T_find(const H5T_t *src, const H5T_t *dst, H5T_bkg_t need_bkg,
FUNC_ENTER(H5T_find, NULL);
+ if (!noop_cdata.stats) {
+ noop_cdata.stats = H5MM_xcalloc (1, sizeof(H5T_stats_t));
+ }
+
/* No-op case */
if (need_bkg<H5T_BKG_YES && 0==H5T_cmp(src, dst)) {
*pcdata = &noop_cdata;
diff --git a/src/H5Z.c b/src/H5Z.c
index 993cc5e..5c7f0fa 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -268,7 +268,7 @@ H5Z_compress (const H5O_compress_t *comp, size_t nbytes, const void *src,
} else if (ret_value>=nbytes) {
/* Output is not smaller than input */
#ifdef H5Z_DEBUG
- H5Z_g[method].comp.over += 1;
+ H5Z_g[method].comp.over += nbytes;
over = 1;
#endif
HGOTO_DONE (0);