hdf5/src/H5Osdspace.c

562 lines
20 KiB
C
Raw Normal View History

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define H5O_PACKAGE /*suppress error about including H5Opkg */
#define H5S_PACKAGE /*prevent warning from including H5Spkg.h */
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
#include "H5Gprivate.h" /* Groups */
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5Spkg.h" /* Dataspaces */
/* PRIVATE PROTOTYPES */
static void *H5O_sdspace_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
[svn-r925] Changes since 19981116 ---------------------- ./INSTALL.parallel [NEW] We're beginning to unify some of the parallel installation steps. This file will contain general information for installing the parallel library. It's not complete yet. ./configure.in ./configure [REGENERATED] ./src/H5config.h.in [REGENERATED] Check for xdr_int() in libnsl required on Solaris when linking with hdf4. It's found on the Irix system I tested which complains that `-lnsl' didn't resolve any symbols. Oh well. Fixed the order of searching for libdf and libmfhdf for hdf4 linking. ./configure.in ./configure [REGENERATED] ./src/H5config.h.in [REGENERATED] ./src/H5Z.c Check for compress() in libz in order to find older versions of the library that will still work for hdf4. Added a separate check for compress2() that hdf5 will use. ./configure.in ./configure [REGENERATED] ./src/H5config.h.in [REGENERATED] ./src/H5.c ./src/H5private.h ./src/H5A.c ./src/H5B.c ./src/H5Bprivate.h ./src/H5D.c ./src/H5F.c ./src/H5Farray.c ./src/H5Fcore.c ./src/H5Ffamily.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fprivate.h ./src/H5Fsec2.c ./src/H5Fsplit.c ./src/H5Fstdio.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5Gpkg.h ./src/H5Gprivate.h ./src/H5HG.c ./src/H5HL.c ./src/H5O.c ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Ofill.c ./src/H5Olayout.c ./src/H5Omtime.c ./src/H5Oname.c ./src/H5Oprivate.h ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5R.c ./src/H5RA.c ./src/H5Sall.c ./src/H5Shyper.c ./src/H5Snone.c ./src/H5Spoint.c ./src/H5Sprivate.h ./src/H5Sselect.c ./src/H5T.c ./src/H5Tbit.c ./src/H5Tconv.c ./src/H5Tpkg.h ./src/H5V.c ./test/bittests.c ./test/gheap.c ./test/hyperslab.c ./test/istore.c ./test/tmeta.c ./test/trefer.c ./test/tselect.c ./tools/h5debug.c ./tools/h5tols.c Added checks for Posix.1g types like `int8_t'. If not defined then H5private.h defines them. Changed all `int8' etc. to `int8_t'. ./src/H5A.c ./src/H5D.c ./src/H5F.c ./src/H5G.c ./src/H5I.c ./src/H5P.c ./src/H5R.c ./src/H5RA.c ./src/H5S.c ./src/H5T.c ./src/H5TB.c ./src/H5Z.c Calling H5*_term_interface() resets interface_initialize_g to FALSE so a subsequent call to H5open() (implied or explicit) reinitializes global variables properly. ./src/H5private.h ./src/H5Oefl.c ./src/H5S.c Changed MAX_SIZET, MAX_SSIZET, MAX_HSIZET, and MAX_HSSIZET to SIZET_MAX, SSIZET_MAX, HSIZET_MAX, and HSSIZE_MAX to they match the Posix.1 constants in <limits.h>. ./src/H5T.c ./src/H5Tconv.c ./src/H5Tpkg.h ./src/H5Tprivate.h ./src/H5detect.c Added 36 more integer hardware conversion functions to the type conversion table for conversions to/from `long long' and `unsigned long long'. The `long long' names will be changed shortly to make them portable to Win32. Changed H5T_init() to H5T_native_open() and added an H5T_native_close() to open and close the predefined native data types. Increased the initial size of the type conversion table from 64 to 128 entries. Reordered the 90 new integer conversion functions so the names that are printed favor `int' over `short' or `long' when two of them are the same. ./test/dtypes.c Added hardware and software integer conversion tests for the 56 functions I added recently but not the additional 36 checked in this time. That will come next. Call H5close() after each test so type conversion statistics are easier to follow. Try this: $ HDF5_DEBUG=t ./dtypes Added more debugging output for when things go wrong. ./src/H5private.h Removed trailing carriage-returns inserted by broken operating system ;-)
1998-11-19 02:40:09 +08:00
static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_sdspace_reset(void *_mesg);
static herr_t H5O_sdspace_free(void *_mesg);
static herr_t H5O_sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src,
hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static herr_t H5O_sdspace_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
/* Set up & include shared message "interface" info */
#define H5O_SHARED_TYPE H5O_MSG_SDSPACE
#define H5O_SHARED_DECODE H5O_sdspace_shared_decode
#define H5O_SHARED_DECODE_REAL H5O_sdspace_decode
#define H5O_SHARED_ENCODE H5O_sdspace_shared_encode
#define H5O_SHARED_ENCODE_REAL H5O_sdspace_encode
#define H5O_SHARED_SIZE H5O_sdspace_shared_size
#define H5O_SHARED_SIZE_REAL H5O_sdspace_size
#define H5O_SHARED_DELETE H5O_sdspace_shared_delete
#undef H5O_SHARED_DELETE_REAL
#define H5O_SHARED_LINK H5O_sdspace_shared_link
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_sdspace_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
#define H5O_SHARED_DEBUG H5O_sdspace_shared_debug
#define H5O_SHARED_DEBUG_REAL H5O_sdspace_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
/* This message derives from H5O message class */
const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
[svn-r407] ./src/H5A.c ./src/H5D.c ./src/H5Tconv.c ./src/H5detect.c Updated to work with new internal H5T functions. Fixed some data type memory leaks during error recovery. ./src/H5Dprivate.h Added H5D_typeof() similar to H5D_entof() that returns a pointer directly to the dataset's type. This is used by H5Tcopy() when invoked on a dataset (see below). ./src/H5Epublic.h Fixed typos in H5E_BEGIN_TRY and H5E_END_TRY macros. ./src/H5F.c Closing a file with objects still open reports the file name in the warning message. Removed unnecessary invalidation of shared data types. ./src/H5Gent.c ./src/H5Gpkg.h ./src/H5Gprivate.h Added `const' to some arguments. ./src/H5O.c ./src/H5Oprivate.h ./src/H5Oshared.c An object header message can now be a pointer to a message in some other object header. The pointer is to the first message of the appropriate type in the other object header and hard link counts are maintained automatically to prevent dangling pointers. The old global heap method of message sharing is also supported although nothing actually uses it. ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Olayout.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshare.c ./src/H5Ostab.c Changed the data type for the shared message info struct to H5O_shared_t and added an extra initializer to the class methods struct for the set_share method. ./src/H5Odtype.c Added the ability to share data type messages by pointing to other object headers. ./src/H5T.c ./src/H5Tpkg.h ./src/H5Tprivate.h ./src/H5Tpublic.h Added named data types and changed the functionality of some API functions as follows: * The term `read-only' means that a type handle cannot be modified with functions like H5Tset_*() or H5Tinsert(). * The term `immutable' means the same as `read-only' with the added restriction that H5Tclose() cannot be called for the type. A transient type is made immutable by calling H5Tlock(). * Handles to named types are always read-only. * Handles to predefined types are immutable. * A transient type can be converted to a named type by calling H5Tcommit(). This function will fail if the type is already named or is immutable. * The API function H5Tcommitted() returns an indication of whether a data type has been commited (or is named). If H5Tcommitted() returns TRUE for a data type obtained by calling H5Dget_type() on a dataset, then the dataset is using a shared data type. * H5Topen() returns a handle to a named type. * H5Tcopy() always returns a handle to a modifiable transient type even when invoked on a named type. Also, when invoked on a dataset it returns a modifiable transient type which is a copy of the dataset's data type. * Using a named data type in the call to H5Dcreate() causes the dataset object header to point to the named data type, but using a transient type causes the type to be copied into the dataset's object header. * The data type returned from H5Dget_type() is a named data type or a read-only transient data type depending on whether the dataset points to a named data type. The old behavior, to return a modifiable transient type, is accomplished by overloading H5Tcopy() to operate on datasets (see above). * H5Tshare(), H5Tunshare(), and H5Tis_shared() have been removed from the API. The following features were *not* implemented because they need more discussion: * A named data type can be opened by applying H5Topen() to a dataset in which case the data type is the data type of the dataset (or the data type to which the dataset points if the dataset has a shared data type). * A named data type can have attributes like groups or datasets. * The members of a compound data type can point to named data types. ./src/h5ls.c Reports `Data type' for named data type objects in the file.
1998-06-05 06:27:11 +08:00
H5O_SDSPACE_ID, /* message id number */
"dataspace", /* message name for debugging */
sizeof(H5S_extent_t), /* native message size */
H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */
H5O_sdspace_shared_decode, /* decode message */
H5O_sdspace_shared_encode, /* encode message */
[svn-r407] ./src/H5A.c ./src/H5D.c ./src/H5Tconv.c ./src/H5detect.c Updated to work with new internal H5T functions. Fixed some data type memory leaks during error recovery. ./src/H5Dprivate.h Added H5D_typeof() similar to H5D_entof() that returns a pointer directly to the dataset's type. This is used by H5Tcopy() when invoked on a dataset (see below). ./src/H5Epublic.h Fixed typos in H5E_BEGIN_TRY and H5E_END_TRY macros. ./src/H5F.c Closing a file with objects still open reports the file name in the warning message. Removed unnecessary invalidation of shared data types. ./src/H5Gent.c ./src/H5Gpkg.h ./src/H5Gprivate.h Added `const' to some arguments. ./src/H5O.c ./src/H5Oprivate.h ./src/H5Oshared.c An object header message can now be a pointer to a message in some other object header. The pointer is to the first message of the appropriate type in the other object header and hard link counts are maintained automatically to prevent dangling pointers. The old global heap method of message sharing is also supported although nothing actually uses it. ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Olayout.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshare.c ./src/H5Ostab.c Changed the data type for the shared message info struct to H5O_shared_t and added an extra initializer to the class methods struct for the set_share method. ./src/H5Odtype.c Added the ability to share data type messages by pointing to other object headers. ./src/H5T.c ./src/H5Tpkg.h ./src/H5Tprivate.h ./src/H5Tpublic.h Added named data types and changed the functionality of some API functions as follows: * The term `read-only' means that a type handle cannot be modified with functions like H5Tset_*() or H5Tinsert(). * The term `immutable' means the same as `read-only' with the added restriction that H5Tclose() cannot be called for the type. A transient type is made immutable by calling H5Tlock(). * Handles to named types are always read-only. * Handles to predefined types are immutable. * A transient type can be converted to a named type by calling H5Tcommit(). This function will fail if the type is already named or is immutable. * The API function H5Tcommitted() returns an indication of whether a data type has been commited (or is named). If H5Tcommitted() returns TRUE for a data type obtained by calling H5Dget_type() on a dataset, then the dataset is using a shared data type. * H5Topen() returns a handle to a named type. * H5Tcopy() always returns a handle to a modifiable transient type even when invoked on a named type. Also, when invoked on a dataset it returns a modifiable transient type which is a copy of the dataset's data type. * Using a named data type in the call to H5Dcreate() causes the dataset object header to point to the named data type, but using a transient type causes the type to be copied into the dataset's object header. * The data type returned from H5Dget_type() is a named data type or a read-only transient data type depending on whether the dataset points to a named data type. The old behavior, to return a modifiable transient type, is accomplished by overloading H5Tcopy() to operate on datasets (see above). * H5Tshare(), H5Tunshare(), and H5Tis_shared() have been removed from the API. The following features were *not* implemented because they need more discussion: * A named data type can be opened by applying H5Topen() to a dataset in which case the data type is the data type of the dataset (or the data type to which the dataset points if the dataset has a shared data type). * A named data type can have attributes like groups or datasets. * The members of a compound data type can point to named data types. ./src/h5ls.c Reports `Data type' for named data type objects in the file.
1998-06-05 06:27:11 +08:00
H5O_sdspace_copy, /* copy the native value */
H5O_sdspace_shared_size, /* size of symbol table entry */
[svn-r407] ./src/H5A.c ./src/H5D.c ./src/H5Tconv.c ./src/H5detect.c Updated to work with new internal H5T functions. Fixed some data type memory leaks during error recovery. ./src/H5Dprivate.h Added H5D_typeof() similar to H5D_entof() that returns a pointer directly to the dataset's type. This is used by H5Tcopy() when invoked on a dataset (see below). ./src/H5Epublic.h Fixed typos in H5E_BEGIN_TRY and H5E_END_TRY macros. ./src/H5F.c Closing a file with objects still open reports the file name in the warning message. Removed unnecessary invalidation of shared data types. ./src/H5Gent.c ./src/H5Gpkg.h ./src/H5Gprivate.h Added `const' to some arguments. ./src/H5O.c ./src/H5Oprivate.h ./src/H5Oshared.c An object header message can now be a pointer to a message in some other object header. The pointer is to the first message of the appropriate type in the other object header and hard link counts are maintained automatically to prevent dangling pointers. The old global heap method of message sharing is also supported although nothing actually uses it. ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Olayout.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshare.c ./src/H5Ostab.c Changed the data type for the shared message info struct to H5O_shared_t and added an extra initializer to the class methods struct for the set_share method. ./src/H5Odtype.c Added the ability to share data type messages by pointing to other object headers. ./src/H5T.c ./src/H5Tpkg.h ./src/H5Tprivate.h ./src/H5Tpublic.h Added named data types and changed the functionality of some API functions as follows: * The term `read-only' means that a type handle cannot be modified with functions like H5Tset_*() or H5Tinsert(). * The term `immutable' means the same as `read-only' with the added restriction that H5Tclose() cannot be called for the type. A transient type is made immutable by calling H5Tlock(). * Handles to named types are always read-only. * Handles to predefined types are immutable. * A transient type can be converted to a named type by calling H5Tcommit(). This function will fail if the type is already named or is immutable. * The API function H5Tcommitted() returns an indication of whether a data type has been commited (or is named). If H5Tcommitted() returns TRUE for a data type obtained by calling H5Dget_type() on a dataset, then the dataset is using a shared data type. * H5Topen() returns a handle to a named type. * H5Tcopy() always returns a handle to a modifiable transient type even when invoked on a named type. Also, when invoked on a dataset it returns a modifiable transient type which is a copy of the dataset's data type. * Using a named data type in the call to H5Dcreate() causes the dataset object header to point to the named data type, but using a transient type causes the type to be copied into the dataset's object header. * The data type returned from H5Dget_type() is a named data type or a read-only transient data type depending on whether the dataset points to a named data type. The old behavior, to return a modifiable transient type, is accomplished by overloading H5Tcopy() to operate on datasets (see above). * H5Tshare(), H5Tunshare(), and H5Tis_shared() have been removed from the API. The following features were *not* implemented because they need more discussion: * A named data type can be opened by applying H5Topen() to a dataset in which case the data type is the data type of the dataset (or the data type to which the dataset points if the dataset has a shared data type). * A named data type can have attributes like groups or datasets. * The members of a compound data type can point to named data types. ./src/h5ls.c Reports `Data type' for named data type objects in the file.
1998-06-05 06:27:11 +08:00
H5O_sdspace_reset, /* default reset method */
[svn-r6252] Purpose: Lots of performance improvements & a couple new internal API interfaces. Description: Performance Improvements: - Cached file offset & length sizes in shared file struct, to avoid constantly looking them up in the FCPL. - Generic property improvements: - Added "revision" number to generic property classes to speed up comparisons. - Changed method of storing properties from using a hash-table to the TBBT routines in the library. - Share the propery names between classes and the lists derived from them. - Removed redundant 'def_value' buffer from each property. - Switching code to use a "copy on write" strategy for properties in each list, where the properties in each list are shared with the properties in the class, until a property's value is changed in a list. - Fixed error in layout code which was allocating too many buffers. - Redefined public macros of the form (H5open()/H5check, <variable>) internally to only be (<variable>), avoiding innumerable useless calls to H5open() and H5check_version(). - Reuse already zeroed buffers in H5F_contig_fill instead of constantly re-zeroing them. - Don't write fill values if writing entire dataset. - Use gettimeofday() system call instead of time() system when checking the modification time of a dataset. - Added reference counted string API and use it for tracking the names of objects opening in a file (for the ID->name code). - Removed redundant H5P_get() calls in B-tree routines. - Redefine H5T datatype macros internally to the library, to avoid calling H5check redundantly. - Keep dataspace information for dataset locally instead of reading from disk each time. Added new module to track open objects in a file, to allow this (which will be useful eventually for some FPH5 metadata caching issues). - Remove H5AC_find macro which was inlining metadata cache lookups, and call function instead. - Remove redundant memset() calls from H5G_namei() routine. - Remove redundant checking of object type when locating objects in metadata cache and rely on the address only. - Create default dataset object to use when default dataset creation property list is used to create datasets, bypassing querying for all the property list values. - Use default I/O vector size when performing raw data with the default dataset transfer property list, instead of querying for I/O vector size. - Remove H5P_DEFAULT internally to the library, replacing it with more specific default property list based on the type of property list needed. - Remove redundant memset() calls in object header message (H5O*) routines. - Remove redunant memset() calls in data I/O routines. - Split free-list allocation routines into malloc() and calloc()- like routines, instead of one combined routine. - Remove lots of indirection in H5O*() routines. - Simplify metadata cache entry comparison routine (used when flushing entire cache out). - Only enable metadata cache statistics when H5AC_DEBUG is turned on, instead of always tracking them. - Simplify address comparison macro (H5F_addr_eq). - Remove redundant metadata cache entry protections during dataset creation by protecting the object header once and making all the modifications necessary for the dataset creation before unprotecting it. - Reduce # of "number of element in extent" computations performed by computing and storing the value during dataspace creation. - Simplify checking for group location's file information, when file has not been involving in file-mounting operations. - Use binary encoding for modification time, instead of ASCII. - Hoist H5HL_peek calls (to get information in a local heap) out of loops in many group routine. - Use static variable for iterators of selections, instead of dynamically allocation them each time. - Lookup & insert new entries in one step, avoiding traversing group's B-tree twice. - Fixed memory leak in H5Gget_objname_idx() routine (tangential to performance improvements, but fixed along the way). - Use free-list for reference counted strings. - Don't bother copying object names into cached group entries, since they are re-created when an object is opened. The benchmark I used to measure these results created several thousand small (2K) datasets in a file and wrote out the data for them. This is Elena's "regular.c" benchmark. These changes resulted in approximately ~4.3x speedup of the development branch when compared to the previous code in the development branch and ~1.4x speedup compared to the release branch. Additionally, these changes reduce the total memory used (code and data) by the development branch by ~800KB, bringing the development branch back into the same ballpark as the release branch. I'll send out a more detailed description of the benchmark results as a followup note. New internal API routines: Added "reference counted strings" API for tracking strings that get used by multiple owners without duplicating the strings. Added "ternary search tree" API for text->object mappings. Platforms tested: Tested h5committest {arabica (fortran), eirene (fortran, C++) modi4 (parallel, fortran)} Other platforms/configurations tested? FreeBSD 4.7 (sleipnir) serial & parallel Solaris 2.6 (baldric) serial
2003-01-10 01:20:03 +08:00
H5O_sdspace_free, /* free method */
H5O_sdspace_shared_delete, /* file delete method */
H5O_sdspace_shared_link, /* link method */
NULL, /* set share method */
NULL, /*can share method */
H5O_sdspace_pre_copy_file, /* pre copy native value to file */
H5O_sdspace_shared_copy_file,/* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
H5O_sdspace_shared_debug /* debug the message */
}};
/* Initial version of the dataspace information */
#define H5O_SDSPACE_VERSION_1 1
/* This version adds support for "null" dataspaces, encodes the type of the
* dataspace in the message and eliminated the rest of the "reserved"
* bytes.
*/
#define H5O_SDSPACE_VERSION_2 2
/* The latest version of the format. Look through the 'encode'
* and 'size' callbacks for places to change when updating this. */
#define H5O_SDSPACE_VERSION_LATEST H5O_SDSPACE_VERSION_2
/* Declare external the free list for H5S_extent_t's */
H5FL_EXTERN(H5S_extent_t);
/* Declare external the free list for hsize_t arrays */
H5FL_ARR_EXTERN(hsize_t);
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_decode
PURPOSE
Decode a simple dimensionality message and return a pointer to a memory
struct with the decoded information
USAGE
void *H5O_sdspace_decode(f, dxpl_id, mesg_flags, p)
H5F_t *f; IN: pointer to the HDF5 file struct
hid_t dxpl_id; IN: DXPL for any I/O
unsigned mesg_flags; IN: Message flags to influence decoding
const uint8 *p; IN: the raw information buffer
RETURNS
Pointer to the new message in native order on success, NULL on failure
DESCRIPTION
This function decodes the "raw" disk form of a simple dimensionality
message into a struct in memory native format. The struct is allocated
within this function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags,
const uint8_t *p)
{
H5S_extent_t *sdim = NULL;/* New extent dimensionality structure */
void *ret_value;
unsigned i; /* local counting variable */
unsigned flags, version;
FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_decode)
/* check args */
HDassert(f);
HDassert(p);
/* decode */
if(NULL == (sdim = H5FL_CALLOC(H5S_extent_t)))
HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, NULL, "dataspace structure allocation failed")
/* Check version */
version = *p++;
if(version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in dataspace message")
/* Get rank */
sdim->rank = *p++;
if(sdim->rank > H5S_MAX_RANK)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple dataspace dimensionality is too large")
/* Get dataspace flags for later */
flags = *p++;
/* Get or determine the type of the extent */
if(version >= H5O_SDSPACE_VERSION_2)
sdim->type = (H5S_class_t)*p++;
else {
/* Set the dataspace type to be simple or scalar as appropriate */
if(sdim->rank > 0)
sdim->type = H5S_SIMPLE;
else
sdim->type = H5S_SCALAR;
/* Increment past reserved byte */
p++;
} /* end else */
/* Only Version 1 has these reserved bytes */
if(version == H5O_SDSPACE_VERSION_1)
p += 4; /*reserved*/
/* Decode dimension sizes */
if(sdim->rank > 0) {
if(NULL == (sdim->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
for(i = 0; i < sdim->rank; i++) {
H5F_DECODE_LENGTH(f, p, sdim->size[i]);
2005-11-15 10:55:39 +08:00
#ifndef H5_HAVE_LARGE_HSIZET
/* Rudimentary check for overflow of the dimension size */
if(sdim->size[i] == 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADSIZE, NULL, "invalid size detected")
2005-11-15 10:55:39 +08:00
#endif /* H5_HAVE_LARGE_HSIZET */
} /* end for */
if(flags & H5S_VALID_MAX) {
if(NULL == (sdim->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
for(i = 0; i < sdim->rank; i++)
H5F_DECODE_LENGTH (f, p, sdim->max[i]);
} /* end if */
} /* end if */
/* Compute the number of elements in the extent */
if(sdim->type == H5S_NULL)
sdim->nelem = 0;
else {
for(i = 0, sdim->nelem = 1; i < sdim->rank; i++)
sdim->nelem *= sdim->size[i];
} /* end else */
/* Set return value */
ret_value = (void*)sdim; /*success*/
done:
if(!ret_value && sdim) {
H5S_extent_release(sdim);
H5FL_FREE(H5S_extent_t, sdim);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_sdspace_decode() */
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_encode
PURPOSE
Encode a simple dimensionality message
USAGE
herr_t H5O_sdspace_encode(f, raw_size, p, mesg)
H5F_t *f; IN: pointer to the HDF5 file struct
size_t raw_size; IN: size of the raw information buffer
const uint8 *p; IN: the raw information buffer
const void *mesg; IN: Pointer to the extent dimensionality struct
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
This function encodes the native memory form of the simple
dimensionality message in the "raw" disk form.
MODIFICATIONS
Robb Matzke, 1998-04-09
The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
instead of just four bytes.
Robb Matzke, 1998-07-20
Added a version number and reformatted the message for aligment.
Raymond Lu
April 8, 2004
Added the type of dataspace into this header message using a reserved
byte.
--------------------------------------------------------------------------*/
static herr_t
H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg)
{
const H5S_extent_t *sdim = (const H5S_extent_t *)_mesg;
unsigned flags = 0;
unsigned version;
hbool_t use_latest_format; /* Flag indicating the newest file format should be used */
unsigned u; /* Local counting variable */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_encode)
/* check args */
HDassert(f);
HDassert(p);
HDassert(sdim);
/* Get the file's 'use the latest version of the format' flag */
use_latest_format = H5F_USE_LATEST_FORMAT(f);
/* Version */
if(use_latest_format)
version = H5O_SDSPACE_VERSION_LATEST;
else if(sdim->type == H5S_NULL)
version = H5O_SDSPACE_VERSION_2;
else
version = H5O_SDSPACE_VERSION_1;
*p++ = version;
/* Rank */
*p++ = sdim->rank;
/* Flags */
if(sdim->max)
flags |= H5S_VALID_MAX;
*p++ = flags;
/* Dataspace type */
if(version > H5O_SDSPACE_VERSION_1)
*p++ = sdim->type;
else {
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
} /* end else */
/* Current & maximum dimensions */
if(sdim->rank > 0) {
for(u = 0; u < sdim->rank; u++)
H5F_ENCODE_LENGTH(f, p, sdim->size[u]);
if(flags & H5S_VALID_MAX) {
for(u = 0; u < sdim->rank; u++)
H5F_ENCODE_LENGTH(f, p, sdim->max[u]);
} /* end if */
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_sdspace_encode() */
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_copy
PURPOSE
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
void *H5O_sdspace_copy(mesg, dest)
const void *mesg; IN: Pointer to the source extent dimensionality struct
const void *dest; IN: Pointer to the destination extent dimensionality struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
This function copies a native (memory) simple dimensionality message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
static void *
H5O_sdspace_copy(const void *mesg, void *dest)
{
const H5S_extent_t *src = (const H5S_extent_t *) mesg;
H5S_extent_t *dst = (H5S_extent_t *) dest;
void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_copy)
/* check args */
HDassert(src);
if(!dst && NULL == (dst = H5FL_MALLOC(H5S_extent_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy extent information */
if(H5S_extent_copy(dst, src) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent")
/* Set return value */
ret_value = dst;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_sdspace_copy() */
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_size
PURPOSE
Return the raw message size in bytes
USAGE
void *H5O_sdspace_size(f, mesg)
H5F_t *f; IN: pointer to the HDF5 file struct
const void *mesg; IN: Pointer to the source extent dimensionality struct
RETURNS
Size of message on success, zero on failure
DESCRIPTION
This function returns the size of the raw simple dimensionality message on
success. (Not counting the message type or size fields, only the data
portion of the message). It doesn't take into account alignment.
MODIFICATIONS
Robb Matzke, 1998-04-09
The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
instead of just four bytes.
--------------------------------------------------------------------------*/
static size_t
H5O_sdspace_size(const H5F_t *f, const void *_mesg)
{
const H5S_extent_t *space = (const H5S_extent_t *)_mesg;
hbool_t use_latest_format; /* Flag indicating the newest file format should be used */
size_t ret_value;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_size)
/* Get the file's 'use the latest version of the format' flag */
use_latest_format = H5F_USE_LATEST_FORMAT(f);
/* Basic information for all dataspace messages */
ret_value = 1 + /* Version */
1 + /* Rank */
1 + /* Flags */
1 + /* Dataspace type/reserved */
(use_latest_format ? 0 : 4); /* Eliminated/reserved */
[svn-r339] Changes since 19980408 ---------------------- ./src/H5Osdspace.c ./html/H5.format.html In the past we were allowed to have >2GB files on a 32-bit machine as long as no dataset within the file was larger than 4GB (or whatever sizeof(size_t) is). That's been fixed now. All dataset size calculations are done with `hsize_t' which is normally defined as `unsigned long long'. ./src/H5F.c ./src/H5Ffamily.c ./src/H5Fprivate.h ./src/H5P.c ./src/H5Ppublic.h The file family member size can now be set/queried. The default is still 64MB, but it can be set to 1GB by saying: H5Pset_family (plist, 30, H5P_DEFAULT); When opening an existing file family the specified bits-per-member is ignored and the first member of the family determines the bits-per-member, which can be retrieved with H5Pget_family(). ./acconfig.h ./configure.in ./src/H5config.h ./src/H5public.h Added `--disable-hsizet' so that those with old GCC compilers (<2.8.1) can still compile the code. ./src/H5.c ./src/H5private.h Added HDfprintf() which works just like fprintf() except you can give `H' as a size modifier for the integer conversions and supply an `hsize_t' or `hssize_t' argument without casting it. For instance: hsize_t npoints = H5Sget_npoints(space); HDfprintf(stdout,"Dataset has %Hd (%#018Hx) points\n", npoints, npoints); You can now give `%a' as a format to print an address, but all formating flags are ignored and it causes the return value of HDfprintf() to not include the characters in the address (but who uses the return value anyway :-). Example: H5G_t *grp; HDfprintf(stdout, "Group object header at %a\n", &(grp->ent.header)); Added HDstrtoll() which works exactly like [HD]strtol() except the result is an int64. ./src/debug.c Large addresses can now be entered from the command-line. Use either decimal, octal (leading `0') or hexadecimal (leading `0x') when giving the address. ./src/h5ls.c The printf format for dataset dimensions was changed to `%Hu' to support large datasets. ./test/big.c [NEW] A test for big datasets on 32-bit machines. This test is not run by default. Don't try to run it on an nfs-mounted file system or other file system that doesn't support holes because it creates two 32GB datasets of all zero.
1998-04-10 04:22:11 +08:00
/* Add in the dimension sizes */
ret_value += space->rank * H5F_SIZEOF_SIZE(f);
/* Add in the space for the maximum dimensions, if they are present */
ret_value += space->max ? (space->rank * H5F_SIZEOF_SIZE(f)) : 0;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_sdspace_size() */
/*-------------------------------------------------------------------------
* Function: H5O_sdspace_reset
*
* Purpose: Frees the inside of a dataspace message and resets it to some
* initial value.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Thursday, April 30, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_sdspace_reset(void *_mesg)
{
H5S_extent_t *mesg = (H5S_extent_t*)_mesg;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_reset)
H5S_extent_release(mesg);
FUNC_LEAVE_NOAPI(SUCCEED)
}
/*-------------------------------------------------------------------------
* Function: H5O_sdsdpace_free
*
* Purpose: Free's the message
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Thursday, March 30, 2000
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_sdspace_free(void *mesg)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_free)
HDassert(mesg);
H5FL_FREE(H5S_extent_t, mesg);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_sdspace_free() */
/*-------------------------------------------------------------------------
* Function: H5O_sdspace_pre_copy_file
*
* Purpose: Perform any necessary actions before copying message between
* files
*
* Return: Success: Non-negative
*
* Failure: Negative
*
* Programmer: Quincey Koziol
* November 30, 2006
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src,
hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info, void *_udata)
{
const H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_pre_copy_file)
/* check args */
HDassert(file_src);
HDassert(src_space_extent);
/* If the user data is non-NULL, assume we are copying a dataset
* and make a copy of the dataspace extent for later in the object copying
* process. (We currently only need to make a copy of the dataspace extent
* if the layout is an early version, but that information isn't
* available here, so we just make a copy of it in all cases)
*/
if(udata) {
/* Allocate copy of dataspace extent */
if(NULL == (udata->src_space_extent = H5FL_MALLOC(H5S_extent_t)))
HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "dataspace extent allocation failed")
/* Create a copy of the dataspace extent */
if(H5S_extent_copy(udata->src_space_extent, src_space_extent) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent")
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dspace_pre_copy_file() */
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_debug
PURPOSE
Prints debugging information for a simple dimensionality message
USAGE
void *H5O_sdspace_debug(f, mesg, stream, indent, fwidth)
H5F_t *f; IN: pointer to the HDF5 file struct
const void *mesg; IN: Pointer to the source extent dimensionality struct
FILE *stream; IN: Pointer to the stream for output data
int indent; IN: Amount to indent information by
int fwidth; IN: Field width (?)
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
This function prints debugging output to the stream passed as a
parameter.
--------------------------------------------------------------------------*/
static herr_t
H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg,
FILE * stream, int indent, int fwidth)
{
const H5S_extent_t *sdim = (const H5S_extent_t *)mesg;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_debug)
/* check args */
HDassert(f);
HDassert(sdim);
HDassert(stream);
HDassert(indent >= 0);
HDassert(fwidth >= 0);
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Rank:",
(unsigned long) (sdim->rank));
if(sdim->rank > 0) {
unsigned u; /* local counting variable */
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
for(u = 0; u < sdim->rank; u++)
HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]);
HDfprintf (stream, "}\n");
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:");
if(sdim->max) {
HDfprintf (stream, "{");
for(u = 0; u < sdim->rank; u++) {
if(H5S_UNLIMITED==sdim->max[u])
HDfprintf (stream, "%sINF", u?", ":"");
else
HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]);
} /* end for */
HDfprintf (stream, "}\n");
} /* end if */
else
HDfprintf (stream, "CONSTANT\n");
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_sdspace_debug() */
2005-11-15 10:55:39 +08:00