summaryrefslogtreecommitdiffstats
path: root/src/H5Zshuffle.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-04-09 02:34:21 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-04-09 02:34:21 (GMT)
commit92b6e817897817df03ad9f9b171ea4e11b901834 (patch)
tree5dc8befddaa0341a8380f80b55756ba1801ad110 /src/H5Zshuffle.c
parent099a9f4e74078691a79874638b9aeeebb3bc1996 (diff)
downloadhdf5-92b6e817897817df03ad9f9b171ea4e11b901834.zip
hdf5-92b6e817897817df03ad9f9b171ea4e11b901834.tar.gz
hdf5-92b6e817897817df03ad9f9b171ea4e11b901834.tar.bz2
[svn-r6611] Purpose:
Code cleanup/new features Description: Switch over to a new style for registering filters with the library - instead passing in an ID, a string and a callback function to H5Zregister, the client should pass in a single pointer to a H5Z_claass_t struct which contains the ID, the description string and all the function callbacks as fields. Added support for a new "can apply" callback for each filter, which is called when a dataset is created to check whether the parameters for that filter apply correctly to the combination of the datatype and the chunk size (i.e. dataspace) for the dataset. Added support for a new "set local" callback for each filter, which is called when a dataset is created (after the "can apply" filter callback) and sets filter parameters that are specific to that particular dataset. Switched the filters we ship over to use the new H5Z_class_t struct for their internal registrations and also added "set local" callbacks to the szip and shuffle filters and a "can apply" callback to the szip filter. Lots of other code cleanups, etc. also Solution: Platforms tested: FreeBSD 4.8 (sleipnir) w/szip Linux 2.4 (sleipnir) w/szip Solaris 2.7 (arabica) w/FORTRAN IRIX64 6.5 (modi4) w/szip, FORTRAN & parallel Misc. update:
Diffstat (limited to 'src/H5Zshuffle.c')
-rw-r--r--src/H5Zshuffle.c78
1 files changed, 74 insertions, 4 deletions
diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c
index bcadbc4..e82f1dc 100644
--- a/src/H5Zshuffle.c
+++ b/src/H5Zshuffle.c
@@ -12,10 +12,14 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#define H5Z_PACKAGE /*suppress error about including H5Zpkg */
+
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5MMprivate.h" /* Memory management */
-#include "H5Zprivate.h" /* Data filters */
+#include "H5Ppublic.h" /* Property lists */
+#include "H5Tpublic.h" /* Datatype functions */
+#include "H5Zpkg.h" /* Data filters */
#ifdef H5_HAVE_FILTER_SHUFFLE
@@ -24,6 +28,72 @@
#define INTERFACE_INIT NULL
static int interface_initialize_g = 0;
+/* Local function prototypes */
+static herr_t H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t space_id);
+static size_t H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts,
+ const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
+
+/* This message derives from H5Z */
+const H5Z_class_t H5Z_SHUFFLE[1] = {{
+ H5Z_FILTER_SHUFFLE, /* Filter id number */
+ "shuffle", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ H5Z_set_local_shuffle, /* The "set local" callback */
+ H5Z_filter_shuffle, /* The actual filter function */
+}};
+
+/* Local macros */
+#define H5Z_SHUFFLE_USER_NPARMS 0 /* Number of parameters that users can set */
+#define H5Z_SHUFFLE_TOTAL_NPARMS 1 /* Total number of parameters for filter */
+#define H5Z_SHUFFLE_PARM_SIZE 0 /* "Local" parameter for shuffling size */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Z_set_local_shuffle
+ *
+ * Purpose: Set the "local" dataset parameter for data shuffling to be
+ * the size of the datatype.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Monday, April 7, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
+{
+ unsigned flags; /* Filter flags */
+ size_t cd_nelmts=H5Z_SHUFFLE_USER_NPARMS; /* Number of filter parameters */
+ unsigned cd_values[H5Z_SHUFFLE_TOTAL_NPARMS]; /* Filter parameters */
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5Z_set_local_shuffle, FAIL);
+
+ /* Get the filter's current parameters */
+ if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters");
+
+ /* Check that no parameters are currently set */
+ if(cd_nelmts!=H5Z_SHUFFLE_USER_NPARMS)
+ HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "incorrect # of shuffle parameters");
+
+ /* Set "local" parameter for this dataset */
+ if((cd_values[H5Z_SHUFFLE_PARM_SIZE]=H5Tget_size(type_id))==0)
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size");
+
+ /* Modify the filter's parameters for this dataset */
+ if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SHUFFLE, flags, H5Z_SHUFFLE_TOTAL_NPARMS, cd_values)<0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters");
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* end H5Z_set_local_shuffle() */
+
/*-------------------------------------------------------------------------
* Function: H5Z_filter_shuffle
@@ -47,7 +117,7 @@ static int interface_initialize_g = 0;
*
*-------------------------------------------------------------------------
*/
-size_t
+static size_t
H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
size_t nbytes, size_t *buf_size, void **buf)
{
@@ -63,11 +133,11 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
FUNC_ENTER_NOAPI(H5Z_filter_shuffle, 0);
/* Check arguments */
- if (cd_nelmts!=1 || cd_values[0]==0)
+ if (cd_nelmts!=H5Z_SHUFFLE_TOTAL_NPARMS || cd_values[H5Z_SHUFFLE_PARM_SIZE]==0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid shuffle parameters");
/* Get the number of bytes per element from the parameter block */
- bytesoftype=cd_values[0];
+ bytesoftype=cd_values[H5Z_SHUFFLE_PARM_SIZE];
/* Don't do anything for 1-byte elements */
if(bytesoftype>1) {