summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2012-04-11 22:09:30 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2012-04-11 22:09:30 (GMT)
commit1f15e6e9d482396e47df6785b161229e7efa1d80 (patch)
tree7c1cad2c4ca3cd80d0f84cea950e26f2aa3e91eb
parentf70f5b17403c20bef94e4c43bdf86e7fd4b88ec8 (diff)
downloadhdf5-1f15e6e9d482396e47df6785b161229e7efa1d80.zip
hdf5-1f15e6e9d482396e47df6785b161229e7efa1d80.tar.gz
hdf5-1f15e6e9d482396e47df6785b161229e7efa1d80.tar.bz2
[svn-r22279] implement the attribute delete VOL callback
use the VOL get_space instead of the API routine in vlen_get_size
-rw-r--r--src/H5A.c54
-rw-r--r--src/H5D.c3
-rw-r--r--src/H5VL.c35
-rw-r--r--src/H5VLnative.c47
-rw-r--r--src/H5VLprivate.h1
-rw-r--r--src/H5VLpublic.h2
6 files changed, 101 insertions, 41 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 0ba7361..8d22b9c 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -308,12 +308,6 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
if(!attr_name || !*attr_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name")
-
- /* Find the object's location
- if(H5G_loc_find(&loc, obj_name, &obj_loc, lapl_id, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found")
- */
-
/* Get the token for the Object location through the VOL */
if(H5VL_object_lookup(loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, obj_name, lapl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object")
@@ -2054,7 +2048,6 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
hid_t lapl_id)
{
void *location = NULL;
-
hid_t obj_loc_id = (-1); /* ID for object located */
H5A_attr_iter_op_t attr_op; /* Attribute operator */
hsize_t start_idx; /* Index of attribute to start iterating at */
@@ -2129,23 +2122,20 @@ done:
herr_t
H5Adelete(hid_t loc_id, const char *name)
{
- H5G_loc_t loc; /* Object location */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*s", loc_id, name);
/* check arguments */
- if(H5I_ATTR == H5I_get_type(loc_id))
+ if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- /* Delete the attribute from the location */
- if(H5O_attr_remove(loc.oloc, name, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
+ /* Open the attribute through the VOL */
+ if(H5VL_attr_delete(loc_id, NULL, name) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete attribute")
done:
FUNC_LEAVE_API(ret_value)
@@ -2172,21 +2162,15 @@ herr_t
H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
hid_t lapl_id)
{
- H5G_loc_t loc; /* Object location */
- H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
- hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
+ void *location = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*s*si", loc_id, obj_name, attr_name, lapl_id);
/* check arguments */
- if(H5I_ATTR == H5I_get_type(loc_id))
+ if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!obj_name || !*obj_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name")
if(!attr_name || !*attr_name)
@@ -2197,25 +2181,19 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- /* Set up opened group location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
-
- /* Find the object's location */
- if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found")
- loc_found = TRUE;
+ /* Get the token for the Object location through the VOL */
+ if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, obj_name, lapl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object")
- /* Delete the attribute from the location */
- if(H5O_attr_remove(obj_loc.oloc, attr_name, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
+ /* Open the attribute through the VOL */
+ if(H5VL_attr_delete(loc_id, location, attr_name) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete attribute")
done:
- /* Release resources */
- if(loc_found && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location")
-
+ if(NULL != location) {
+ free (location);
+ location = NULL;
+ }
FUNC_LEAVE_API(ret_value)
} /* H5Adelete_by_name() */
diff --git a/src/H5D.c b/src/H5D.c
index 4a9c03f..eae57fb 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -761,7 +761,8 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id,
vlen_bufsize.dataset_id = dataset_id;
/* Get a copy of the dataspace ID */
- if((vlen_bufsize.fspace_id = H5Dget_space(dataset_id)) < 0)
+ if(H5VL_dataset_get(dataset_id, H5VL_DATASET_GET_SPACE, &(vlen_bufsize.fspace_id)) < 0)
+ //if((vlen_bufsize.fspace_id = H5Dget_space(dataset_id)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace")
/* Create a scalar for the memory dataspace */
diff --git a/src/H5VL.c b/src/H5VL.c
index 0de74bd..c99200e 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -874,6 +874,41 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_attr_delete
+ *
+ * Purpose: Deletes an attribute through the VOL
+ *
+ * Return: Success: Non Negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_attr_delete(hid_t loc_id, void *location, const char *attr_name)
+{
+ H5VL_id_wrapper_t *id_wrapper; /* user id structure */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* get the ID struct */
+ if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier")
+
+ if((ret_value = (id_wrapper->vol_plugin->attr_cls.delete)
+ (id_wrapper->obj_id, location, attr_name)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDELETE, FAIL, "delete failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_attr_close() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_attr_close
*
* Purpose: Closes an attribute through the VOL
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 34a35bb..afabef7 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -68,6 +68,7 @@ static herr_t H5VL_native_attr_read(hid_t attr_id, hid_t dtype_id, void *buf);
static herr_t H5VL_native_attr_write(hid_t attr_id, hid_t dtype_id, const void *buf);
static herr_t H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, va_list arguments);
static herr_t H5VL_native_attr_generic(hid_t id, H5VL_attr_generic_t generic_type, va_list arguments);
+static herr_t H5VL_native_attr_delete(hid_t loc_id, void *location, const char *attr_name);
static herr_t H5VL_native_attr_close(hid_t attr_id);
static herr_t H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id,
@@ -117,9 +118,9 @@ H5VL_class_t H5VL_native_g = {
H5VL_native_attr_open, /* open */
H5VL_native_attr_read, /* read */
H5VL_native_attr_write, /* write */
- NULL, /* delete */
H5VL_native_attr_get, /* get */
H5VL_native_attr_generic, /* generic */
+ H5VL_native_attr_delete, /* delete */
H5VL_native_attr_close /* close */
},
{ /* datatype_cls */
@@ -630,6 +631,50 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_native_attr_delete
+ *
+ * Purpose: Deletes an attribute from a location
+ *
+ * Return: Success: 0
+ * Failure: -1, attr not deleted.
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_native_attr_delete(hid_t loc_id, void *location, const char *attr_name)
+{
+ H5G_loc_t loc; /* Object location */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+
+ if(NULL == location) { /* H5Adelete */
+ /* Delete the attribute from the location */
+ if(H5O_attr_remove(loc.oloc, attr_name, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
+ }
+ else { /* H5Adelete_by_name */
+ H5G_loc_t *obj_loc = (H5G_loc_t *)location;
+
+ /* Delete the attribute from the location */
+ if(H5O_attr_remove(obj_loc->oloc, attr_name, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
+
+ if(H5G_loc_free(obj_loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
+ }
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_native_attr_delete() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_close
*
* Purpose: Closes an attribute.
diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h
index f5b7664..e58106a 100644
--- a/src/H5VLprivate.h
+++ b/src/H5VLprivate.h
@@ -61,6 +61,7 @@ H5_DLL herr_t H5VL_attr_read(hid_t attr_id, hid_t dtype_id, void *buf);
H5_DLL herr_t H5VL_attr_write(hid_t attr_id, hid_t dtype_id, const void *buf);
H5_DLL herr_t H5VL_attr_get(hid_t id, H5VL_attr_get_t get_type, ...);
H5_DLL herr_t H5VL_attr_generic(hid_t id, H5VL_attr_generic_t generic_type, ...);
+H5_DLL herr_t H5VL_attr_delete(hid_t loc_id, void *location, const char *attr_name);
H5_DLL herr_t H5VL_attr_close(hid_t attr_id);
H5_DLL hid_t H5VL_dataset_create(hid_t uid, const char *name, hid_t dcpl_id, hid_t dapl_id);
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index 683b7d7..fc57733 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -116,9 +116,9 @@ typedef struct H5VL_attr_class_t {
hid_t (*open) (hid_t loc_id, void *location, const char *attr_name, hid_t aapl_id);
herr_t (*read) (hid_t attr_id, hid_t mem_type_id, void *buf);
herr_t (*write) (hid_t attr_id, hid_t mem_type_id, const void *buf);
- herr_t (*delete)(hid_t loc_id, const char *attr_name);
herr_t (*get) (hid_t file_id, H5VL_attr_get_t get_type, va_list arguments);
herr_t (*generic)(hid_t id, H5VL_attr_generic_t generic_type, va_list arguments);
+ herr_t (*delete)(hid_t loc_id, void *location, const char *attr_name);
herr_t (*close) (hid_t attr_id);
} H5VL_attr_class_t;