diff options
-rw-r--r-- | src/H5D.c | 2 | ||||
-rw-r--r-- | src/H5R.c | 39 | ||||
-rw-r--r-- | src/H5Rpublic.h | 8 | ||||
-rw-r--r-- | src/H5Sall.c | 40 | ||||
-rw-r--r-- | src/H5Shyper.c | 166 | ||||
-rw-r--r-- | src/H5Snone.c | 60 | ||||
-rw-r--r-- | src/H5Spoint.c | 114 | ||||
-rw-r--r-- | src/H5Sprivate.h | 10 | ||||
-rw-r--r-- | src/H5Sselect.c | 113 | ||||
-rw-r--r-- | src/H5T.c | 20 | ||||
-rw-r--r-- | src/H5Tpublic.h | 2 | ||||
-rw-r--r-- | src/Makefile.in | 4 |
12 files changed, 568 insertions, 10 deletions
@@ -880,7 +880,7 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, H5D_t *new_dset = NULL; H5D_t *ret_value = NULL; intn i, ndims; - hsize_t max_dim[H5O_LAYOUT_NDIMS]; + hsize_t max_dim[H5O_LAYOUT_NDIMS]={0}; H5O_efl_t *efl = NULL; H5F_t *f = NULL; @@ -22,6 +22,7 @@ static char RcsId[] = "@(#)$Revision$"; #include <H5Eprivate.h> /* Error handling */ #include <H5Fprivate.h> /* Files */ #include <H5Gprivate.h> /* Groups */ +#include <H5MMprivate.h> /* Memory Management */ #include <H5Rprivate.h> /* References */ #include <H5Sprivate.h> /* Dataspaces */ @@ -120,7 +121,7 @@ H5R_term_interface(void) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t __unused__ *space) +H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space) { H5G_stat_t sb; /* Stat buffer for retrieving OID */ herr_t ret_value = FAIL; @@ -150,6 +151,40 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, } case H5R_DATASET_REGION: + { + haddr_t addr; + hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ + hssize_t buf_size; /* Size of buffer needed to serialize selection */ + uint8 *p; /* Pointer to OID to store */ + uint8 *buf; /* Buffer to store serialized selection in */ + + /* Set information for dataset OID */ + p=(uint8 *)ref->oid; + H5F_addr_pack(loc->file,&addr,&sb.objno[0]); + H5F_addr_encode(loc->file,&p,&addr); + + /* Set up information for dataset region */ + ref->region[0]=ref->region[1]=0; /* Zero the heap ID out, may leak heap space if user is re-using reference */ + + /* Get the amount of space required to serialize the selection */ + if ((buf_size = H5S_select_serial_size(space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, + "Invalid amount of space for serializing selection"); + + /* Allocate the space to store the serialized information */ + if (NULL==(buf = H5MM_malloc(buf_size))) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + + /* Serialize the selection */ + if (H5S_select_serialize(space,buf) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, + "Unable to serialize selection"); +/* Save the serialized buffer for later */ + break; + } + case H5R_INTERNAL: HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "Dataset region and internal references are not supported yet"); @@ -215,7 +250,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given"); if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE) HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type"); - if(ref_type!=H5R_OBJECT) + if(ref_type!=H5R_OBJECT && ref_type!=H5R_DATASET_REGION) HRETURN_ERROR (H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported"); if (space_id!=(-1) && (H5I_DATASPACE!=H5I_get_type (space_id) || NULL==(space=H5I_object (space_id)))) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index 7447694..c92d201 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -45,6 +45,14 @@ typedef struct { unsigned long oid[2]; /* OID of object referenced */ } hobj_ref_t; +/* Dataset Region reference structure for user's code */ +typedef struct { + unsigned long oid[2]; /* OID of object referenced */ + unsigned long region[2]; /* heap ID of region in object */ + unsigned long bsize; /* Memory buffer size */ + unsigned char *buf; /* Serialized selection information */ +} hdset_reg_ref_t; + /* Publicly visible datastructures */ #ifdef __cplusplus diff --git a/src/H5Sall.c b/src/H5Sall.c index 638e5a0..9ac5940 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -563,3 +563,43 @@ H5S_all_npoints (const H5S_t *space) FUNC_LEAVE (ret_value); } /* H5S_all_npoints() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_all_select_serialize + PURPOSE + Serialize the current selection into a user-provided buffer. + USAGE + herr_t H5S_all_select_serialize(space, buf) + H5S_t *space; IN: Dataspace pointer of selection to serialize + uint8 *buf; OUT: Buffer to put serialized selection into + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Serializes the current element selection into a buffer. (Primarily for + storing on disk). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_all_select_serialize (const H5S_t *space, uint8 *buf) +{ + herr_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_all_select_serialize, FAIL); + + assert(space); + + /* Store the preamble information */ + UINT32ENCODE(buf, (uint32)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32)1); /* Store the version number */ + UINT32ENCODE(buf, (uint32)0); /* Store the un-used padding */ + UINT32ENCODE(buf, (uint32)0); /* Store the additional information length */ + + /* Set success */ + ret_value=SUCCEED; + + FUNC_LEAVE (ret_value); +} /* H5S_all_select_serialize() */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 11f335d..03f364c 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -1814,6 +1814,41 @@ H5S_hyper_node_prepend (H5S_hyper_node_t **head, H5S_hyper_node_t *node) /*-------------------------------------------------------------------------- NAME + H5S_hyper_node_release + PURPOSE + Free the memory for a hyperslab node + USAGE + herr_t H5S_hyper_node_release(node) + H5S_hyper_node_t *node; IN: Pointer to node to free + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Frees a hyperslab node. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5S_hyper_node_release (H5S_hyper_node_t *node) +{ + herr_t ret_value=SUCCEED; + + FUNC_ENTER (H5S_hyper_node_release, FAIL); + + /* Check args */ + assert (node); + + /* Free the hyperslab node */ + node->start = H5MM_xfree(node->start); + node->end = H5MM_xfree(node->end); + H5MM_xfree(node); + + FUNC_LEAVE (ret_value); +} /* H5S_hyper_node_release() */ + +/*-------------------------------------------------------------------------- + NAME H5S_hyper_add PURPOSE Add a block to hyperslab selection @@ -2027,7 +2062,7 @@ done: PURPOSE Clip a list of nodes against the current selection USAGE - herr_t H5S_hyper_add(space, nodes, uniq, overlap) + herr_t H5S_hyper_clip(space, nodes, uniq, overlap) H5S_t *space; IN: Pointer to dataspace H5S_hyper_node_t *nodes; IN: Pointer to list of nodes H5S_hyper_node_t **uniq; IN: Handle to list of non-overlapping nodes @@ -2120,6 +2155,7 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, /* Check args */ assert (space); assert (nodes); + assert (uniq || overlap); /* Allocate space for the temporary starts & sizes */ if((start = H5MM_malloc(sizeof(hssize_t)*space->extent.u.simple.rank))==NULL) @@ -2233,6 +2269,9 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, if(H5S_hyper_node_prepend(overlap,node)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab"); } + else { /* Free the node if we aren't going to keep it */ + H5S_hyper_node_release(node); + } /* end else */ overlapped=1; /* stop the algorithm for this block */ } /* end if */ } /* end for */ @@ -2248,6 +2287,9 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, if(H5S_hyper_node_prepend(uniq,node)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab"); } + else { /* Free the node if we aren't going to keep it */ + H5S_hyper_node_release(node); + } /* end else */ } /* end if */ /* Advance to next hyperslab node */ @@ -2327,9 +2369,7 @@ H5S_hyper_release (H5S_t *space) curr=space->select.sel_info.hslab.hyper_lst->head; while(curr!=NULL) { next=curr->next; - curr->start = H5MM_xfree(curr->start); - curr->end = H5MM_xfree(curr->end); - H5MM_xfree(curr); + H5S_hyper_node_release(curr); curr=next; } /* end while */ @@ -2630,4 +2670,122 @@ H5S_hyper_select_valid (const H5S_t *space) FUNC_LEAVE (ret_value); } /* end H5S_hyper_select_valid() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_hyper_select_serial_size + PURPOSE + Determine the number of bytes needed to store the serialized hyperslab + selection information. + USAGE + hssize_t H5S_hyper_select_serial_size(space) + H5S_t *space; IN: Dataspace pointer to query + RETURNS + The number of bytes required on success, negative on an error. + DESCRIPTION + Determines the number of bytes required to serialize the current hyperslab + selection information for storage on disk. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +hssize_t +H5S_hyper_select_serial_size (const H5S_t *space) +{ + H5S_hyper_node_t *curr; /* Hyperslab information nodes */ + hssize_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_hyper_select_serial_size, FAIL); + + assert(space); + /* Basic number of bytes required to serialize point selection: + * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> + + * <length (4 bytes)> + <rank (4 bytes)> + <# of blocks (4 bytes)> = 24 bytes + */ + ret_value=24; + + /* Spin through hyperslabs to total the space needed to store them */ + curr=space->select.sel_info.hslab.hyper_lst->head; + while(curr!=NULL) { + /* Add 8 bytes times the rank for each element selected */ + ret_value+=8*space->extent.u.simple.rank; + curr=curr->next; + } /* end while */ + + FUNC_LEAVE (ret_value); +} /* end H5S_hyper_select_serial_size() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_hyper_select_serialize + PURPOSE + Serialize the current selection into a user-provided buffer. + USAGE + herr_t H5S_hyper_select_serialize(space, buf) + H5S_t *space; IN: Dataspace pointer of selection to serialize + uint8 *buf; OUT: Buffer to put serialized selection into + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Serializes the current element selection into a buffer. (Primarily for + storing on disk). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_hyper_select_serialize (const H5S_t *space, uint8 *buf) +{ + H5S_hyper_node_t *curr; /* Hyperslab information nodes */ + uint8 *lenp; /* pointer to length location for later storage */ + uint32 len=0; /* number of bytes used */ + intn i; /* local counting variable */ + herr_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_point_select_serialize, FAIL); + + assert(space); + + /* Store the preamble information */ + UINT32ENCODE(buf, (uint32)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32)1); /* Store the version number */ + UINT32ENCODE(buf, (uint32)0); /* Store the un-used padding */ + lenp=buf; /* keep the pointer to the length location for later */ + buf+=4; /* skip over space for length */ + + /* Encode number of dimensions */ + UINT32ENCODE(buf, (uint32)space->extent.u.simple.rank); + len+=4; + + /* Encode number of elements */ + UINT32ENCODE(buf, (uint32)space->select.sel_info.hslab.hyper_lst->count); + len+=4; + + /* Encode each point in selection */ + curr=space->select.sel_info.hslab.hyper_lst->head; + while(curr!=NULL) { + /* Add 8 bytes times the rank for each element selected */ + len+=8*space->extent.u.simple.rank; + + /* Encode starting point */ + for(i=0; i<space->extent.u.simple.rank; i++) + UINT32ENCODE(buf, (uint32)curr->start[i]); + + /* Encode starting point */ + for(i=0; i<space->extent.u.simple.rank; i++) + UINT32ENCODE(buf, (uint32)curr->end[i]); + + curr=curr->next; + } /* end while */ + + /* Encode length */ + UINT32ENCODE(lenp, (uint32)len); /* Store the length of the extra information */ + + /* Set success */ + ret_value=SUCCEED; + + FUNC_LEAVE (ret_value); +} /* H5S_hyper_select_serialize() */ diff --git a/src/H5Snone.c b/src/H5Snone.c new file mode 100644 index 0000000..cbb3d1e --- /dev/null +++ b/src/H5Snone.c @@ -0,0 +1,60 @@ +/* + * Copyright (C) 1998 NCSA + * All rights reserved. + * + * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Tuesday, November 10, 1998 + * + * Purpose: "None" selection data space I/O functions. + */ +#include <H5private.h> +#include <H5Eprivate.h> +#include <H5Sprivate.h> +#include <H5Vprivate.h> +#include <H5Dprivate.h> + +/* Interface initialization */ +#define PABLO_MASK H5S_none_mask +#define INTERFACE_INIT NULL +static intn interface_initialize_g = FALSE; + + +/*-------------------------------------------------------------------------- + NAME + H5S_none_select_serialize + PURPOSE + Serialize the current selection into a user-provided buffer. + USAGE + herr_t H5S_none_select_serialize(space, buf) + H5S_t *space; IN: Dataspace pointer of selection to serialize + uint8 *buf; OUT: Buffer to put serialized selection into + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Serializes the current element selection into a buffer. (Primarily for + storing on disk). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_none_select_serialize (const H5S_t *space, uint8 *buf) +{ + herr_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_none_select_serialize, FAIL); + + assert(space); + + /* Store the preamble information */ + UINT32ENCODE(buf, (uint32)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32)1); /* Store the version number */ + UINT32ENCODE(buf, (uint32)0); /* Store the un-used padding */ + UINT32ENCODE(buf, (uint32)0); /* Store the additional information length */ + + /* Set success */ + ret_value=SUCCEED; + + FUNC_LEAVE (ret_value); +} /* H5S_none_select_serialize() */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index d0c966a..66f6b8b 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -831,4 +831,118 @@ H5S_point_select_valid (const H5S_t *space) FUNC_LEAVE (ret_value); } /* end H5S_point_select_valid() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_point_select_serial_size + PURPOSE + Determine the number of bytes needed to store the serialized point selection + information. + USAGE + hssize_t H5S_point_select_serial_size(space) + H5S_t *space; IN: Dataspace pointer to query + RETURNS + The number of bytes required on success, negative on an error. + DESCRIPTION + Determines the number of bytes required to serialize the current point + selection information for storage on disk. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +hssize_t +H5S_point_select_serial_size (const H5S_t *space) +{ + H5S_pnt_node_t *curr; /* Point information nodes */ + hssize_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_point_select_serial_size, FAIL); + assert(space); + + /* Basic number of bytes required to serialize point selection: + * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> + + * <length (4 bytes)> + <rank (4 bytes)> + <# of points (4 bytes)> = 24 bytes + */ + ret_value=24; + + /* Count points in selection */ + curr=space->select.sel_info.pnt_lst->head; + while(curr!=NULL) { + /* Add 4 bytes times the rank for each element selected */ + ret_value+=4*space->extent.u.simple.rank; + curr=curr->next; + } /* end while */ + + FUNC_LEAVE (ret_value); +} /* end H5S_point_select_serial_size() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_point_select_serialize + PURPOSE + Serialize the current selection into a user-provided buffer. + USAGE + herr_t H5S_point_select_serialize(space, buf) + H5S_t *space; IN: Dataspace pointer of selection to serialize + uint8 *buf; OUT: Buffer to put serialized selection into + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Serializes the current element selection into a buffer. (Primarily for + storing on disk). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_point_select_serialize (const H5S_t *space, uint8 *buf) +{ + H5S_pnt_node_t *curr; /* Point information nodes */ + uint8 *lenp; /* pointer to length location for later storage */ + uint32 len=0; /* number of bytes used */ + intn i; /* local counting variable */ + herr_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_point_select_serialize, FAIL); + + assert(space); + + /* Store the preamble information */ + UINT32ENCODE(buf, (uint32)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32)1); /* Store the version number */ + UINT32ENCODE(buf, (uint32)0); /* Store the un-used padding */ + lenp=buf; /* keep the pointer to the length location for later */ + buf+=4; /* skip over space for length */ + + /* Encode number of dimensions */ + UINT32ENCODE(buf, (uint32)space->extent.u.simple.rank); + len+=4; + + /* Encode number of elements */ + UINT32ENCODE(buf, (uint32)space->select.num_elem); + len+=4; + + /* Encode each point in selection */ + curr=space->select.sel_info.pnt_lst->head; + while(curr!=NULL) { + /* Add 4 bytes times the rank for each element selected */ + len+=4*space->extent.u.simple.rank; + + /* Encode each point */ + for(i=0; i<space->extent.u.simple.rank; i++) + UINT32ENCODE(buf, (uint32)curr->pnt[i]); + + curr=curr->next; + } /* end while */ + + /* Encode length */ + UINT32ENCODE(lenp, (uint32)len); /* Store the length of the extra information */ + + /* Set success */ + ret_value=SUCCEED; + + FUNC_LEAVE (ret_value); +} /* H5S_point_select_serialize() */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index f7d0270..817d654 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -325,6 +325,8 @@ herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth); herr_t H5S_register(H5S_sel_type cls, const H5S_fconv_t *fconv, const H5S_mconv_t *mconv); +hssize_t H5S_select_serial_size(const H5S_t *space); +herr_t H5S_select_serialize(const H5S_t *space, uint8 *buf); /* Point select functions */ herr_t H5S_point_add (H5S_t *space, size_t num_elemn, const hssize_t **coord); @@ -332,10 +334,13 @@ herr_t H5S_point_release (H5S_t *space); hsize_t H5S_point_npoints (const H5S_t *space); herr_t H5S_point_copy (H5S_t *dst, const H5S_t *src); htri_t H5S_point_select_valid (const H5S_t *space); +hssize_t H5S_point_select_serial_size(const H5S_t *space); +herr_t H5S_point_select_serialize(const H5S_t *space, uint8 *buf); /* "All" select functions */ herr_t H5S_all_release (H5S_t *space); hsize_t H5S_all_npoints (const H5S_t *space); +herr_t H5S_all_select_serialize(const H5S_t *space, uint8 *buf); /* Hyperslab selection functions */ herr_t H5S_hyper_add (H5S_t *space, const hssize_t *start, const hsize_t *end); @@ -348,6 +353,11 @@ herr_t H5S_hyper_copy (H5S_t *dst, const H5S_t *src); htri_t H5S_hyper_select_valid (const H5S_t *space); herr_t H5S_hyper_node_add (H5S_hyper_node_t **head, intn endflag, intn rank, const hssize_t *start, const hsize_t *size); herr_t H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, H5S_hyper_node_t **overlap); +hssize_t H5S_hyper_select_serial_size(const H5S_t *space); +herr_t H5S_hyper_select_serialize(const H5S_t *space, uint8 *buf); + +/* "None" selection functions */ +herr_t H5S_none_select_serialize(const H5S_t *space, uint8 *buf); #ifdef HAVE_PARALLEL /* MPI-IO function to read directly from app buffer to file rky980813 */ diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 526b295..7564680 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -421,7 +421,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab"); } /* end if */ } /* end for */ - } /* end if */ + } /* end else */ /* Clip list of new blocks to add against current selection */ if(op==H5S_SELECT_OR) { @@ -928,3 +928,114 @@ H5S_select_valid (const H5S_t *space) FUNC_LEAVE (ret_value); } /* H5S_select_valid() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_select_serial_size + PURPOSE + Determine the number of bytes needed to serialize the current selection + offset defined. + USAGE + hssize_t H5S_select_serial_size(space) + H5S_t *space; IN: Dataspace pointer to query + RETURNS + The number of bytes required on success, negative on an error. + DESCRIPTION + Determines the number of bytes required to serialize the current selection + information for storage on disk. This routine just hands off to the + appropriate routine for each type of selection. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +hssize_t +H5S_select_serial_size (const H5S_t *space) +{ + hssize_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_select_serial_size, FAIL); + + assert(space); + + switch(space->select.type) { + case H5S_SEL_POINTS: /* Sequence of points selected */ + ret_value=H5S_point_select_serial_size(space); + break; + + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + ret_value=H5S_hyper_select_serial_size(space); + break; + + case H5S_SEL_ALL: /* Entire extent selected */ + case H5S_SEL_NONE: /* Nothing selected */ + ret_value=16; /* replace with real function call at some point */ + break; + + case H5S_SEL_ERROR: + case H5S_SEL_N: + break; + } + + FUNC_LEAVE (ret_value); +} /* H5S_select_serial_size() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_select_serialize + PURPOSE + Serialize the current selection into a user-provided buffer. + USAGE + herr_t H5S_select_serialize(space, buf) + H5S_t *space; IN: Dataspace pointer of selection to serialize + uint8 *buf; OUT: Buffer to put serialized selection into + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Serializes the current selection into a buffer. (Primarily for storing + on disk). This routine just hands off to the appropriate routine for each + type of selection. + The serialized information for all types of selections follows this format: + <type of selection> = uint32 + <version #> = uint32 + <padding, not-used> = 4 bytes + <length of selection specific information> = uint32 + <selection specific information> = ? bytes (depends on selection type) + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_select_serialize (const H5S_t *space, uint8 *buf) +{ + herr_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_select_serialize, FAIL); + + assert(space); + + switch(space->select.type) { + case H5S_SEL_POINTS: /* Sequence of points selected */ + ret_value=H5S_point_select_serialize(space,buf); + break; + + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + ret_value=H5S_hyper_select_serialize(space,buf); + break; + + case H5S_SEL_ALL: /* Entire extent selected */ + ret_value=H5S_all_select_serialize(space,buf); + break; + + case H5S_SEL_NONE: /* Nothing selected */ + ret_value=H5S_none_select_serialize(space,buf); + break; + + case H5S_SEL_ERROR: + case H5S_SEL_N: + break; + } + + FUNC_LEAVE (ret_value); +} /* H5S_select_serialize() */ @@ -60,6 +60,7 @@ hid_t H5T_STD_B32LE_g = FAIL; hid_t H5T_STD_B64BE_g = FAIL; hid_t H5T_STD_B64LE_g = FAIL; hid_t H5T_STD_REF_OBJ_g = FAIL; +hid_t H5T_STD_REF_DSETREG_g = FAIL; hid_t H5T_UNIX_D32BE_g = FAIL; hid_t H5T_UNIX_D32LE_g = FAIL; @@ -621,6 +622,25 @@ H5T_init_interface(void) HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize H5T layer"); } + /* Dataset Region pointer (i.e. selection inside a dataset) */ + if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + } + dt->state = H5T_STATE_IMMUTABLE; + H5F_addr_undef (&(dt->ent.header)); + dt->type = H5T_REFERENCE; + dt->size = sizeof(haddr_t); + dt->u.atomic.order = H5T_ORDER_NONE; + dt->u.atomic.offset = 0; + dt->u.atomic.prec = 8 * dt->size; + dt->u.atomic.lsb_pad = H5T_PAD_ZERO; + dt->u.atomic.msb_pad = H5T_PAD_ZERO; + dt->u.atomic.u.r.rtype = H5R_DATASET_REGION; + if ((H5T_STD_REF_DSETREG_g = H5I_register(H5I_DATATYPE, dt)) < 0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to initialize H5T layer"); + } + /* * Register conversion functions beginning with the most general and diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 8c7792e..188d3d6 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -210,6 +210,7 @@ extern hid_t H5T_IEEE_F64LE_g; #define H5T_STD_B64BE (H5open(), H5T_STD_B64BE_g) #define H5T_STD_B64LE (H5open(), H5T_STD_B64LE_g) #define H5T_STD_REF_OBJ (H5open(), H5T_STD_REF_OBJ_g) +#define H5T_STD_REF_DSETREG (H5open(), H5T_STD_REF_DSETREG_g) extern hid_t H5T_STD_I8BE_g; extern hid_t H5T_STD_I8LE_g; extern hid_t H5T_STD_I16BE_g; @@ -235,6 +236,7 @@ extern hid_t H5T_STD_B32LE_g; extern hid_t H5T_STD_B64BE_g; extern hid_t H5T_STD_B64LE_g; extern hid_t H5T_STD_REF_OBJ_g; +extern hid_t H5T_STD_REF_DSETREG_g; /* * Types which are particular to Unix. diff --git a/src/Makefile.in b/src/Makefile.in index 338241b..b59f610 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -19,8 +19,8 @@ LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5D.c H5E.c H5F.c H5Farray.c H5Fcore.c \ H5Fstdio.c H5G.c H5Gent.c H5Gnode.c H5Gstab.c H5HG.c H5HL.c H5I.c H5MF.c \ H5MM.c H5O.c H5Oattr.c H5Ocomp.c H5Ocont.c H5Odtype.c H5Oefl.c H5Ofill.c \ H5Olayout.c H5Omtime.c H5Oname.c H5Onull.c H5Osdspace.c H5Oshared.c \ - H5Ostab.c H5P.c H5R.c H5RA.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Spoint.c \ - H5Sselect.c H5T.c H5Tbit.c H5Tconv.c H5Tinit.c H5TB.c H5V.c H5Z.c + H5Ostab.c H5P.c H5R.c H5RA.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Snone.c \ + H5Spoint.c H5Sselect.c H5T.c H5Tbit.c H5Tconv.c H5Tinit.c H5TB.c H5V.c H5Z.c LIB_OBJ=$(LIB_SRC:.c=.o) |