mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r73] Lots of added code for dataset I/O. Its now writing out datasets to the disk
correctly, but only in "native" format. I'm adding the data-type conversions and checking the reading later today.
This commit is contained in:
parent
2a7ec85d6b
commit
08b00d7bfe
@ -32,6 +32,7 @@ typedef enum {
|
||||
H5_DATASPACE, /* Group ID for Dataspace objects */
|
||||
H5_DATASET, /* Group ID for Dataset objects */
|
||||
H5_DIRECTORY, /* Group ID for Directory objects */
|
||||
H5_OID, /* Group ID for OID objects */
|
||||
MAXGROUP /* Highest group in group_t (Invalid as true group) */
|
||||
} group_t;
|
||||
|
||||
|
199
src/H5D.c
199
src/H5D.c
@ -34,14 +34,12 @@ static char RcsId[] = "@(#)$Revision$";
|
||||
|
||||
#include <H5private.h> /* Generic Functions */
|
||||
#include <H5Aprivate.h> /* Atoms */
|
||||
#include <H5Gprivate.h> /* Groups */
|
||||
#include <H5Oprivate.h> /* Object Headers */
|
||||
#include <H5Mprivate.h> /* Meta-Object API */
|
||||
#include <H5Dprivate.h> /* Dataset functions */
|
||||
#include <H5Eprivate.h> /* Error handling */
|
||||
#include <H5Gprivate.h> /* Symbol tables */
|
||||
#include <H5Mprivate.h> /* Meta data */
|
||||
#include <H5Oprivate.h> /* Object headers */
|
||||
#include <H5MFprivate.h> /* File space allocation header */
|
||||
|
||||
#define PABLO_MASK H5D_mask
|
||||
|
||||
@ -104,14 +102,15 @@ hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
|
||||
|
||||
/* Initialize the dataset object */
|
||||
if(H5Aatom_group(owner_id)==H5_FILE)
|
||||
new_dset->file=owner_id;
|
||||
else
|
||||
new_dset->file=H5Mget_file(owner_id);
|
||||
new_dset->name=HDstrdup(name); /* make a copy of the dataset name */
|
||||
if(H5Aatom_group(owner_id)!=H5_FILE)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
|
||||
new_dset->file=H5Aatom_object(owner_id);
|
||||
if((new_dset->name=HDmalloc(sizeof(H5O_name_t)))==NULL)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
|
||||
new_dset->name->s=HDstrdup(name); /* make a copy of the dataset name */
|
||||
new_dset->modified=BTRUE; /* Yep, we're new... */
|
||||
new_dset->type=0;
|
||||
new_dset->dim=0;
|
||||
new_dset->type=NULL;
|
||||
new_dset->dim=NULL;
|
||||
new_dset->header=(-1); /* don't know where we are... */
|
||||
new_dset->data=(-1); /* don't know where we should put the data, either... */
|
||||
|
||||
@ -130,6 +129,72 @@ done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5D_create() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5D_access
|
||||
PURPOSE
|
||||
Start access to an existing HDF5 dataset object
|
||||
USAGE
|
||||
hatom_t H5D_access(oid)
|
||||
hatom_t oid; IN: Atom for OID of dataset
|
||||
RETURNS
|
||||
Returns ID (atom) on success, FAIL on failure
|
||||
DESCRIPTION
|
||||
This function initiates access to a dataset object.
|
||||
--------------------------------------------------------------------------*/
|
||||
hatom_t H5D_access(hatom_t oid)
|
||||
{
|
||||
H5D_dataset_t *dset; /* dataset object to access */
|
||||
H5D_oid_t *ohdr; /* OID for reference to dataset */
|
||||
H5O_std_store_t store; /* standard storage info */
|
||||
hatom_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER(H5D_access, H5D_init_interface, FAIL);
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
|
||||
/* Go get the OID for the dataset */
|
||||
if((ohdr=H5Aatom_object(oid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
|
||||
/* Allocate space for the dataset */
|
||||
if((dset=HDmalloc(sizeof(H5D_dataset_t)))==NULL)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
|
||||
|
||||
/* Pull information about the dataset out of the file */
|
||||
dset->file=H5Aatom_object(ohdr->fid); /* Get the pointer to the file for the dataset */
|
||||
/* Get the dataset's name */
|
||||
if((dset->name=H5O_read(dset->file,ohdr->ohdr,ohdr->ent,H5O_NAME,1,NULL))==NULL)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
|
||||
dset->modified=BFALSE; /* nothing changed yet */
|
||||
/* Get the dataset's type (currently only atomic types) */
|
||||
if((dset->type=H5O_read(dset->file,ohdr->ohdr,ohdr->ent,H5O_SIM_DTYPE,1,NULL))==NULL)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
|
||||
/* Get the dataset's dimensionality (currently only simple dataspaces) */
|
||||
if((dset->dim=H5O_read(dset->file,ohdr->ohdr,ohdr->ent,H5O_SIM_DIM,1,NULL))==NULL)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
|
||||
dset->header=ohdr->ohdr; /* keep the object header location for later */
|
||||
/* Get the dataset's data offset (currently only standard storage) */
|
||||
if(NULL==H5O_read(dset->file,ohdr->ohdr,ohdr->ent,H5O_STD_STORE,1,&store))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
|
||||
dset->data=store.off;
|
||||
|
||||
/* Register the new datatype and get an ID for it */
|
||||
if((ret_value=H5Aregister_atom(H5_DATASET, (const VOIDP)dset))==FAIL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
|
||||
|
||||
done:
|
||||
if(ret_value == FAIL)
|
||||
{ /* Error condition cleanup */
|
||||
|
||||
} /* end if */
|
||||
|
||||
/* Normal function cleanup */
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5D_access() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5Dset_info
|
||||
@ -181,6 +246,60 @@ done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5Dset_info() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5Dget_info
|
||||
PURPOSE
|
||||
Get the type and dimensionality of a dataset.
|
||||
USAGE
|
||||
herr_t H5Dget_info(oid, tid, sid)
|
||||
hatom_t oid; IN: Dataset object to query
|
||||
hatom_t *tid; OUT: Datatype object to use as node element
|
||||
hatom_t *sid; OUT: Dimensionality object to use as dataspace
|
||||
RETURNS
|
||||
SUCCEED/FAIL
|
||||
DESCRIPTION
|
||||
This function starts access to the datatype and dataspace of an
|
||||
existing dataset. H5Mendaccess must be called to release the datatype and
|
||||
dataspace returned from this function.
|
||||
--------------------------------------------------------------------------*/
|
||||
herr_t H5Dget_info(hatom_t oid, hatom_t *tid, hatom_t *sid)
|
||||
{
|
||||
H5D_dataset_t *dataset; /* dataset object to query */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER(H5Dget_info, H5D_init_interface, FAIL);
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
|
||||
/* Check that we've received correctly typed parameters */
|
||||
if(H5Aatom_group(oid)!=H5_DATASET)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
|
||||
|
||||
/* Get the object */
|
||||
if((dataset=H5Aatom_object(oid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
/* Check that the datatype & dataspace haven't already been initialized */
|
||||
if(dataset->type==NULL || dataset->dim==NULL)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_UNINITIALIZED, FAIL);
|
||||
|
||||
if((*tid=H5Aregister_atom(H5_DATATYPE, (const VOIDP)dataset->type))==FAIL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
|
||||
if((*sid=H5Aregister_atom(H5_DATASPACE, (const VOIDP)dataset->dim))==FAIL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
|
||||
|
||||
done:
|
||||
if(ret_value == FAIL)
|
||||
{ /* Error condition cleanup */
|
||||
|
||||
} /* end if */
|
||||
|
||||
/* Normal function cleanup */
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5Dset_info() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5Dwrite
|
||||
@ -203,9 +322,7 @@ done:
|
||||
herr_t H5Dwrite(hatom_t oid, hatom_t did, VOIDP buf)
|
||||
{
|
||||
H5D_dataset_t *dataset; /* dataset object to release */
|
||||
#if 0
|
||||
uintn towrite; /* number of bytes to write out */
|
||||
#endif
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER(H5Dwrite, H5D_init_interface, FAIL);
|
||||
@ -214,7 +331,7 @@ herr_t H5Dwrite(hatom_t oid, hatom_t did, VOIDP buf)
|
||||
H5ECLEAR;
|
||||
|
||||
/* Check that we've received correctly typed parameters */
|
||||
if(H5Aatom_group(did)!=H5_DATASPACE)
|
||||
if(did!=0 && H5Aatom_group(did)!=H5_DATASPACE)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
|
||||
if(buf==NULL)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
|
||||
@ -223,14 +340,26 @@ herr_t H5Dwrite(hatom_t oid, hatom_t did, VOIDP buf)
|
||||
if((dataset=H5Aatom_object(oid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
/* Check that the datatype & dataspace haven't already been initialized */
|
||||
if(dataset->type==0 || dataset->dim==0)
|
||||
if(dataset->type==NULL || dataset->dim==NULL)
|
||||
HGOTO_ERROR(H5E_FUNC, H5E_UNINITIALIZED, FAIL);
|
||||
|
||||
#if 0
|
||||
towrite=H5Tsize(dataset->type)*H5Pnelem(did);
|
||||
#endif
|
||||
/* Compute the number of bytes to write out */
|
||||
if(did==0) /* Check if we are writing out the entire dataset */
|
||||
towrite=H5T_size(dataset->type,BTRUE)*H5P_nelem(dataset->dim);
|
||||
else
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
|
||||
|
||||
/* Check if we have space for the dataset yet */
|
||||
if(dataset->data==(-1))
|
||||
if((dataset->data=H5MF_alloc(dataset->file,towrite))==FAIL)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
|
||||
|
||||
/* Check memory to disk datatype conversions, etc. */
|
||||
/* data out */
|
||||
/* DO THIS! -QAK */
|
||||
|
||||
/* Write the data out to disk */
|
||||
if(H5F_block_write(dataset->file,dataset->data,towrite,buf)==FAIL)
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL);
|
||||
|
||||
done:
|
||||
if(ret_value == FAIL)
|
||||
@ -263,7 +392,6 @@ herr_t H5D_flush(hatom_t oid)
|
||||
{
|
||||
H5D_dataset_t *dataset; /* dataset object to release */
|
||||
herr_t ret_value = SUCCEED;
|
||||
hdf5_file_t *file = NULL;
|
||||
H5G_entry_t d_sym;
|
||||
|
||||
FUNC_ENTER(H5D_flush, H5D_init_interface, FAIL);
|
||||
@ -277,16 +405,11 @@ herr_t H5D_flush(hatom_t oid)
|
||||
|
||||
/* Check if we have information to flush to the file... */
|
||||
if (dataset->modified) {
|
||||
/* Get the dataset's file... (I'm not fond of this. -QAK) */
|
||||
if((file=H5Aatom_object(dataset->file))==NULL)
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_BADATOM, FAIL);
|
||||
|
||||
|
||||
if (dataset->header<=0) {
|
||||
/*
|
||||
* Create the object header.
|
||||
*/
|
||||
if ((dataset->header = H5O_new (file, 0, H5D_MINHDR_SIZE))<0) {
|
||||
if ((dataset->header = H5O_new (dataset->file, 0, H5D_MINHDR_SIZE))<0) {
|
||||
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*can't create header*/
|
||||
}
|
||||
|
||||
@ -303,7 +426,7 @@ herr_t H5D_flush(hatom_t oid)
|
||||
/* Check if this dataset has an "atomic" datatype */
|
||||
if(BTRUE==H5T_is_atomic(dataset->type))
|
||||
{
|
||||
if(H5O_modify(file,dataset->header,&d_sym,NULL,H5O_SIM_DTYPE,H5O_NEW_MESG,dataset->type)==FAIL)
|
||||
if(H5O_modify(dataset->file,dataset->header,&d_sym,NULL,H5O_SIM_DTYPE,H5O_NEW_MESG,dataset->type)==FAIL)
|
||||
HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
|
||||
} /* end if */
|
||||
else
|
||||
@ -313,14 +436,22 @@ herr_t H5D_flush(hatom_t oid)
|
||||
/* Check if this dataset has "simple" dimensionality */
|
||||
if(BTRUE==H5P_is_simple(dataset->dim))
|
||||
{
|
||||
if(H5O_modify(file,dataset->header,&d_sym,NULL,H5O_SIM_DIM,H5O_NEW_MESG,dataset->dim)==FAIL)
|
||||
if(H5O_modify(dataset->file,dataset->header,&d_sym,NULL,H5O_SIM_DIM,H5O_NEW_MESG,dataset->dim->s)==FAIL)
|
||||
HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
|
||||
} /* end if */
|
||||
else
|
||||
{ /* if it's not an atomic datatype, fail for right now */
|
||||
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
|
||||
} /* end else */
|
||||
if(dataset->data>0)
|
||||
{
|
||||
H5O_std_store_t store; /* standard storage info */
|
||||
|
||||
store.len=H5T_size(dataset->type,BTRUE)*H5P_nelem(dataset->dim);
|
||||
store.off=dataset->data;
|
||||
if(H5O_modify(dataset->file,dataset->header,&d_sym,NULL,H5O_STD_STORE,H5O_NEW_MESG,&store)==FAIL)
|
||||
HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
|
||||
} /* end if */
|
||||
|
||||
/*
|
||||
* Give the object header a name so others can access it.
|
||||
@ -332,7 +463,7 @@ herr_t H5D_flush(hatom_t oid)
|
||||
/*
|
||||
* Give the object header a name so others can access it.
|
||||
*/
|
||||
if (H5G_insert (file, file->root_sym, NULL, dataset->name,
|
||||
if (H5G_insert (dataset->file, dataset->file->root_sym, NULL, dataset->name->s,
|
||||
&d_sym)<0) {
|
||||
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*can't name header*/
|
||||
}
|
||||
@ -353,7 +484,7 @@ herr_t H5D_flush(hatom_t oid)
|
||||
* changed messages aren't cached in the symbol table entry.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if (H5G_find (file, file->root_sym, NULL, dataset->name, &d_sym)<0) {
|
||||
if (H5G_find (dataset->file, dataset->file->root_sym, NULL, dataset->name->s, &d_sym)<0) {
|
||||
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL);
|
||||
}
|
||||
|
||||
@ -362,11 +493,11 @@ herr_t H5D_flush(hatom_t oid)
|
||||
*/
|
||||
|
||||
#if 0
|
||||
H5O_modify (file, d_sym.header, &d_sym, &entry_changed,
|
||||
H5O_modify (dataset->file, d_sym.header, &d_sym, &entry_changed,
|
||||
H5O_WHATEVER, 0, &the_message);
|
||||
H5O_modify (file, d_sym.header, &d_sym, &entry_changed,
|
||||
H5O_modify (dataset->file, d_sym.header, &d_sym, &entry_changed,
|
||||
H5O_WHATEVER, 0, &the_message);
|
||||
H5O_modify (file, d_sym.header, &d_sym, &entry_changed,
|
||||
H5O_modify (dataset->file, d_sym.header, &d_sym, &entry_changed,
|
||||
H5O_WHATEVER, 0, &the_message);
|
||||
#endif
|
||||
|
||||
@ -380,7 +511,7 @@ herr_t H5D_flush(hatom_t oid)
|
||||
* Make sure the symbol table entry as modified by the
|
||||
* changing of messages gets back to the file.
|
||||
*/
|
||||
H5G_modify (file, file->root_sym, NULL, dataset->name, &d_sym);
|
||||
H5G_modify (dataset->file, dataset->file->root_sym, NULL, dataset->name->s, &d_sym);
|
||||
}
|
||||
}
|
||||
dataset->modified = FALSE;
|
||||
@ -430,6 +561,7 @@ herr_t H5D_release(hatom_t oid)
|
||||
|
||||
/* relase the memory used for the dataset */
|
||||
if(dataset->name!=NULL)
|
||||
HDfree(dataset->name->s);
|
||||
HDfree(dataset->name);
|
||||
HDfree(dataset);
|
||||
|
||||
@ -448,4 +580,3 @@ done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5D_release() */
|
||||
|
||||
|
||||
|
@ -23,15 +23,25 @@
|
||||
/* Private headers needed by this file */
|
||||
#include <H5private.h>
|
||||
#include <H5Cprivate.h> /* for the hobjtype_t type */
|
||||
#include <H5Gprivate.h> /* Symbol tables */
|
||||
#include <H5Tprivate.h> /* for the h5_datatype_t type */
|
||||
#include <H5Pprivate.h> /* for the H5P_sdim_t type */
|
||||
#include <H5Oprivate.h> /* Object Headers */
|
||||
|
||||
/* Define a struct to carry all the information required to look up an object header */
|
||||
typedef struct {
|
||||
hatom_t fid; /* File Id for object */
|
||||
haddr_t ohdr; /* Offset of the object header */
|
||||
H5G_entry_t *dir; /* directory entry for the directory the object is located in */
|
||||
H5G_entry_t *ent; /* directory entry for the object itself */
|
||||
} H5D_oid_t;
|
||||
|
||||
typedef struct {
|
||||
hatom_t file; /* ID of the file-store of this object */
|
||||
char *name; /* Name of dataset */
|
||||
hdf5_file_t *file; /* Pointer to the file-store of this object */
|
||||
H5O_name_t *name; /* Name of dataset */
|
||||
hbool_t modified; /* Whether the dataset has been modified from version on disk */
|
||||
h5_datatype_t *type; /* Pointer to datatype of the dataset */
|
||||
H5P_sdim_t *dim; /* Pointer to dimensionality of the dataset */
|
||||
h5_datatype_t *type; /* Pointer to datatype of the dataset */
|
||||
H5P_dim_t *dim; /* Pointer to dimensionality of the dataset */
|
||||
haddr_t header; /* offset of the object header for this dataset */
|
||||
haddr_t data; /* offset of the data in the file */
|
||||
} H5D_dataset_t;
|
||||
@ -43,6 +53,7 @@ typedef struct {
|
||||
|
||||
/*-----------------_-- Local function prototypes ----------------------------*/
|
||||
hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name);
|
||||
hatom_t H5D_access(hatom_t oid);
|
||||
herr_t H5D_flush(hatom_t oid);
|
||||
herr_t H5D_release(hatom_t oid);
|
||||
|
||||
|
@ -29,6 +29,7 @@ extern "C" {
|
||||
|
||||
/* Functions in H5D.c */
|
||||
herr_t H5Dset_info(hatom_t oid, hatom_t tid, hatom_t did);
|
||||
herr_t H5Dget_info(hatom_t oid, hatom_t *tid, hatom_t *sid);
|
||||
herr_t H5Dwrite(hatom_t oid, hatom_t did, VOIDP buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -113,9 +113,9 @@ static meta_func_t meta_func_arr[]={
|
||||
H5P_release /* Dimensionality Release */
|
||||
},
|
||||
{ /* Dataset object meta-functions (defined in H5D.c) */
|
||||
H5_DATASPACE, /* Dataset Type ID */
|
||||
H5_DATASET, /* Dataset Type ID */
|
||||
H5D_create, /* Dataset Create */
|
||||
NULL, /* Dataset Access */
|
||||
H5D_access, /* Dataset Access */
|
||||
NULL, /* Dataset Copy */
|
||||
NULL, /* Dataset FindName */
|
||||
NULL, /* Dataset NameLen */
|
||||
|
@ -46,12 +46,12 @@ static intn interface_initialize_g = FALSE;
|
||||
|
||||
/* ID to type mapping */
|
||||
static const H5O_class_t *const message_type_g[] = {
|
||||
H5O_NULL, /*0x0000 Null */
|
||||
H5O_SIM_DIM, /*0x0001 Simple dimensionality */
|
||||
H5O_NULL, /*0x0000 Null */
|
||||
H5O_SIM_DIM, /*0x0001 Simple dimensionality */
|
||||
NULL, /*0x0002 Data space (fiber bundle?) */
|
||||
H5O_SIM_DTYPE, /*0x0003 Simple data type */
|
||||
H5O_SIM_DTYPE, /*0x0003 Simple data type */
|
||||
NULL, /*0x0004 Compound data type */
|
||||
NULL, /*0x0005 Data storage -- standard object */
|
||||
H5O_STD_STORE, /*0x0005 Data storage -- standard object */
|
||||
NULL, /*0x0006 Data storage -- compact object */
|
||||
NULL, /*0x0007 Data storage -- external object */
|
||||
NULL, /*0x0008 Data storage -- indexed object */
|
||||
|
@ -98,18 +98,7 @@ extern const H5O_class_t H5O_NULL[1];
|
||||
#define H5O_SIM_DIM_ID 0x0001
|
||||
extern const H5O_class_t H5O_SIM_DIM[1];
|
||||
|
||||
/* Hmm, let's try this... */
|
||||
#ifdef QAK
|
||||
typedef struct {
|
||||
uint32 rank; /* Number of dimensions */
|
||||
uint32 dim_flags; /* Dimension flags */
|
||||
uint32 *size; /* Dimension sizes */
|
||||
uint32 *max; /* Maximum dimension sizes */
|
||||
uint32 *perm; /* Dimension permutations */
|
||||
} H5O_sim_dim_t;
|
||||
#else /* QAK */
|
||||
typedef H5P_sdim_t H5O_sim_dim_t;
|
||||
#endif /* QAK */
|
||||
|
||||
/*
|
||||
* Simple Datatype message.
|
||||
@ -117,16 +106,18 @@ typedef H5P_sdim_t H5O_sim_dim_t;
|
||||
#define H5O_SIM_DTYPE_ID 0x0003
|
||||
extern const H5O_class_t H5O_SIM_DTYPE[1];
|
||||
|
||||
/* Hmm, let's try this... */
|
||||
#ifdef QAK
|
||||
typedef struct {
|
||||
uint8 length; /* Number of bytes */
|
||||
uint8 arch; /* Architecture format of the data */
|
||||
hatom_t type; /* Type of the data */
|
||||
} H5O_sim_dtype_t;
|
||||
#else /* QAK */
|
||||
typedef h5_atomic_type_t H5O_sim_dtype_t;
|
||||
#endif /* QAK */
|
||||
|
||||
/*
|
||||
* Standard Data Storage message.
|
||||
*/
|
||||
#define H5O_STD_STORE_ID 0x0005
|
||||
extern const H5O_class_t H5O_STD_STORE[1];
|
||||
|
||||
typedef struct H5O_std_store {
|
||||
haddr_t off;
|
||||
haddr_t len;
|
||||
} H5O_std_store_t;
|
||||
|
||||
/*
|
||||
* Object name message.
|
||||
|
@ -292,12 +292,17 @@ H5O_sim_dim_cache (H5G_entry_t *ent, const void *mesg)
|
||||
} /* end if */
|
||||
|
||||
/* Check each dimension */
|
||||
for(u=0; u<sdim->rank; u++)
|
||||
if (ent->cache.sdata.dim[u] != sdim->size[u])
|
||||
{
|
||||
modified = BTRUE;
|
||||
ent->cache.sdata.dim[u] = sdim->size[u];
|
||||
} /* end if */
|
||||
if(ent->cache.sdata.dim==NULL)
|
||||
modified = BTRUE;
|
||||
else
|
||||
{
|
||||
for(u=0; u<sdim->rank; u++)
|
||||
if (ent->cache.sdata.dim[u] != sdim->size[u])
|
||||
{
|
||||
modified = BTRUE;
|
||||
ent->cache.sdata.dim[u] = sdim->size[u];
|
||||
} /* end if */
|
||||
} /* end else */
|
||||
} /* end else */
|
||||
|
||||
FUNC_LEAVE (modified);
|
||||
|
77
src/H5P.c
77
src/H5P.c
@ -171,7 +171,7 @@ done:
|
||||
This function determines the if a dataspace is "simple". ie. if it
|
||||
has orthogonal, evenly spaced dimensions.
|
||||
--------------------------------------------------------------------------*/
|
||||
hbool_t H5P_is_simple(H5P_sdim_t *sdim)
|
||||
hbool_t H5P_is_simple(H5P_dim_t *sdim)
|
||||
{
|
||||
hbool_t ret_value = BFAIL;
|
||||
|
||||
@ -181,11 +181,14 @@ hbool_t H5P_is_simple(H5P_sdim_t *sdim)
|
||||
H5ECLEAR;
|
||||
|
||||
assert(sdim);
|
||||
ret_value=BTRUE; /* Currently all dataspaces are simple */
|
||||
if(sdim->type==H5P_TYPE_UNKNOWN)
|
||||
{
|
||||
HGOTO_ERROR (H5E_INTERNAL, H5E_UNINITIALIZED, FAIL);
|
||||
}
|
||||
else
|
||||
ret_value=sdim->type==H5P_TYPE_SIMPLE ? BTRUE : BFALSE; /* Currently all dataspaces are simple, but check anyway */
|
||||
|
||||
#ifdef LATER
|
||||
done:
|
||||
#endif /* LATER */
|
||||
if(ret_value == BFAIL)
|
||||
{ /* Error condition cleanup */
|
||||
|
||||
@ -310,6 +313,58 @@ done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5Pset_space() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5P_nelem
|
||||
PURPOSE
|
||||
Return the number of elements in a dataspace (internal)
|
||||
USAGE
|
||||
uintn H5P_nelem(space)
|
||||
H5P_dim_t *space; IN: Pointer to the dataspace object to query
|
||||
RETURNS
|
||||
The number of elements in a dataspace on success, UFAIL on failure
|
||||
DESCRIPTION
|
||||
This function determines the number of dataset elements in a
|
||||
dataspace. For example, a simple 3-dimensional dataspace with dimensions
|
||||
2, 3 and 4 would have 24 elements.
|
||||
UFAIL is returned on an error, otherwise the number of elements is returned.
|
||||
--------------------------------------------------------------------------*/
|
||||
uintn H5P_nelem(H5P_dim_t *space)
|
||||
{
|
||||
uintn u; /* local counting variable */
|
||||
uintn ret_value = UFAIL;
|
||||
|
||||
FUNC_ENTER(H5P_nelem, H5P_init_interface, UFAIL);
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
|
||||
assert(space);
|
||||
|
||||
/* Check for anything but simple dataspaces for now */
|
||||
if(space->type!=H5P_TYPE_SIMPLE)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL);
|
||||
|
||||
/* Check for other form of scalar dataspaces */
|
||||
if(space->s->rank==0)
|
||||
ret_value=1;
|
||||
else
|
||||
{
|
||||
for(ret_value=1, u=0; u<(uintn)space->s->rank; u++)
|
||||
ret_value*=space->s->size[u];
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
if(ret_value == UFAIL)
|
||||
{ /* Error condition cleanup */
|
||||
|
||||
} /* end if */
|
||||
|
||||
/* Normal function cleanup */
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5P_nelem() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5Pnelem
|
||||
@ -329,7 +384,6 @@ done:
|
||||
uintn H5Pnelem(hatom_t sid)
|
||||
{
|
||||
H5P_dim_t *space=NULL; /* dataspace to modify */
|
||||
uintn u; /* local counting variable */
|
||||
uintn ret_value = UFAIL;
|
||||
|
||||
FUNC_ENTER(H5Pnelem, H5P_init_interface, UFAIL);
|
||||
@ -344,18 +398,7 @@ uintn H5Pnelem(hatom_t sid)
|
||||
if((space=H5Aatom_object(sid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
|
||||
/* Check for anything but simple dataspaces for now */
|
||||
if(space->type!=H5P_TYPE_SIMPLE)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL);
|
||||
|
||||
/* Check for other form of scalar dataspaces */
|
||||
if(space->s->rank==0)
|
||||
ret_value=1;
|
||||
else
|
||||
{
|
||||
for(ret_value=1, u=0; u<(uintn)space->s->rank; u++)
|
||||
ret_value*=space->s->size[u];
|
||||
} /* end else */
|
||||
ret_value=H5P_nelem(space);
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
|
@ -41,7 +41,8 @@ typedef struct H5P_sdim_t {
|
||||
/* Private functions */
|
||||
hatom_t H5P_create(hatom_t owner_id, hobjtype_t type, const char *name);
|
||||
uint32 H5P_get_lrank(H5P_sdim_t *sdim);
|
||||
hbool_t H5P_is_simple(H5P_sdim_t *sdim);
|
||||
hbool_t H5P_is_simple(H5P_dim_t *sdim);
|
||||
uintn H5P_nelem(H5P_dim_t *space);
|
||||
herr_t H5P_release(hatom_t oid);
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <H5Apublic.h>
|
||||
|
||||
/* Define atomic datatypes */
|
||||
#define H5P_SCALAR MAKE_ATOM(H5_DATASPACE,0)
|
||||
#define H5P_SCALAR MAKE_ATOM(H5_DATASPACE,0) /* Atom for scalar dataspace */
|
||||
|
||||
/* Different types of dataspaces */
|
||||
#define H5P_TYPE_UNKNOWN 0 /* Dataspace is not unitialized */
|
||||
|
137
src/H5T.c
137
src/H5T.c
@ -260,6 +260,7 @@ hbool_t H5T_is_atomic(h5_datatype_t *type)
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
|
||||
assert (type);
|
||||
/* Check the base type of the datatype */
|
||||
if(H5T_COMPOUND==type->dt.base)
|
||||
ret_value=BFALSE;
|
||||
@ -301,6 +302,8 @@ hbool_t H5Tis_atomic(hatom_t tid)
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
if(H5Aatom_group(tid)!=H5_DATATYPE)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
|
||||
/* Go get the object */
|
||||
if((dt=H5Aatom_object(tid))==NULL)
|
||||
@ -517,6 +520,92 @@ done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5Tadd_field() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5T_size
|
||||
PURPOSE
|
||||
Determine the size of a datatype (internal)
|
||||
USAGE
|
||||
uintn H5Tsize(dt, mem_flag)
|
||||
h5_datatype_t *dt; IN: Pointer to Datatype object to query
|
||||
hbool_t mem_flag; IN: Whether the memory or disk size is desired
|
||||
RETURNS
|
||||
The size of the datatype on success or UFAIL on failure.
|
||||
DESCRIPTION
|
||||
Ths function returns the size of the datatype in bytes as it is stored
|
||||
on disk or in memory, depending on the mem_flag. Setting the mem_flag to
|
||||
BTRUE returns the size in memory, BFALSE returns the size on disk.
|
||||
--------------------------------------------------------------------------*/
|
||||
uintn H5T_size(h5_datatype_t *dt, hbool_t mem_flag)
|
||||
{
|
||||
uintn ret_value = UFAIL;
|
||||
|
||||
FUNC_ENTER(H5T_size, H5T_init_interface, UFAIL);
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
|
||||
assert(dt);
|
||||
|
||||
if(dt->dt.base==H5T_COMPOUND)
|
||||
{
|
||||
intn i; /* local counting variable */
|
||||
|
||||
/* Check the base type of the datatype */
|
||||
if(H5T_COMPOUND!=dt->dt.base)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);
|
||||
|
||||
/* Check if the compound information has been initialized */
|
||||
if(NULL==dt->ci)
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, FAIL);
|
||||
|
||||
/* Grab the number of fields */
|
||||
for(i=0; i<=dt->ci->n; i++)
|
||||
ret_value+=H5Tsize(dt->ci->flist[i].dt.base, dt->ci->flist[i].dt.len,
|
||||
dt->ci->flist[i].dt.arch,mem_flag)*H5Pnelem(dt->ci->flist[i].dim_id);
|
||||
} /* end if */
|
||||
else
|
||||
{ /* Simple, user-defined datatypes */
|
||||
switch(dt->dt.base)
|
||||
{
|
||||
case H5T_CHAR:
|
||||
case H5T_INT:
|
||||
case H5T_FLOAT: /* All three of thes types use the length as the number of bytes */
|
||||
ret_value=dt->dt.len;
|
||||
break;
|
||||
|
||||
case H5T_DATE:
|
||||
ret_value=8; /* Number of characters for ISO 8601 format */
|
||||
break;
|
||||
|
||||
case H5T_TIME:
|
||||
ret_value=6; /* Number of characters for ISO 8601 format */
|
||||
break;
|
||||
|
||||
case H5T_SPTR:
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
|
||||
break;
|
||||
|
||||
case H5T_PPTR:
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
|
||||
break;
|
||||
|
||||
default:
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, UFAIL);
|
||||
} /* end switch */
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
if(ret_value == UFAIL)
|
||||
{ /* Error condition cleanup */
|
||||
|
||||
} /* end if */
|
||||
|
||||
/* Normal function cleanup */
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5T_size() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5Tsize
|
||||
@ -580,53 +669,7 @@ uintn H5Tsize(hatom_t tid, uint8 len, uint8 arch, hbool_t mem_flag)
|
||||
if((dt=H5Aatom_object(tid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
|
||||
if(dt->dt.base==H5T_COMPOUND)
|
||||
{
|
||||
intn i; /* local counting variable */
|
||||
|
||||
/* Check the base type of the datatype */
|
||||
if(H5T_COMPOUND!=dt->dt.base)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);
|
||||
|
||||
/* Check if the compound information has been initialized */
|
||||
if(NULL==dt->ci)
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, FAIL);
|
||||
|
||||
/* Grab the number of fields */
|
||||
for(i=0; i<=dt->ci->n; i++)
|
||||
ret_value+=H5Tsize(dt->ci->flist[i].dt.base, dt->ci->flist[i].dt.len,
|
||||
dt->ci->flist[i].dt.arch,mem_flag)*H5Pnelem(dt->ci->flist[i].dim_id);
|
||||
} /* end if */
|
||||
else
|
||||
{ /* Simple, user-defined datatypes */
|
||||
switch(dt->dt.base)
|
||||
{
|
||||
case H5T_CHAR:
|
||||
case H5T_INT:
|
||||
case H5T_FLOAT: /* All three of thes types use the length as the number of bytes */
|
||||
ret_value=dt->dt.len;
|
||||
break;
|
||||
|
||||
case H5T_DATE:
|
||||
ret_value=8; /* Number of characters for ISO 8601 format */
|
||||
break;
|
||||
|
||||
case H5T_TIME:
|
||||
ret_value=6; /* Number of characters for ISO 8601 format */
|
||||
break;
|
||||
|
||||
case H5T_SPTR:
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
|
||||
break;
|
||||
|
||||
case H5T_PPTR:
|
||||
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
|
||||
break;
|
||||
|
||||
default:
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, UFAIL);
|
||||
} /* end switch */
|
||||
} /* end else */
|
||||
ret_value=H5T_size(dt,mem_flag);
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
|
@ -53,6 +53,7 @@ typedef struct {
|
||||
/* Private functions */
|
||||
hatom_t H5T_create(hatom_t owner_id, hobjtype_t type, const char *name);
|
||||
hbool_t H5T_is_atomic(h5_datatype_t *type);
|
||||
uintn H5T_size(h5_datatype_t *dt, hbool_t mem_flag);
|
||||
herr_t H5T_release(hatom_t oid);
|
||||
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@ PROGS=debug
|
||||
# Source and object files for the library (lexicographically)...
|
||||
LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5C.c H5D.c H5E.c H5F.c H5G.c H5Gnode.c \
|
||||
H5H.c H5M.c H5MF.c H5MM.c H5O.c H5Ocont.c H5Oname.c H5Onull.c \
|
||||
H5Ostab.c H5Osdtyp.c H5Osdim.c H5P.c H5T.c
|
||||
H5Ostab.c H5Osdtyp.c H5Osdim.c H5P.c H5T.c H5Ostdst.c
|
||||
LIB_OBJ=$(LIB_SRC:.c=.o)
|
||||
|
||||
# Source and object files for programs...
|
||||
|
Loading…
Reference in New Issue
Block a user