summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-06-25 19:36:54 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-06-25 19:36:54 (GMT)
commit21403c5ec467bea879c1887ec5c9429a26458942 (patch)
tree4ca90b8969b8de21213f4ce3b83b629538c6c1c0
parent78f622071f1199581775479811b5d730d14f0779 (diff)
downloadhdf5-21403c5ec467bea879c1887ec5c9429a26458942.zip
hdf5-21403c5ec467bea879c1887ec5c9429a26458942.tar.gz
hdf5-21403c5ec467bea879c1887ec5c9429a26458942.tar.bz2
[svn-r1385] Updated H5Rdereference, H5Rget_object_type and H5Rget_region to accept a
location ID (i.e. a file or group ID) as well as the dataset ID. This should allow Dave to get the palettes stored in the file correctly and also enable Bob and/or Bruce's indexing stuff. This change should be folded into the documentation for these three functions for the release. Also, I fixed a number of bugs in the hyperslab and point selection iterators for H5Diterate and they are working correctly now.
-rw-r--r--src/H5D.c10
-rw-r--r--src/H5R.c111
-rw-r--r--src/H5Sall.c3
-rw-r--r--src/H5Shyper.c11
-rw-r--r--src/H5Snone.c2
-rw-r--r--src/H5Spoint.c9
-rw-r--r--src/H5Sselect.c4
7 files changed, 96 insertions, 54 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 4a55b64..fb927a3 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -2350,15 +2350,15 @@ H5D_typeof (H5D_t *dset)
/*-------------------------------------------------------------------------
- * Function: H5D_get_file
+ * Function: H5D_get_file
*
- * Purpose: Returns the dataset's file pointer.
+ * Purpose: Returns the dataset's file pointer.
*
- * Return: Success: Ptr to the dataset's file pointer.
+ * Return: Success: Ptr to the dataset's file pointer.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Thursday, October 22, 1998
*
* Modifications:
diff --git a/src/H5R.c b/src/H5R.c
index bb4b869..924cef3 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -37,9 +37,9 @@ static herr_t H5R_init_interface(void);
/* Static functions */
static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name,
H5R_type_t ref_type, H5S_t *space);
-static hid_t H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref);
-static H5S_t * H5R_get_region(H5D_t *dset, H5R_type_t ref_type, void *_ref);
-static intn H5R_get_object_type(H5D_t *dset, void *_ref);
+static hid_t H5R_dereference(H5F_t *file, H5R_type_t ref_type, void *_ref);
+static H5S_t * H5R_get_region(H5F_t *file, H5R_type_t ref_type, void *_ref);
+static intn H5R_get_object_type(H5F_t *file, void *_ref);
/*--------------------------------------------------------------------------
@@ -319,7 +319,7 @@ done:
Opens the HDF5 object referenced.
USAGE
hid_t H5R_dereference(ref)
- H5D_t *dset; IN: Dataset reference object is in.
+ H5F_t *file; IN: File the object being dereferenced is within
H5R_type_t ref_type; IN: Type of reference
void *ref; IN: Reference to open.
@@ -335,7 +335,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static hid_t
-H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref)
+H5R_dereference(H5F_t *file, H5R_type_t ref_type, void *_ref)
{
H5D_t *dataset; /* Pointer to dataset to open */
H5G_t *group; /* Pointer to group to open */
@@ -349,12 +349,12 @@ H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref)
assert(_ref);
assert(ref_type>H5R_BADTYPE || ref_type<H5R_MAXTYPE);
- assert(dset);
+ assert(file);
/* Initialize the symbol table entry */
HDmemset(&ent,0,sizeof(H5G_entry_t));
ent.type=H5G_NOTHING_CACHED;
- ent.file=H5D_get_file(dset);
+ ent.file=file;
switch(ref_type) {
case H5R_OBJECT:
@@ -467,9 +467,10 @@ done:
Opens the HDF5 object referenced.
USAGE
hid_t H5Rdereference(ref)
- hid_t dataset; IN: Dataset reference object is in.
+ hid_t id; IN: Dataset reference object is in or location ID of
+ object that the dataset is located within.
H5R_type_t ref_type; IN: Type of reference to create
- void *ref; IN: Reference to open.
+ void *ref; IN: Reference to open.
RETURNS
Valid ID on success, Negative on failure
@@ -482,24 +483,33 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5Rdereference(hid_t dataset, H5R_type_t ref_type, void *_ref)
+H5Rdereference(hid_t id, H5R_type_t ref_type, void *_ref)
{
- H5D_t *dset = NULL; /* dataset object */
+ H5G_entry_t *loc = NULL; /* Symbol table entry */
+ H5D_t *dset = NULL; /* dataset object */
+ H5F_t *file=NULL; /* File object */
hid_t ret_value = FAIL;
FUNC_ENTER(H5Rdereference, FAIL);
- H5TRACE3("i","iRtx",dataset,ref_type,_ref);
+ H5TRACE3("i","iRtx",id,ref_type,_ref);
/* Check args */
- if (H5I_DATASET != H5I_get_type(dataset) || NULL == (dset = H5I_object(dataset)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ if (H5I_DATASET == H5I_get_type(id)) {
+ if(NULL == (dset = H5I_object(id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ file=H5D_get_file(dset);
+ } else {
+ if (NULL == (loc = H5G_loc(id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ file=loc->file;
+ }
if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE)
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
if(_ref==NULL)
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
/* Create reference */
- if ((ret_value=H5R_dereference(dset, ref_type, _ref))<0)
+ if ((ret_value=H5R_dereference(file, ref_type, _ref))<0)
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object");
done:
@@ -513,8 +523,10 @@ done:
PURPOSE
Retrieves a dataspace with the region pointed to selected.
USAGE
- H5S_t *H5R_get_region(ref)
- void *ref; IN: Reference to open.
+ H5S_t *H5R_get_region(file, ref_type, ref)
+ H5F_t *file; IN: File the object being dereferenced is within
+ H5R_type_t ref_type; UNUSED
+ void *ref; IN: Reference to open.
RETURNS
Pointer to the dataspace on success, NULL on failure
@@ -528,7 +540,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static H5S_t *
-H5R_get_region(H5D_t *dset, H5R_type_t UNUSED ref_type, void *_ref)
+H5R_get_region(H5F_t *file, H5R_type_t UNUSED ref_type, void *_ref)
{
H5D_t *dataset; /* Pointer to dataset to open */
H5G_entry_t ent; /* Symbol table entry */
@@ -542,12 +554,12 @@ H5R_get_region(H5D_t *dset, H5R_type_t UNUSED ref_type, void *_ref)
assert(_ref);
assert(ref_type==H5R_DATASET_REGION);
- assert(dset);
+ assert(file);
/* Initialize the symbol table entry */
HDmemset(&ent,0,sizeof(H5G_entry_t));
ent.type=H5G_NOTHING_CACHED;
- ent.file=H5D_get_file(dset);
+ ent.file=file;
/* Get the heap ID for the dataset region */
p=(uint8_t *)ref->heapid;
@@ -597,7 +609,10 @@ done:
PURPOSE
Retrieves a dataspace with the region pointed to selected.
USAGE
- hid_t H5Rget_region(ref)
+ hid_t H5Rget_region(id, ref_type, ref)
+ hid_t id; IN: Dataset reference object is in or location ID of
+ object that the dataset is located within.
+ H5R_type_t ref_type; IN: Type of reference to get region of
void *ref; IN: Reference to open.
RETURNS
@@ -612,25 +627,34 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5Rget_region(hid_t dataset, H5R_type_t ref_type, void *_ref)
+H5Rget_region(hid_t id, H5R_type_t ref_type, void *_ref)
{
+ H5G_entry_t *loc = NULL; /* Symbol table entry */
H5D_t *dset = NULL; /* dataset object */
H5S_t *space = NULL; /* dataspace object */
+ H5F_t *file=NULL; /* File object */
hid_t ret_value = FAIL;
FUNC_ENTER(H5Rget_region, FAIL);
- H5TRACE3("i","iRtx",dataset,ref_type,_ref);
+ H5TRACE3("i","iRtx",id,ref_type,_ref);
/* Check args */
- if (H5I_DATASET != H5I_get_type(dataset) || NULL == (dset = H5I_object(dataset)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ if (H5I_DATASET == H5I_get_type(id)) {
+ if(NULL == (dset = H5I_object(id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ file=H5D_get_file(dset);
+ } else {
+ if (NULL == (loc = H5G_loc(id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ file=loc->file;
+ }
if(ref_type!=H5R_DATASET_REGION)
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
if(_ref==NULL)
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
/* Get the dataspace with the correct region selected */
- if ((space=H5R_get_region(dset,ref_type,_ref))==NULL)
+ if ((space=H5R_get_region(file,ref_type,_ref))==NULL)
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace");
/* Atomize */
@@ -648,8 +672,8 @@ done:
PURPOSE
Retrieves the type of object that an object reference points to
USAGE
- intn H5Rget_object_type(dset, ref)
- H5D_t *dset; IN: dataset pointer that the reference is located within
+ intn H5R_get_object_type(file, ref)
+ H5F_t *file; IN: File the object being dereferenced is within
void *ref; IN: Reference to query.
RETURNS
@@ -664,7 +688,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static intn
-H5R_get_object_type(H5D_t *dset, void *_ref)
+H5R_get_object_type(H5F_t *file, void *_ref)
{
H5G_entry_t ent; /* Symbol table entry */
hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */
@@ -674,12 +698,12 @@ H5R_get_object_type(H5D_t *dset, void *_ref)
FUNC_ENTER(H5R_get_object_type, H5G_UNKNOWN);
assert(ref);
- assert(dset);
+ assert(file);
/* Initialize the symbol table entry */
HDmemset(&ent,0,sizeof(H5G_entry_t));
ent.type=H5G_NOTHING_CACHED;
- ent.file=H5D_get_file(dset);
+ ent.file=file;
/* Get the object oid */
p=(uint8_t *)ref->oid;
@@ -700,8 +724,9 @@ done:
PURPOSE
Retrieves the type of object that an object reference points to
USAGE
- intn H5Rget_object_type(ref)
- hid_t dataset; IN: dataset the reference is located within
+ intn H5Rget_object_type(id, ref)
+ hid_t id; IN: Dataset reference object is in or location ID of
+ object that the dataset is located within.
void *ref; IN: Reference to query.
RETURNS
@@ -716,24 +741,32 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
int
-H5Rget_object_type(hid_t dataset, void *_ref)
+H5Rget_object_type(hid_t id, void *_ref)
{
+ H5G_entry_t *loc = NULL; /* Symbol table entry */
H5D_t *dset = NULL; /* dataset object */
+ H5F_t *file=NULL; /* File object */
hid_t ret_value = H5G_UNKNOWN;
FUNC_ENTER(H5Rget_object_type, H5G_UNKNOWN);
- H5TRACE2("Is","ix",dataset,_ref);
+ H5TRACE2("Is","ix",id,_ref);
/* Check args */
- if (H5I_DATASET != H5I_get_type(dataset) ||
- NULL == (dset = H5I_object(dataset)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a dataset");
+ if (H5I_DATASET == H5I_get_type(id)) {
+ if(NULL == (dset = H5I_object(id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ file=H5D_get_file(dset);
+ } else {
+ if (NULL == (loc = H5G_loc(id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ file=loc->file;
+ }
if(_ref==NULL)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN,
"invalid reference pointer");
/* Get the object information */
- if ((ret_value=H5R_get_object_type(dset,_ref))<0) {
+ if ((ret_value=H5R_get_object_type(file,_ref))<0) {
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN,
"unable to determine object type");
}
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 18d8f52..9109589 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -9,6 +9,7 @@
*/
#include <H5private.h>
#include <H5Eprivate.h>
+#include <H5Iprivate.h>
#include <H5Sprivate.h>
#include <H5Vprivate.h>
#include <H5Dprivate.h>
@@ -967,7 +968,7 @@ H5S_all_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op
assert(buf);
assert(space);
assert(operator);
- assert(H5I_DATATYPE != H5I_get_type(type_id));
+ assert(H5I_DATATYPE == H5I_get_type(type_id));
/* Get the dataspace extent rank */
rank=space->extent.u.simple.rank;
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index ecef87c..50704bd 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -2992,7 +2992,7 @@ H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info)
size_t i; /* Counters */
intn j;
- FUNC_ENTER (H5S_hyper_mwrite, 0);
+ FUNC_ENTER (H5S_hyper_select_iterate_mem, 0);
assert(iter_info);
@@ -3010,6 +3010,8 @@ H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info)
/* (Which means that we've got a list of the regions in the fastest */
/* changing dimension and should input those regions) */
if((dim+2)==iter_info->space->extent.u.simple.rank) {
+ HDmemcpy(iter_info->mem_offset, iter_info->iter->hyp.pos,(iter_info->space->extent.u.simple.rank*sizeof(hssize_t)));
+ iter_info->mem_offset[iter_info->space->extent.u.simple.rank]=0;
/* Iterate over data from regions */
for(i=0; i<num_regions && user_ret==0; i++) {
@@ -3028,6 +3030,9 @@ H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info)
/* Subtract the element from the selected region (not implemented yet) */
+ /* Increment the coordinate offset */
+ iter_info->mem_offset[iter_info->space->extent.u.simple.rank-1]=j;
+
/* Advance the pointer in the buffer */
tmp_buf=((char *)tmp_buf+iter_info->elem_size);
} /* end for */
@@ -3122,7 +3127,7 @@ H5S_hyper_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
assert(buf);
assert(space);
assert(operator);
- assert(H5I_DATATYPE != H5I_get_type(type_id));
+ assert(H5I_DATATYPE == H5I_get_type(type_id));
/* Initialize these before any errors can occur */
HDmemset(&iter,0,sizeof(H5S_sel_iter_t));
@@ -3159,8 +3164,6 @@ H5S_hyper_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
HDmemcpy(iter_info.mem_size, space->extent.u.simple.size, space->extent.u.simple.rank*sizeof(hsize_t));
iter_info.mem_size[space->extent.u.simple.rank]=iter_info.elem_size;
/* Copy the location of the region in the file */
- HDmemcpy(iter_info.mem_offset, iter.hyp.pos,(space->extent.u.simple.rank*sizeof(hssize_t)));
- iter_info.mem_offset[space->extent.u.simple.rank]=0;
iter_info.op=operator;
iter_info.op_data=operator_data;
diff --git a/src/H5Snone.c b/src/H5Snone.c
index 508be0e..cb5ede3 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -133,7 +133,7 @@ H5S_none_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t o
assert(buf);
assert(space);
assert(operator);
- assert(H5I_DATATYPE != H5I_get_type(type_id));
+ assert(H5I_DATATYPE == H5I_get_type(type_id));
FUNC_LEAVE (ret_value);
} /* H5S_hyper_select_iterate() */
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 583aab7..4d248b8 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -1149,6 +1149,7 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
void *operator_data)
{
hsize_t mem_size[H5O_LAYOUT_NDIMS]; /* Dataspace size */
+ hsize_t mem_offset[H5O_LAYOUT_NDIMS]; /* Point offset */
hsize_t offset; /* offset of region in buffer */
void *tmp_buf; /* temporary location of the element in the buffer */
H5S_pnt_node_t *node; /* Point node */
@@ -1160,7 +1161,7 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
assert(buf);
assert(space);
assert(operator);
- assert(H5I_DATATYPE != H5I_get_type(type_id));
+ assert(H5I_DATATYPE == H5I_get_type(type_id));
/* Get the dataspace extent rank */
rank=space->extent.u.simple.rank;
@@ -1172,8 +1173,12 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
/* Iterate through the node, checking the bounds on each element */
node=space->select.sel_info.pnt_lst->head;
while(node!=NULL && ret_value==0) {
+ /* Set up the location of the point */
+ HDmemcpy(mem_offset, node->pnt, rank*sizeof(hssize_t));
+ mem_offset[rank]=0;
+
/* Get the offset in the memory buffer */
- offset=H5V_array_offset(rank+1,mem_size,node->pnt);
+ offset=H5V_array_offset(rank+1,mem_size,mem_offset);
tmp_buf=((char *)buf+offset);
ret_value=(*operator)(tmp_buf,type_id,rank,node->pnt,operator_data);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 1379617..c36cc03 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -1725,7 +1725,7 @@ H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t operat
assert(buf);
assert(space);
assert(operator);
- assert(H5I_DATATYPE != H5I_get_type(type_id));
+ assert(H5I_DATATYPE == H5I_get_type(type_id));
switch(space->select.type) {
case H5S_SEL_POINTS: /* Sequence of points selected */
@@ -1749,6 +1749,6 @@ H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t operat
break;
}
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE(ret_value);
} /* end H5S_select_iterate() */