MISR Toolkit  1.5.1
H5SMpkg.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * Programmer: James Laird <jlaird@ncsa.uiuc.edu>
16  * Thursday, March 30, 2006
17  *
18  * Purpose: This file contains declarations which are visible only within
19  * the H5SM shared object header messages package. Source files
20  * outside the H5SM package should include H5SMprivate.h instead.
21  */
22 #ifndef H5SM_PACKAGE
23 #error "Do not include this file outside the H5SM package!"
24 #endif
25 
26 #ifndef _H5SMpkg_H
27 #define _H5SMpkg_H
28 
29 /* Get package's private header */
30 #include "H5SMprivate.h" /* Shared Object Header Messages */
31 
32 /* Other private headers needed by this file */
33 #include "H5ACprivate.h" /* Metadata Cache */
34 #include "H5B2private.h" /* B-trees */
35 #include "H5HFprivate.h" /* Fractal heaps */
36 
37 
38 /****************************/
39 /* Package Macros */
40 /****************************/
41 
42 /* Size of checksum information (on disk) */
43 #define H5SM_SIZEOF_CHECKSUM 4
44 
45 #define H5SM_HEAP_LOC_SIZE ( \
46  (unsigned)4 /* Reference count */ \
47  + sizeof(H5O_fheap_id_t) /* size of heap ID on disk */ \
48  )
49 
50 #define H5SM_OH_LOC_SIZE(f) ( \
51  (unsigned)1 /* reserved (possible flags?) */ \
52  + (unsigned)1 /* message type ID */ \
53  + (unsigned)2 /* creation index of message in OH */ \
54  + H5F_SIZEOF_ADDR(f) /* address of OH */ \
55  )
56 
57 #define H5SM_SOHM_ENTRY_SIZE(f) ( \
58  (unsigned)1 /* Message location */ \
59  + (unsigned)4 /* Hash value */ \
60  + MAX(H5SM_HEAP_LOC_SIZE, H5SM_OH_LOC_SIZE(f)) /* Entry */ \
61  )
62 
63 #define H5SM_INDEX_HEADER_SIZE(f) ( \
64  (unsigned)1 /* Whether index is a list or B-tree */ \
65  + (unsigned)1 /* Version of index format */ \
66  + (unsigned)2 /* Type of messages stored in the index */ \
67  + (unsigned)4 /* Minimum size of messages to share */ \
68  + (unsigned)(3 * 2) /* B-tree cutoff, list cutoff, # of shared messages */ \
69  + H5F_SIZEOF_ADDR(f) /* Location of list or B-tree */ \
70  + H5F_SIZEOF_ADDR(f) /* Address of heap */ \
71  )
72 
73 /* Format overhead for all SOHM tree metadata in the file */
74 #define H5SM_METADATA_PREFIX_SIZE ( \
75  H5_SIZEOF_MAGIC /* Signature */ \
76  + H5SM_SIZEOF_CHECKSUM /* Checksum */ \
77  )
78 
79 #define H5SM_TABLE_SIZE(f) ( \
80  /* General metadata fields */ \
81  H5SM_METADATA_PREFIX_SIZE \
82  \
83  /* Indices */ \
84  + (H5F_SOHM_NINDEXES(f) * H5SM_INDEX_HEADER_SIZE(f)) \
85  )
86 
87 #define H5SM_LIST_SIZE(f, num_mesg) ( \
88  /* General metadata fields */ \
89  H5SM_METADATA_PREFIX_SIZE \
90  \
91  /* Message entries */ \
92  + (H5SM_SOHM_ENTRY_SIZE(f) * num_mesg) \
93  )
94 
95 #define H5SM_B2_NODE_SIZE 512
96 #define H5SM_B2_SPLIT_PERCENT 100
97 #define H5SM_B2_MERGE_PERCENT 40
98 
99 #define H5SM_LIST_VERSION 0 /* Verion of Shared Object Header Message List Indexes */
100 
101 /****************************/
102 /* Package Typedefs */
103 /****************************/
104 
105 /* There are a number of Shared Object Header Message-specific structs here.
106  *
107  * The H5SM_master_table_t is pointed to by the file superblock. Since a file
108  * can have more than one SOHM index, this table collects all the indexes into
109  * one place. It holds an array of H5SM_index_header_t structs.
110  *
111  * An H5SM_index_header_t is actually the for a given index. It holds
112  * the number of messages in the index, the types of messages in the index,
113  * etc. It also records whether the index is a list or a b-tree, and has
114  * the address of the list or b-tree.
115  *
116  * If the index is a list, the address in the index header should be given
117  * to the cache, which can load it into a H5SM_list_t struct. This is mostly
118  * just a header for the cache information; it contains a pointer back to
119  * the index header and an unsorted array of messages.
120  *
121  * These messages are H5SM_sohm_t structs. They hold the actual SOHM's
122  * address, hash value, and refcount.
123  *
124  * If the index is a b-tree, the H5SM_index_header_t struct holds the address
125  * of the b-tree instead of the address of a H5SM_list_t. The B-tree's nodes
126  * are still 'H5SM_sohm_t's.
127  *
128  * H5SM_mesg_key_t structs are used to search lists and B-trees for a certain
129  * message. They correspond to a message that hasn't yet been written to
130  * disk.
131  */
132 
133 /* Where a message is stored */
134 typedef enum {
136  H5SM_IN_HEAP = 0, /* Message is stored in the heap */
137  H5SM_IN_OH /* Message is stored in an object header */
139 
140 /* Typedef for a record's location if it's stored in the heap */
141 typedef struct {
142  hsize_t ref_count; /* Number of times this message is used in the file */
143  H5O_fheap_id_t fheap_id; /* ID of the OHM in the fractal heap */
145 
146 /* Typedef for a SOHM index node */
147 typedef struct {
148  H5SM_storage_loc_t location; /* Type of message location */
149  uint32_t hash; /* Hash value for encoded OHM */
150  unsigned msg_type_id; /* Message's type ID */
151  union {
152  H5O_mesg_loc_t mesg_loc; /* Location of message in object header */
153  H5SM_heap_loc_t heap_loc; /* Heap ID for message in SOHM heap */
154  } u;
155 } H5SM_sohm_t;
156 
157 /* Types of message indices */
158 typedef enum {
160  H5SM_LIST, /* Index is an unsorted list */
161  H5SM_BTREE /* Index is a sorted B-tree */
163 
164 /* Typedef for a SOHM index header */
165 typedef struct {
166 /* Stored */
167  unsigned mesg_types; /* Bit flag vector of message types */
168  size_t min_mesg_size; /* number of messages being tracked */
169  size_t list_max; /* >= this many messages, index with a B-tree */
170  size_t btree_min; /* <= this many messages, index with a list again */
171  size_t num_messages; /* number of messages being tracked */
172  H5SM_index_type_t index_type; /* Is the index a list or a B-tree? */
173  haddr_t index_addr; /* Address of the actual index (list or B-tree) */
174  haddr_t heap_addr; /* Address of the fheap used to store shared messages */
175 
176 /* Not stored */
177  size_t list_size; /* Size of list index on disk */
179 
180 /* Typedef for a SOHM list */
181 typedef struct {
182  /* Information for H5AC cache functions, _must_ be first field in structure */
183  H5AC_info_t cache_info;
184 
185  H5SM_index_header_t *header; /* Pointer to the corresponding index header */
186  H5SM_sohm_t *messages; /* Actual list, stored as an array */
187 } H5SM_list_t;
188 
189 /* Typedef for shared object header message master table */
191  /* Information for H5AC cache functions, _must_ be first field in structure */
192  H5AC_info_t cache_info;
193 
194  size_t table_size; /* Size of table on disk */
195  unsigned num_indexes; /* Number of indexes */
196  H5SM_index_header_t *indexes; /* Array of num_indexes indexes */
197 };
198 
199 /* Typedef for searching an index (list or B-tree) */
200 typedef struct {
201  H5F_t *file; /* File in which sharing is happening */
202  hid_t dxpl_id; /* DXPL for sharing messages in heap */
203  H5HF_t *fheap; /* The heap for this message type, open. */
204  void *encoding; /* The message encoded, or NULL */
205  size_t encoding_size; /* Size of the encoding, or 0 */
206  H5SM_sohm_t message; /* The message to find/insert.
207  * If the message doesn't yet have a
208  * heap ID, the heap ID will be 0. */
210 
211 /*
212  * Data exchange structure to pass through the fractal heap layer for the
213  * H5HF_op function when computing a hash value for a message.
214  */
215 typedef struct {
216  /* downward (internal) */
217  unsigned type_id; /* Message type */
218 
219  /* upward */
220  uint32_t hash; /* Hash value */
222 
223 /* Typedef to increment a reference count in the B-tree */
224 typedef struct {
225  H5SM_mesg_key_t *key; /* IN: key for message being incremented */
226  H5O_fheap_id_t fheap_id; /* OUT: fheap ID of record */
229 
230 /* v2 B-tree client callback context */
231 typedef struct H5SM_bt2_ctx_t {
232  uint8_t sizeof_addr; /* Size of file addresses */
234 
235 /* Callback info for loading a shared message table index into the cache */
236 typedef struct H5SM_table_cache_ud_t {
237  H5F_t *f; /* File that shared message index stored as a table is in */
239 
240 /* Callback info for loading a shared message list index into the cache */
241 typedef struct H5SM_list_cache_ud_t {
242  H5F_t *f; /* File that shared message index stored as a table is in */
243  H5SM_index_header_t *header; /* Index header for this list */
245 
246 
247 /****************************/
248 /* Package Variables */
249 /****************************/
250 
251 /* Declare free lists to manage H5SM structs */
256 
257 H5_DLLVAR const H5AC_class_t H5AC_SOHM_TABLE[1];
258 H5_DLLVAR const H5AC_class_t H5AC_SOHM_LIST[1];
259 H5_DLLVAR const H5B2_class_t H5SM_INDEX[1];
260 
261 /****************************/
262 /* Package Prototypes */
263 /****************************/
264 
265 /* General routines */
266 H5_DLL ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id);
267 
268 /* Encode and decode routines, used for B-tree and cache encoding/decoding */
269 H5_DLL herr_t H5SM_message_compare(const void *rec1, const void *rec2, int *result);
270 H5_DLL herr_t H5SM_message_encode(uint8_t *raw, const void *native, void *ctx);
271 H5_DLL herr_t H5SM_message_decode(const uint8_t *raw, void *native, void *ctx);
272 
273 /* H5B2_remove_t callback to add messages to a list index */
274 H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data);
275 
276 /* Fractal heap 'op' callback to compute hash value for message "in place" */
277 H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata);
278 
279 /* Routines to release data structures */
282 
283 /* Testing functions */
284 #ifdef H5SM_TESTING
285 H5_DLL herr_t H5SM_get_mesg_count_test(H5F_t *f, hid_t dxpl_id, unsigned type_id,
286  size_t *mesg_count);
287 #endif /* H5SM_TESTING */
288 
289 #endif /* _H5SMpkg_H */
290 
H5FL_ARR_EXTERN(H5SM_index_header_t)
struct H5SM_bt2_ctx_t H5SM_bt2_ctx_t
size_t min_mesg_size
Definition: H5SMpkg.h:168
herr_t H5SM_list_free(H5SM_list_t *list)
long long ssize_t
Definition: H5public.h:156
#define H5_DLL
Definition: H5api_adpt.h:256
H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void *record, void *op_data)
int herr_t
Definition: H5public.h:124
unsigned type_id
Definition: H5SMpkg.h:217
H5SM_index_header_t * header
Definition: H5SMpkg.h:243
H5SM_index_type_t index_type
Definition: H5SMpkg.h:172
unsigned long long hsize_t
Definition: H5public.h:169
H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata)
struct H5SM_table_cache_ud_t H5SM_table_cache_ud_t
H5_DLLVAR const H5B2_class_t H5SM_INDEX[1]
Definition: H5SMpkg.h:259
H5AC_info_t cache_info
Definition: H5SMpkg.h:183
H5SM_mesg_key_t * key
Definition: H5SMpkg.h:225
uint8_t sizeof_addr
Definition: H5SMpkg.h:232
uint64_t haddr_t
Definition: H5public.h:182
H5O_fheap_id_t fheap_id
Definition: H5SMpkg.h:143
H5SM_storage_loc_t
Definition: H5SMpkg.h:134
H5FL_EXTERN(H5SM_master_table_t)
H5AC_info_t cache_info
Definition: H5SMpkg.h:192
H5_DLL ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id)
H5SM_storage_loc_t location
Definition: H5SMpkg.h:148
hsize_t ref_count
Definition: H5SMpkg.h:142
H5O_mesg_loc_t mesg_loc
Definition: H5SMpkg.h:152
haddr_t heap_addr
Definition: H5SMpkg.h:174
size_t encoding_size
Definition: H5SMpkg.h:205
int hid_t
Definition: H5Ipublic.h:54
unsigned num_indexes
Definition: H5SMpkg.h:195
H5_DLL herr_t H5SM_message_compare(const void *rec1, const void *rec2, int *result)
H5HF_t * fheap
Definition: H5SMpkg.h:203
H5F_t * file
Definition: H5SMpkg.h:201
uint32_t hash
Definition: H5SMpkg.h:220
haddr_t index_addr
Definition: H5SMpkg.h:173
H5SM_sohm_t message
Definition: H5SMpkg.h:206
H5_DLLVAR const H5AC_class_t H5AC_SOHM_TABLE[1]
Definition: H5SMpkg.h:257
void * encoding
Definition: H5SMpkg.h:204
H5SM_index_header_t * header
Definition: H5SMpkg.h:185
H5_DLLVAR const H5AC_class_t H5AC_SOHM_LIST[1]
Definition: H5SMpkg.h:258
H5SM_index_type_t
Definition: H5SMpkg.h:158
H5SM_index_header_t * indexes
Definition: H5SMpkg.h:196
herr_t H5SM_table_free(H5SM_master_table_t *table)
size_t num_messages
Definition: H5SMpkg.h:171
#define H5_DLLVAR
Definition: H5api_adpt.h:257
unsigned mesg_types
Definition: H5SMpkg.h:167
hid_t dxpl_id
Definition: H5SMpkg.h:202
unsigned msg_type_id
Definition: H5SMpkg.h:150
H5_DLL herr_t H5SM_message_encode(uint8_t *raw, const void *native, void *ctx)
H5SM_heap_loc_t heap_loc
Definition: H5SMpkg.h:153
struct H5SM_list_cache_ud_t H5SM_list_cache_ud_t
H5O_fheap_id_t fheap_id
Definition: H5SMpkg.h:226
H5_DLL herr_t H5SM_message_decode(const uint8_t *raw, void *native, void *ctx)
uint32_t hash
Definition: H5SMpkg.h:149
H5SM_sohm_t * messages
Definition: H5SMpkg.h:186
Definition: H5Fpkg.h:255

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:53