mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r13491] Description:
Reduce the size of the value used to store the # of bytes in the "payload" for chunk 0 of an object header. Tested on: FreeBSD/32 6.2 (duty)
This commit is contained in:
parent
753a42edf6
commit
1eb19fc895
26
src/H5O.c
26
src/H5O.c
@ -677,6 +677,8 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
|
||||
|
||||
/* Initialize version-specific fields */
|
||||
if(oh->version > H5O_VERSION_1) {
|
||||
size_t tent_oh_size; /* Tentative size of object header */
|
||||
|
||||
/* Initialize all time fields with current time, if we are storing them */
|
||||
if(oh->flags & H5O_HDR_STORE_TIMES)
|
||||
oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now();
|
||||
@ -698,6 +700,30 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
|
||||
/* Check for non-default attribute storage phase change values */
|
||||
if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF)
|
||||
oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE;
|
||||
|
||||
/* Determine correct value for chunk #0 size bits */
|
||||
|
||||
/* See if only 1 byte is enough */
|
||||
tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
|
||||
if(tent_oh_size > 255) {
|
||||
uint8_t old_oh_flags = oh->flags; /* Temporary object header flags */
|
||||
|
||||
/* Need more than 1 byte, see if 2 bytes is enough */
|
||||
oh->flags |= H5O_HDR_CHUNK0_2;
|
||||
tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
|
||||
if(tent_oh_size > 65535) {
|
||||
/* Need more than 2 bytes, see if 4 bytes is enough */
|
||||
oh->flags = old_oh_flags;
|
||||
oh->flags |= H5O_HDR_CHUNK0_4;
|
||||
tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
|
||||
if(tent_oh_size > 4294967295) {
|
||||
/* Use 8 bytes */
|
||||
/* (Should probably have check for using more than 8 bytes... :-) */
|
||||
oh->flags = old_oh_flags;
|
||||
oh->flags |= H5O_HDR_CHUNK0_8;
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
else {
|
||||
/* Reset unused time fields */
|
||||
|
@ -279,7 +279,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
|
||||
/* Flags */
|
||||
oh->flags = *p++;
|
||||
if(oh->flags & ~H5O_HDR_ALL_FLAGS)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "unknown object header status flag(s)")
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "unknown object header status flag(s)")
|
||||
|
||||
/* Number of messages (to allocate initially) */
|
||||
nmesgs = 1;
|
||||
@ -324,6 +324,28 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
|
||||
oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF;
|
||||
oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF;
|
||||
} /* end else */
|
||||
|
||||
/* First chunk size */
|
||||
switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
|
||||
case 0: /* 1 byte size */
|
||||
chunk_size = *p++;
|
||||
break;
|
||||
|
||||
case 1: /* 2 byte size */
|
||||
UINT16DECODE(p, chunk_size);
|
||||
break;
|
||||
|
||||
case 2: /* 4 byte size */
|
||||
UINT32DECODE(p, chunk_size);
|
||||
break;
|
||||
|
||||
case 3: /* 8 byte size */
|
||||
UINT64DECODE(p, chunk_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad size for chunk 0")
|
||||
} /* end switch */
|
||||
} /* end if */
|
||||
else {
|
||||
/* Reset unused time fields */
|
||||
@ -332,10 +354,10 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
|
||||
/* Reset unused attribute fields */
|
||||
oh->max_compact = 0;
|
||||
oh->min_dense = 0;
|
||||
} /* end else */
|
||||
|
||||
/* First chunk size */
|
||||
UINT32DECODE(p, chunk_size);
|
||||
/* First chunk size */
|
||||
UINT32DECODE(p, chunk_size);
|
||||
} /* end else */
|
||||
|
||||
/* Reserved, in version 1 */
|
||||
if(H5O_VERSION_1 == oh->version)
|
||||
@ -412,8 +434,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
|
||||
} /* end if */
|
||||
else {
|
||||
/* Read the chunk raw data */
|
||||
if(H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size,
|
||||
dxpl_id, oh->chunk[chunkno].image) < 0)
|
||||
if(H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id, oh->chunk[chunkno].image) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data")
|
||||
|
||||
/* Point into chunk image to decode */
|
||||
@ -649,6 +670,8 @@ H5O_assert(oh);
|
||||
* on the entire block of memory needs to be updated if anything is
|
||||
* modified */
|
||||
if(oh->version > H5O_VERSION_1) {
|
||||
uint64_t chunk0_size = oh->chunk[0].size - H5O_SIZEOF_HDR(oh); /* Size of chunk 0's data */
|
||||
|
||||
/* Verify magic number */
|
||||
HDassert(!HDmemcmp(p, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC));
|
||||
p += H5O_SIZEOF_MAGIC;
|
||||
@ -676,8 +699,27 @@ H5O_assert(oh);
|
||||
UINT16ENCODE(p, oh->min_dense);
|
||||
} /* end if */
|
||||
|
||||
/* Chunk size */
|
||||
UINT32ENCODE(p, (oh->chunk[0].size - H5O_SIZEOF_HDR(oh)));
|
||||
/* First chunk size */
|
||||
switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
|
||||
case 0: /* 1 byte size */
|
||||
*p++ = chunk0_size;
|
||||
break;
|
||||
|
||||
case 1: /* 2 byte size */
|
||||
UINT16ENCODE(p, chunk0_size);
|
||||
break;
|
||||
|
||||
case 2: /* 4 byte size */
|
||||
UINT32ENCODE(p, chunk0_size);
|
||||
break;
|
||||
|
||||
case 3: /* 8 byte size */
|
||||
UINT64ENCODE(p, chunk0_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0")
|
||||
} /* end switch */
|
||||
} /* end if */
|
||||
else {
|
||||
/* Version */
|
||||
|
11
src/H5Opkg.h
11
src/H5Opkg.h
@ -88,6 +88,12 @@
|
||||
#define H5O_CRT_ATTR_MIN_DENSE_DEF 6
|
||||
#define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES
|
||||
|
||||
/* Object header status flag definitions */
|
||||
#define H5O_HDR_CHUNK0_1 0x00
|
||||
#define H5O_HDR_CHUNK0_2 0x01
|
||||
#define H5O_HDR_CHUNK0_4 0x02
|
||||
#define H5O_HDR_CHUNK0_8 0x03
|
||||
|
||||
/*
|
||||
* Size of object header prefix.
|
||||
*/
|
||||
@ -114,7 +120,7 @@
|
||||
2 + /*max compact attributes */ \
|
||||
2 /*min dense attributes */ \
|
||||
) : 0) + \
|
||||
4 + /*chunk data size */ \
|
||||
(1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + /*chunk 0 data size */ \
|
||||
H5O_SIZEOF_CHKSUM) /*checksum size */ \
|
||||
)
|
||||
|
||||
@ -188,9 +194,6 @@
|
||||
} /* end if */ \
|
||||
} /* end if */
|
||||
|
||||
/* All the object header status flags that this version of the library knows about */
|
||||
#define H5O_HDR_ALL_FLAGS (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_ATTR_STORE_PHASE_CHANGE | H5O_HDR_STORE_TIMES)
|
||||
|
||||
|
||||
/* The "message class" type */
|
||||
struct H5O_msg_class_t {
|
||||
|
@ -61,10 +61,12 @@
|
||||
#define H5O_MESG_ALL_FLAG (H5O_MESG_SDSPACE_FLAG | H5O_MESG_DTYPE_FLAG | H5O_MESG_FILL_FLAG | H5O_MESG_PLINE_FLAG | H5O_MESG_ATTR_FLAG)
|
||||
|
||||
/* Object header status flag definitions */
|
||||
#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x01 /* Attribute creation order is tracked */
|
||||
#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x02 /* Attribute creation order has index */
|
||||
#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x04 /* Non-default attribute storage phase change values stored */
|
||||
#define H5O_HDR_STORE_TIMES 0x08 /* Store access, modification, change & birth times for object */
|
||||
#define H5O_HDR_CHUNK0_SIZE 0x03 /* 2-bit field indicating # of bytes to store the size of chunk 0's data */
|
||||
#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x04 /* Attribute creation order is tracked */
|
||||
#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x08 /* Attribute creation order has index */
|
||||
#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x10 /* Non-default attribute storage phase change values stored */
|
||||
#define H5O_HDR_STORE_TIMES 0x20 /* Store access, modification, change & birth times for object */
|
||||
#define H5O_HDR_ALL_FLAGS (H5O_HDR_CHUNK0_SIZE | H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_ATTR_STORE_PHASE_CHANGE | H5O_HDR_STORE_TIMES)
|
||||
|
||||
/* Maximum shared message values. Number of indexes is 8 to allow room to add
|
||||
* new types of messages.
|
||||
|
@ -427,9 +427,9 @@ lifecycle(hid_t fapl)
|
||||
/* Check that the object header is only one chunk and the space has been allocated correctly */
|
||||
if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR
|
||||
#ifdef H5_HAVE_LARGE_HSIZET
|
||||
if(obj_stat.ohdr.size != 190) TEST_ERROR
|
||||
if(obj_stat.ohdr.size != 187) TEST_ERROR
|
||||
#else /* H5_HAVE_LARGE_HSIZET */
|
||||
if(obj_stat.ohdr.size != 170) TEST_ERROR
|
||||
if(obj_stat.ohdr.size != 167) TEST_ERROR
|
||||
#endif /* H5_HAVE_LARGE_HSIZET */
|
||||
if(obj_stat.ohdr.free != 0) TEST_ERROR
|
||||
if(obj_stat.ohdr.nmesgs != 6) TEST_ERROR
|
||||
@ -453,9 +453,9 @@ lifecycle(hid_t fapl)
|
||||
/* Check that the object header is still one chunk and the space has been allocated correctly */
|
||||
if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR
|
||||
#ifdef H5_HAVE_LARGE_HSIZET
|
||||
if(obj_stat.ohdr.size != 190) TEST_ERROR
|
||||
if(obj_stat.ohdr.size != 187) TEST_ERROR
|
||||
#else /* H5_HAVE_LARGE_HSIZET */
|
||||
if(obj_stat.ohdr.size != 170) TEST_ERROR
|
||||
if(obj_stat.ohdr.size != 167) TEST_ERROR
|
||||
#endif /* H5_HAVE_LARGE_HSIZET */
|
||||
if(obj_stat.ohdr.free != 112) TEST_ERROR
|
||||
if(obj_stat.ohdr.nmesgs != 3) TEST_ERROR
|
||||
|
@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_latest.h5'
|
||||
#############################
|
||||
Opened "../testfiles/h5mkgrp_nested_latest.h5" with sec2 driver.
|
||||
/one Group
|
||||
Location: 1:428
|
||||
Location: 1:422
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
/one/two Group
|
||||
Location: 1:238
|
||||
Location: 1:235
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
|
@ -3,18 +3,18 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult_latest.h5'
|
||||
#############################
|
||||
Opened "../testfiles/h5mkgrp_nested_mult_latest.h5" with sec2 driver.
|
||||
/one Group
|
||||
Location: 1:428
|
||||
Location: 1:422
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
/one/two Group
|
||||
Location: 1:238
|
||||
Location: 1:235
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
/three Group
|
||||
Location: 1:808
|
||||
Location: 1:796
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
/three/four Group
|
||||
Location: 1:618
|
||||
Location: 1:609
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
|
@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_several_latest.h5'
|
||||
#############################
|
||||
Opened "../testfiles/h5mkgrp_several_latest.h5" with sec2 driver.
|
||||
/one Group
|
||||
Location: 1:238
|
||||
Location: 1:235
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
/two Group
|
||||
Location: 1:428
|
||||
Location: 1:422
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
|
@ -3,6 +3,6 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_single_latest.h5'
|
||||
#############################
|
||||
Opened "../testfiles/h5mkgrp_single_latest.h5" with sec2 driver.
|
||||
/latest Group
|
||||
Location: 1:238
|
||||
Location: 1:235
|
||||
Links: 1
|
||||
Modified: XXXX-XX-XX XX:XX:XX XXX
|
||||
|
Loading…
Reference in New Issue
Block a user