2003-04-01 02:30:57 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
* 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
1997-09-22 10:08:54 +08:00
|
|
|
|
/*
|
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
|
* Friday, September 19, 1997
|
|
|
|
|
*/
|
2005-09-12 22:29:54 +08:00
|
|
|
|
#define H5G_PACKAGE /*suppress error about including H5Gpkg */
|
2000-10-10 15:43:38 +08:00
|
|
|
|
#define H5F_PACKAGE /*suppress error about including H5Fpkg */
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2004-06-23 23:36:35 +08:00
|
|
|
|
|
2005-09-12 22:29:54 +08:00
|
|
|
|
/* Packages needed by this file... */
|
2003-05-16 03:22:33 +08:00
|
|
|
|
#include "H5private.h" /* Generic Functions */
|
|
|
|
|
#include "H5Eprivate.h" /* Error handling */
|
|
|
|
|
#include "H5Fpkg.h" /* File access */
|
2005-09-12 22:29:54 +08:00
|
|
|
|
#include "H5FLprivate.h" /* Free Lists */
|
2003-05-16 03:22:33 +08:00
|
|
|
|
#include "H5Gpkg.h" /* Groups */
|
|
|
|
|
#include "H5HLprivate.h" /* Local Heaps */
|
2005-11-15 10:55:39 +08:00
|
|
|
|
#include "H5Iprivate.h" /* IDs */
|
2006-07-06 03:01:50 +08:00
|
|
|
|
#include "H5MMprivate.h" /* Memory Management */
|
2005-11-15 10:55:39 +08:00
|
|
|
|
|
|
|
|
|
/* Private macros */
|
|
|
|
|
#define H5G_NO_CHANGE (-1) /*see H5G_ent_modified() */
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2003-05-16 03:22:33 +08:00
|
|
|
|
/* Private prototypes */
|
2003-06-04 23:25:23 +08:00
|
|
|
|
#ifdef NOT_YET
|
2003-05-16 03:22:33 +08:00
|
|
|
|
static herr_t H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type);
|
2003-06-04 23:25:23 +08:00
|
|
|
|
#endif /* NOT_YET */
|
2005-11-15 10:55:39 +08:00
|
|
|
|
static herr_t H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent);
|
|
|
|
|
static herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp,
|
|
|
|
|
H5G_entry_t *ent/*out*/);
|
2003-05-16 03:22:33 +08:00
|
|
|
|
|
2005-09-12 22:29:54 +08:00
|
|
|
|
/* Declare extern the PQ free list for the wrapped strings */
|
|
|
|
|
H5FL_BLK_EXTERN(str_buf);
|
|
|
|
|
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Function: H5G_ent_modified
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Purpose: This function should be called after you make any
|
|
|
|
|
* modifications to a symbol table entry cache. Supply the new
|
|
|
|
|
* type for the cache. If CACHE_TYPE is the constant
|
|
|
|
|
* H5G_NO_CHANGE then the cache type isn't changed--just the
|
|
|
|
|
* dirty bit is set.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Return: Non-negative on success/Negative on failure
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
1997-09-22 10:08:54 +08:00
|
|
|
|
* Friday, September 19, 1997
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2005-11-15 10:55:39 +08:00
|
|
|
|
herr_t
|
1998-01-17 06:23:43 +08:00
|
|
|
|
H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type)
|
1997-09-22 10:08:54 +08:00
|
|
|
|
{
|
2005-09-12 22:29:54 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_modified)
|
2002-05-29 23:07:55 +08:00
|
|
|
|
|
2005-09-12 22:29:54 +08:00
|
|
|
|
HDassert(ent);
|
2002-05-29 23:07:55 +08:00
|
|
|
|
|
2005-09-12 22:29:54 +08:00
|
|
|
|
/* Update cache type, if requested */
|
|
|
|
|
if (H5G_NO_CHANGE != cache_type)
|
2002-08-09 00:52:55 +08:00
|
|
|
|
ent->type = cache_type;
|
1998-01-17 06:23:43 +08:00
|
|
|
|
ent->dirty = TRUE;
|
2002-05-29 23:07:55 +08:00
|
|
|
|
|
2005-09-12 22:29:54 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
|
|
|
} /* end H5G_ent_modified */
|
2002-08-09 00:52:55 +08:00
|
|
|
|
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Function: H5G_ent_decode_vec
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Purpose: Same as H5G_ent_decode() except it does it for an array of
|
|
|
|
|
* symbol table entries.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Errors:
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* SYM CANTDECODE Can't decode.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Return: Success: Non-negative, with *pp pointing to the first byte
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* after the last symbol.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Failure: Negative
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* matzke@llnl.gov
|
|
|
|
|
* Jul 18 1997
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2005-09-12 22:29:54 +08:00
|
|
|
|
H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n)
|
1997-09-22 10:08:54 +08:00
|
|
|
|
{
|
2005-09-12 22:29:54 +08:00
|
|
|
|
unsigned u;
|
2002-08-09 00:52:55 +08:00
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2002-05-29 23:07:55 +08:00
|
|
|
|
FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/* check arguments */
|
|
|
|
|
assert(f);
|
|
|
|
|
assert(pp);
|
|
|
|
|
assert(ent);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/* decode entries */
|
2005-09-12 22:29:54 +08:00
|
|
|
|
for (u = 0; u < n; u++)
|
|
|
|
|
if (H5G_ent_decode(f, pp, ent + u) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode")
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2002-08-09 00:52:55 +08:00
|
|
|
|
done:
|
2003-01-11 04:26:02 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
}
|
2002-08-09 00:52:55 +08:00
|
|
|
|
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Function: H5G_ent_decode
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Purpose: Decodes a symbol table entry pointed to by `*pp'.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Errors:
|
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Return: Success: Non-negative with *pp pointing to the first byte
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* following the symbol table entry.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Failure: Negative
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* matzke@llnl.gov
|
|
|
|
|
* Jul 18 1997
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
1998-07-20 21:45:25 +08:00
|
|
|
|
* Robb Matzke, 17 Jul 1998
|
|
|
|
|
* Added a 4-byte padding field for alignment and future expansion.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2005-11-15 10:55:39 +08:00
|
|
|
|
static herr_t
|
1998-11-19 02:40:09 +08:00
|
|
|
|
H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent)
|
1997-09-22 10:08:54 +08:00
|
|
|
|
{
|
1998-11-19 02:40:09 +08:00
|
|
|
|
const uint8_t *p_ret = *pp;
|
|
|
|
|
uint32_t tmp;
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_ent_decode)
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/* check arguments */
|
2005-11-15 10:55:39 +08:00
|
|
|
|
HDassert(f);
|
|
|
|
|
HDassert(pp);
|
|
|
|
|
HDassert(ent);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
ent->file = f;
|
1998-01-08 01:14:26 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/* decode header */
|
2000-10-10 15:43:38 +08:00
|
|
|
|
H5F_DECODE_LENGTH(f, *pp, ent->name_off);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
H5F_addr_decode(f, pp, &(ent->header));
|
1998-01-29 04:24:49 +08:00
|
|
|
|
UINT32DECODE(*pp, tmp);
|
1998-07-20 21:45:25 +08:00
|
|
|
|
*pp += 4; /*reserved*/
|
1998-01-29 04:24:49 +08:00
|
|
|
|
ent->type=(H5G_type_t)tmp;
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/* decode scratch-pad */
|
|
|
|
|
switch (ent->type) {
|
2005-08-09 05:03:17 +08:00
|
|
|
|
case H5G_NOTHING_CACHED:
|
|
|
|
|
break;
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2005-08-09 05:03:17 +08:00
|
|
|
|
case H5G_CACHED_STAB:
|
|
|
|
|
assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH);
|
|
|
|
|
H5F_addr_decode(f, pp, &(ent->cache.stab.btree_addr));
|
|
|
|
|
H5F_addr_decode(f, pp, &(ent->cache.stab.heap_addr));
|
|
|
|
|
break;
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2005-08-09 05:03:17 +08:00
|
|
|
|
case H5G_CACHED_SLINK:
|
|
|
|
|
UINT32DECODE (*pp, ent->cache.slink.lval_offset);
|
|
|
|
|
break;
|
1998-04-15 00:44:46 +08:00
|
|
|
|
|
2005-08-09 05:03:17 +08:00
|
|
|
|
default:
|
|
|
|
|
HDabort();
|
1998-01-17 06:23:43 +08:00
|
|
|
|
}
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
*pp = p_ret + H5G_SIZEOF_ENTRY(f);
|
2002-08-10 04:48:23 +08:00
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
|
|
|
} /* end H5G_ent_decode() */
|
2002-08-10 04:48:23 +08:00
|
|
|
|
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Function: H5G_ent_encode_vec
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Purpose: Same as H5G_ent_encode() except it does it for an array of
|
|
|
|
|
* symbol table entries.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Errors:
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* SYM CANTENCODE Can't encode.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Return: Success: Non-negative, with *pp pointing to the first byte
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* after the last symbol.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Failure: Negative
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* matzke@llnl.gov
|
|
|
|
|
* Jul 18 1997
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2005-09-12 22:29:54 +08:00
|
|
|
|
H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n)
|
1997-09-22 10:08:54 +08:00
|
|
|
|
{
|
2005-09-12 22:29:54 +08:00
|
|
|
|
unsigned u;
|
2002-08-09 00:52:55 +08:00
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2002-05-29 23:07:55 +08:00
|
|
|
|
FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/* check arguments */
|
|
|
|
|
assert(f);
|
|
|
|
|
assert(pp);
|
|
|
|
|
assert(ent);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/* encode entries */
|
2005-09-12 22:29:54 +08:00
|
|
|
|
for (u = 0; u < n; u++)
|
|
|
|
|
if (H5G_ent_encode(f, pp, ent + u) < 0)
|
2002-08-09 00:52:55 +08:00
|
|
|
|
HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode");
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
2002-08-09 00:52:55 +08:00
|
|
|
|
done:
|
2003-01-11 04:26:02 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
}
|
2002-08-09 00:52:55 +08:00
|
|
|
|
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Function: H5G_ent_encode
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Purpose: Encodes the specified symbol table entry into the buffer
|
|
|
|
|
* pointed to by *pp.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Errors:
|
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Return: Success: Non-negative, with *pp pointing to the first byte
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* after the symbol table entry.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Failure: Negative
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* matzke@llnl.gov
|
|
|
|
|
* Jul 18 1997
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Robb Matzke, 8 Aug 1997
|
|
|
|
|
* Writes zeros for the bytes that aren't used so the file doesn't
|
|
|
|
|
* contain junk.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2005-11-15 10:55:39 +08:00
|
|
|
|
static herr_t
|
1998-11-19 02:40:09 +08:00
|
|
|
|
H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent)
|
1997-09-22 10:08:54 +08:00
|
|
|
|
{
|
1998-11-19 02:40:09 +08:00
|
|
|
|
uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_ent_encode);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
|
|
|
|
/* check arguments */
|
|
|
|
|
assert(f);
|
|
|
|
|
assert(pp);
|
|
|
|
|
|
|
|
|
|
if (ent) {
|
|
|
|
|
/* encode header */
|
2000-10-10 15:43:38 +08:00
|
|
|
|
H5F_ENCODE_LENGTH(f, *pp, ent->name_off);
|
1999-07-29 02:25:43 +08:00
|
|
|
|
H5F_addr_encode(f, pp, ent->header);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
UINT32ENCODE(*pp, ent->type);
|
1998-07-20 21:45:25 +08:00
|
|
|
|
UINT32ENCODE(*pp, 0); /*reserved*/
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
|
|
|
|
/* encode scratch-pad */
|
|
|
|
|
switch (ent->type) {
|
2002-08-09 00:52:55 +08:00
|
|
|
|
case H5G_NOTHING_CACHED:
|
|
|
|
|
break;
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
2002-08-09 00:52:55 +08:00
|
|
|
|
case H5G_CACHED_STAB:
|
|
|
|
|
assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH);
|
|
|
|
|
H5F_addr_encode(f, pp, ent->cache.stab.btree_addr);
|
|
|
|
|
H5F_addr_encode(f, pp, ent->cache.stab.heap_addr);
|
|
|
|
|
break;
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
2002-08-09 00:52:55 +08:00
|
|
|
|
case H5G_CACHED_SLINK:
|
|
|
|
|
UINT32ENCODE (*pp, ent->cache.slink.lval_offset);
|
|
|
|
|
break;
|
1998-04-15 00:44:46 +08:00
|
|
|
|
|
2002-08-09 00:52:55 +08:00
|
|
|
|
default:
|
|
|
|
|
HDabort();
|
1998-01-17 06:23:43 +08:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2000-10-10 15:43:38 +08:00
|
|
|
|
H5F_ENCODE_LENGTH(f, *pp, 0);
|
1999-08-11 04:21:32 +08:00
|
|
|
|
H5F_addr_encode(f, pp, HADDR_UNDEF);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
UINT32ENCODE(*pp, H5G_NOTHING_CACHED);
|
1998-07-20 21:45:25 +08:00
|
|
|
|
UINT32ENCODE(*pp, 0); /*reserved*/
|
1998-01-17 06:23:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fill with zero */
|
1999-07-29 02:25:43 +08:00
|
|
|
|
while (*pp < p_ret) *(*pp)++ = 0;
|
1998-01-17 06:23:43 +08:00
|
|
|
|
*pp = p_ret;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2004-06-23 23:36:35 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
}
|
2002-08-10 04:48:23 +08:00
|
|
|
|
|
2002-09-25 22:50:49 +08:00
|
|
|
|
|
2002-08-29 02:34:12 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Function: H5G_ent_copy
|
2002-08-29 02:34:12 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Purpose: Do a deep copy of symbol table entries
|
2002-08-29 02:34:12 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Return: Success: Non-negative
|
|
|
|
|
* Failure: Negative
|
2002-08-29 02:34:12 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Programmer: Pedro Vicente
|
|
|
|
|
* pvn@ncsa.uiuc.edu
|
|
|
|
|
* ???day, August ??, 2002
|
2002-08-29 02:34:12 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Notes: 'depth' parameter determines how much of the group entry
|
|
|
|
|
* structure we want to copy. The values are:
|
2005-12-26 13:28:18 +08:00
|
|
|
|
* H5_COPY_SHALLOW - Copy all the fields from the source
|
2002-10-15 04:08:23 +08:00
|
|
|
|
* to the destination, including the user path and
|
2005-08-29 13:36:16 +08:00
|
|
|
|
* canonical path. (Destination "takes ownership" of
|
|
|
|
|
* user and canonical paths)
|
2005-12-26 13:28:18 +08:00
|
|
|
|
* H5_COPY_DEEP - Copy all the fields from the source to
|
2002-10-15 04:08:23 +08:00
|
|
|
|
* the destination, deep copying the user and canonical
|
|
|
|
|
* paths.
|
2002-08-29 02:34:12 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2005-12-26 13:28:18 +08:00
|
|
|
|
H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth)
|
2002-08-29 02:34:12 +08:00
|
|
|
|
{
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_copy)
|
2002-08-29 02:34:12 +08:00
|
|
|
|
|
[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
|
|
|
|
/* Check arguments */
|
2005-11-15 10:55:39 +08:00
|
|
|
|
HDassert(src);
|
|
|
|
|
HDassert(dst);
|
2005-12-26 13:28:18 +08:00
|
|
|
|
HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
|
2002-10-15 04:08:23 +08:00
|
|
|
|
|
2002-09-25 22:50:49 +08:00
|
|
|
|
/* Copy the top level information */
|
2005-11-15 10:55:39 +08:00
|
|
|
|
HDmemcpy(dst, src, sizeof(H5G_entry_t));
|
2002-08-29 02:34:12 +08:00
|
|
|
|
|
2002-09-25 22:50:49 +08:00
|
|
|
|
/* Deep copy the names */
|
2005-12-26 13:28:18 +08:00
|
|
|
|
if(depth == H5_COPY_DEEP) {
|
2005-11-15 10:55:39 +08:00
|
|
|
|
/* Nothing currently */
|
|
|
|
|
;
|
2005-12-26 13:28:18 +08:00
|
|
|
|
} else if(depth == H5_COPY_SHALLOW) {
|
2005-07-17 10:46:42 +08:00
|
|
|
|
/* Discarding 'const' qualifier OK - QAK */
|
2005-08-29 13:36:16 +08:00
|
|
|
|
H5G_ent_reset((H5G_entry_t *)src);
|
2002-10-15 04:08:23 +08:00
|
|
|
|
} /* end if */
|
2002-08-29 02:34:12 +08:00
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
|
|
|
} /* end H5G_ent_copy() */
|
2002-08-29 02:34:12 +08:00
|
|
|
|
|
2005-08-21 03:28:40 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Function: H5G_ent_reset
|
2005-08-21 03:28:40 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Purpose: Reset a symbol table entry to an empty state
|
2005-08-21 03:28:40 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Return: Success: Non-negative
|
|
|
|
|
* Failure: Negative
|
2005-08-21 03:28:40 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* ?day, August ??, 2005
|
2005-08-21 03:28:40 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
H5G_ent_reset(H5G_entry_t *ent)
|
|
|
|
|
{
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_reset)
|
2005-08-21 03:28:40 +08:00
|
|
|
|
|
|
|
|
|
/* Check arguments */
|
|
|
|
|
HDassert(ent);
|
|
|
|
|
|
|
|
|
|
/* Clear the symbol table entry to an empty state */
|
|
|
|
|
HDmemset(ent, 0, sizeof(H5G_entry_t));
|
|
|
|
|
ent->header = HADDR_UNDEF;
|
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
2005-08-21 03:28:40 +08:00
|
|
|
|
} /* end H5G_ent_reset() */
|
|
|
|
|
|
2005-09-12 22:29:54 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Function: H5G_ent_convert
|
2005-09-12 22:29:54 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Purpose: Convert a link to a symbol table entry
|
2005-09-12 22:29:54 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Return: Success: Non-negative, with *pp pointing to the first byte
|
|
|
|
|
* after the last symbol.
|
2005-09-12 22:29:54 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Failure: Negative
|
2005-09-12 22:29:54 +08:00
|
|
|
|
*
|
2005-11-15 10:55:39 +08:00
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* Sep 20 2005
|
2005-09-12 22:29:54 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2005-11-15 10:55:39 +08:00
|
|
|
|
H5G_ent_convert(H5F_t *f, haddr_t heap_addr, const char *name, const H5O_link_t *lnk,
|
|
|
|
|
H5G_entry_t *ent, hid_t dxpl_id)
|
2005-09-12 22:29:54 +08:00
|
|
|
|
{
|
2005-11-15 10:55:39 +08:00
|
|
|
|
size_t name_offset; /* Offset of name in heap */
|
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2005-09-12 22:29:54 +08:00
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
FUNC_ENTER_NOAPI(H5G_ent_convert, FAIL)
|
2005-09-12 22:29:54 +08:00
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
/* check arguments */
|
|
|
|
|
HDassert(f);
|
|
|
|
|
HDassert(H5F_addr_defined(heap_addr));
|
|
|
|
|
HDassert(name);
|
|
|
|
|
HDassert(lnk);
|
|
|
|
|
|
|
|
|
|
/* Reset the new entry */
|
|
|
|
|
H5G_ent_reset(ent);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Add the new name to the heap.
|
|
|
|
|
*/
|
|
|
|
|
name_offset = H5HL_insert(f, dxpl_id, heap_addr, HDstrlen(name) + 1, name);
|
|
|
|
|
if(0 == name_offset || (size_t)(-1) == name_offset)
|
|
|
|
|
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap")
|
|
|
|
|
ent->name_off = name_offset;
|
|
|
|
|
|
|
|
|
|
/* Build correct information for symbol table entry based on link type */
|
|
|
|
|
switch(lnk->type) {
|
2006-07-06 03:01:50 +08:00
|
|
|
|
case H5L_LINK_HARD:
|
2005-11-15 10:55:39 +08:00
|
|
|
|
ent->type = H5G_NOTHING_CACHED;
|
|
|
|
|
ent->header = lnk->u.hard.addr;
|
|
|
|
|
break;
|
2005-09-12 22:29:54 +08:00
|
|
|
|
|
2006-07-06 03:01:50 +08:00
|
|
|
|
case H5L_LINK_SOFT:
|
2005-11-15 10:55:39 +08:00
|
|
|
|
{
|
|
|
|
|
size_t lnk_offset; /* Offset to sym-link value */
|
2005-09-12 22:29:54 +08:00
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
/* Insert link value into local heap */
|
|
|
|
|
if((size_t)(-1) == (lnk_offset = H5HL_insert(f, dxpl_id, heap_addr,
|
|
|
|
|
HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name)))
|
|
|
|
|
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap")
|
|
|
|
|
|
|
|
|
|
ent->type = H5G_CACHED_SLINK;
|
|
|
|
|
ent->cache.slink.lval_offset = lnk_offset;
|
|
|
|
|
} /* end case */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type")
|
|
|
|
|
} /* end switch */
|
|
|
|
|
|
|
|
|
|
/* Set the file for the entry */
|
|
|
|
|
ent->file = f;
|
2005-09-12 22:29:54 +08:00
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2005-11-15 10:55:39 +08:00
|
|
|
|
} /* end H5G_ent_convert() */
|
2005-09-12 22:29:54 +08:00
|
|
|
|
|
1997-09-22 10:08:54 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Function: H5G_ent_debug
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Purpose: Prints debugging information about a symbol table entry.
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-10-27 05:18:54 +08:00
|
|
|
|
* Return: Non-negative on success/Negative on failure
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* matzke@llnl.gov
|
|
|
|
|
* Aug 29 1997
|
1997-09-22 10:08:54 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2003-02-11 01:26:09 +08:00
|
|
|
|
H5G_ent_debug(H5F_t UNUSED *f, hid_t dxpl_id, const H5G_entry_t *ent, FILE * stream,
|
2001-08-15 06:09:56 +08:00
|
|
|
|
int indent, int fwidth, haddr_t heap)
|
1997-09-22 10:08:54 +08:00
|
|
|
|
{
|
1998-04-15 00:44:46 +08:00
|
|
|
|
const char *lval = NULL;
|
2003-03-22 22:53:27 +08:00
|
|
|
|
int nested_indent, nested_fwidth;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2004-06-23 23:36:35 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_debug);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
2003-03-22 22:53:27 +08:00
|
|
|
|
/* Calculate the indent & field width values for nested information */
|
|
|
|
|
nested_indent=indent+3;
|
|
|
|
|
nested_fwidth=MAX(0,fwidth-3);
|
|
|
|
|
|
1999-07-29 02:25:43 +08:00
|
|
|
|
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
|
|
|
|
|
"Name offset into private heap:",
|
|
|
|
|
(unsigned long) (ent->name_off));
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
1999-07-29 02:25:43 +08:00
|
|
|
|
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
|
|
|
|
|
"Object header address:", ent->header);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
|
1999-07-29 02:25:43 +08:00
|
|
|
|
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
|
|
|
|
|
"Dirty:",
|
|
|
|
|
ent->dirty ? "Yes" : "No");
|
|
|
|
|
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth,
|
2003-03-22 22:53:27 +08:00
|
|
|
|
"Cache info type:");
|
1998-01-17 06:23:43 +08:00
|
|
|
|
switch (ent->type) {
|
2003-03-22 22:53:27 +08:00
|
|
|
|
case H5G_NOTHING_CACHED:
|
|
|
|
|
HDfprintf(stream, "Nothing Cached\n");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case H5G_CACHED_STAB:
|
|
|
|
|
HDfprintf(stream, "Symbol Table\n");
|
|
|
|
|
|
|
|
|
|
HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth,
|
|
|
|
|
"Cached entry information:");
|
|
|
|
|
HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth,
|
|
|
|
|
"B-tree address:", ent->cache.stab.btree_addr);
|
|
|
|
|
|
|
|
|
|
HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth,
|
|
|
|
|
"Heap address:", ent->cache.stab.heap_addr);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case H5G_CACHED_SLINK:
|
|
|
|
|
HDfprintf (stream, "Symbolic Link\n");
|
2005-08-09 05:03:17 +08:00
|
|
|
|
HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth,
|
|
|
|
|
"Cached information:");
|
2003-03-22 22:53:27 +08:00
|
|
|
|
HDfprintf (stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth,
|
|
|
|
|
"Link value offset:",
|
|
|
|
|
(unsigned long)(ent->cache.slink.lval_offset));
|
2004-07-15 03:08:34 +08:00
|
|
|
|
if (heap>0 && H5F_addr_defined(heap)) {
|
2003-09-19 03:27:27 +08:00
|
|
|
|
const H5HL_t *heap_ptr;
|
|
|
|
|
|
|
|
|
|
heap_ptr = H5HL_protect(ent->file, dxpl_id, heap);
|
|
|
|
|
lval = H5HL_offset_into(ent->file, heap_ptr, ent->cache.slink.lval_offset);
|
2003-03-22 22:53:27 +08:00
|
|
|
|
HDfprintf (stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth,
|
|
|
|
|
"Link value:",
|
|
|
|
|
lval);
|
2005-07-03 00:36:15 +08:00
|
|
|
|
H5HL_unprotect(ent->file, dxpl_id, heap_ptr, heap, H5AC__NO_FLAGS_SET);
|
2003-03-22 22:53:27 +08:00
|
|
|
|
}
|
2004-07-15 03:08:34 +08:00
|
|
|
|
else
|
|
|
|
|
HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given, name not displayed!");
|
2003-03-22 22:53:27 +08:00
|
|
|
|
break;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-03-22 22:53:27 +08:00
|
|
|
|
default:
|
|
|
|
|
HDfprintf(stream, "*** Unknown symbol type %d\n", ent->type);
|
|
|
|
|
break;
|
1998-01-17 06:23:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2004-06-23 23:36:35 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED);
|
1997-09-22 10:08:54 +08:00
|
|
|
|
}
|
2005-11-15 10:55:39 +08:00
|
|
|
|
|