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 files COPYING and Copyright.html. COPYING can be found at the root *
9 * of the source code distribution tree; Copyright.html can be found at the *
10 * root level of an installed copy of the electronic HDF5 document set and *
11 * is linked from the top-level documents page. It can also be found at *
12 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
13 * access to either file, you may request a copy from help@hdfgroup.org. *
14 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16 /*-------------------------------------------------------------------------
17 *
18 * Created: H5Pgcpl.c
19 * August 29 2006
20 * Quincey Koziol <koziol@ncsa.uiuc.edu>
21 *
22 * Purpose: Group creation property list class routines
23 *
24 *-------------------------------------------------------------------------
25 */
26
27 /****************/
28 /* Module Setup */
29 /****************/
30 #define H5P_PACKAGE /*suppress error about including H5Ppkg */
31
32 /***********/
33 /* Headers */
34 /***********/
35 #include "H5private.h" /* Generic Functions */
36 #include "H5Eprivate.h" /* Error handling */
37 #include "H5Iprivate.h" /* IDs */
38 #include "H5Ppkg.h" /* Property lists */
39
40
41 /****************/
42 /* Local Macros */
43 /****************/
44
45
46 /******************/
47 /* Local Typedefs */
48 /******************/
49
50
51 /********************/
52 /* Package Typedefs */
53 /********************/
54
55
56 /********************/
57 /* Local Prototypes */
58 /********************/
59
60 /* Property class callbacks */
61 static herr_t H5P__gcrt_reg_prop(H5P_genclass_t *pclass);
62
63
64 /*********************/
65 /* Package Variables */
66 /*********************/
67
68 /* Group creation property list class library initialization object */
69 const H5P_libclass_t H5P_CLS_GCRT[1] = {{
70 "group create", /* Class name for debugging */
71 H5P_TYPE_GROUP_CREATE, /* Class type */
72 &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */
73 &H5P_CLS_GROUP_CREATE_g, /* Pointer to class ID */
74 &H5P_LST_GROUP_CREATE_g, /* Pointer to default property list ID */
75 H5P__gcrt_reg_prop, /* Default property registration routine */
76 NULL, /* Class creation callback */
77 NULL, /* Class creation callback info */
78 NULL, /* Class copy callback */
79 NULL, /* Class copy callback info */
80 NULL, /* Class close callback */
81 NULL /* Class close callback info */
82 }};
83
84
85 /*****************************/
86 /* Library Private Variables */
87 /*****************************/
88
89
90 /*******************/
91 /* Local Variables */
92 /*******************/
93
94
95
96 /*-------------------------------------------------------------------------
97 * Function: H5P__gcrt_reg_prop
98 *
99 * Purpose: Initialize the group creation property list class
100 *
101 * Return: Non-negative on success/Negative on failure
102 *
103 * Programmer: Quincey Koziol
104 * October 31, 2006
105 *-------------------------------------------------------------------------
106 */
107 static herr_t
H5P__gcrt_reg_prop(H5P_genclass_t * pclass)108 H5P__gcrt_reg_prop(H5P_genclass_t *pclass)
109 {
110 H5O_ginfo_t ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */
111 H5O_linfo_t linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */
112 herr_t ret_value = SUCCEED; /* Return value */
113
114 FUNC_ENTER_STATIC
115
116 /* Register group info property */
117 if(H5P_register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &ginfo, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
118 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
119
120 /* Register link info property */
121 if(H5P_register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &linfo, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
122 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
123
124 done:
125 FUNC_LEAVE_NOAPI(ret_value)
126 } /* end H5P__gcrt_reg_prop() */
127
128
129 /*-------------------------------------------------------------------------
130 * Function: H5Pset_local_heap_size_hint
131 *
132 * Purpose: Set the "size hint" for creating local heaps for a group.
133 *
134 * Return: Non-negative on success/Negative on failure
135 *
136 * Programmer: Quincey Koziol
137 * August 29, 2005
138 *-------------------------------------------------------------------------
139 */
140 herr_t
H5Pset_local_heap_size_hint(hid_t plist_id,size_t size_hint)141 H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint)
142 {
143 H5P_genplist_t *plist; /* Property list pointer */
144 H5O_ginfo_t ginfo; /* Group information structure */
145 herr_t ret_value = SUCCEED; /* Return value */
146
147 FUNC_ENTER_API(FAIL)
148 H5TRACE2("e", "iz", plist_id, size_hint);
149
150 /* Get the plist structure */
151 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
152 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
153
154 /* Get value */
155 if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
156 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
157
158 /* Update field */
159 H5_ASSIGN_OVERFLOW(ginfo.lheap_size_hint, size_hint, size_t, uint32_t);
160
161 /* Set value */
162 if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
163 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
164
165 done:
166 FUNC_LEAVE_API(ret_value)
167 } /* end H5Pset_local_heap_size_hint() */
168
169
170 /*-------------------------------------------------------------------------
171 * Function: H5Pget_local_heap_size_hint
172 *
173 * Purpose: Returns the local heap size hint, which is used for creating
174 * groups
175 *
176 * Return: Non-negative on success/Negative on failure
177 *
178 * Programmer: Quincey Koziol
179 * August 29, 2005
180 *-------------------------------------------------------------------------
181 */
182 herr_t
H5Pget_local_heap_size_hint(hid_t plist_id,size_t * size_hint)183 H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/)
184 {
185 herr_t ret_value = SUCCEED; /* return value */
186
187 FUNC_ENTER_API(FAIL)
188 H5TRACE2("e", "ix", plist_id, size_hint);
189
190 if(size_hint) {
191 H5P_genplist_t *plist; /* Property list pointer */
192 H5O_ginfo_t ginfo; /* Group information structure */
193
194 /* Get the plist structure */
195 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
196 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
197
198 /* Get value */
199 if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
200 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
201
202 /* Update field */
203 *size_hint = ginfo.lheap_size_hint;
204 } /* end if */
205
206 done:
207 FUNC_LEAVE_API(ret_value)
208 } /* end H5Pget_local_heap_size_hint() */
209
210
211 /*-------------------------------------------------------------------------
212 * Function: H5Pset_link_phase_change
213 *
214 * Purpose: Set the maximum # of links to store "compactly" and the
215 * minimum # of links to store "densely". (These should
216 * overlap).
217 *
218 * Note: Currently both of these must be updated at the same time.
219 *
220 * Note: Come up with better name & description! -QAK
221 *
222 * Return: Non-negative on success/Negative on failure
223 *
224 * Programmer: Quincey Koziol
225 * August 29, 2005
226 *-------------------------------------------------------------------------
227 */
228 herr_t
H5Pset_link_phase_change(hid_t plist_id,unsigned max_compact,unsigned min_dense)229 H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense)
230 {
231 H5P_genplist_t *plist; /* Property list pointer */
232 H5O_ginfo_t ginfo; /* Group information structure */
233 herr_t ret_value = SUCCEED; /* Return value */
234
235 FUNC_ENTER_API(FAIL)
236 H5TRACE3("e", "iIuIu", plist_id, max_compact, min_dense);
237
238 /* Range check values */
239 if(max_compact < min_dense)
240 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be >= min dense value")
241 if(max_compact > 65535)
242 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be < 65536")
243 if(min_dense > 65535)
244 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min dense value must be < 65536")
245
246 /* Get the plist structure */
247 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
248 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
249
250 /* Get group info */
251 if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
252 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
253
254 /* Update fields */
255 if(max_compact != H5G_CRT_GINFO_MAX_COMPACT || min_dense != H5G_CRT_GINFO_MIN_DENSE)
256 ginfo.store_link_phase_change = TRUE;
257 else
258 ginfo.store_link_phase_change = FALSE;
259 ginfo.max_compact = (uint16_t)max_compact;
260 ginfo.min_dense = (uint16_t)min_dense;
261
262 /* Set group info */
263 if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
264 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
265
266 done:
267 FUNC_LEAVE_API(ret_value)
268 } /* end H5Pset_link_phase_change() */
269
270
271 /*-------------------------------------------------------------------------
272 * Function: H5Pget_link_phase_change
273 *
274 * Purpose: Returns the max. # of compact links & the min. # of dense
275 * links, which are used for storing groups
276 *
277 * Return: Non-negative on success/Negative on failure
278 *
279 * Programmer: Quincey Koziol
280 * August 29, 2005
281 *-------------------------------------------------------------------------
282 */
283 herr_t
H5Pget_link_phase_change(hid_t plist_id,unsigned * max_compact,unsigned * min_dense)284 H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned *min_dense /*out*/)
285 {
286 herr_t ret_value = SUCCEED; /* return value */
287
288 FUNC_ENTER_API(FAIL)
289 H5TRACE3("e", "ixx", plist_id, max_compact, min_dense);
290
291 /* Get values */
292 if(max_compact || min_dense) {
293 H5P_genplist_t *plist; /* Property list pointer */
294 H5O_ginfo_t ginfo; /* Group information structure */
295
296 /* Get the plist structure */
297 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
298 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
299
300 /* Get group info */
301 if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
302 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
303
304 if(max_compact)
305 *max_compact = ginfo.max_compact;
306 if(min_dense)
307 *min_dense = ginfo.min_dense;
308 } /* end if */
309
310 done:
311 FUNC_LEAVE_API(ret_value)
312 } /* end H5Pget_link_phase_change() */
313
314
315 /*-------------------------------------------------------------------------
316 * Function: H5Pset_est_link_info
317 *
318 * Purpose: Set the estimates for the number of entries and length of each
319 * entry name in a group.
320 *
321 * Note: Currently both of these must be updated at the same time.
322 *
323 * Note: EST_NUM_ENTRIES applies only when the number of entries is less
324 * than the MAX_COMPACT # of entries (from H5Pset_link_phase_change).
325 *
326 * Note: Come up with better name & description? -QAK
327 *
328 * Return: Non-negative on success/Negative on failure
329 *
330 * Programmer: Quincey Koziol
331 * September 6, 2005
332 *-------------------------------------------------------------------------
333 */
334 herr_t
H5Pset_est_link_info(hid_t plist_id,unsigned est_num_entries,unsigned est_name_len)335 H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name_len)
336 {
337 H5P_genplist_t *plist; /* Property list pointer */
338 H5O_ginfo_t ginfo; /* Group information structure */
339 herr_t ret_value = SUCCEED; /* Return value */
340
341 FUNC_ENTER_API(FAIL)
342 H5TRACE3("e", "iIuIu", plist_id, est_num_entries, est_name_len);
343
344 /* Range check values */
345 if(est_num_entries > 65535)
346 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. number of entries must be < 65536")
347 if(est_name_len > 65535)
348 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. name length must be < 65536")
349
350 /* Get the plist structure */
351 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
352 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
353
354 /* Get group info */
355 if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
356 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
357
358 /* Update fields */
359 if(est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || est_name_len != H5G_CRT_GINFO_EST_NAME_LEN)
360 ginfo.store_est_entry_info = TRUE;
361 else
362 ginfo.store_est_entry_info = FALSE;
363 ginfo.est_num_entries = (uint16_t)est_num_entries;
364 ginfo.est_name_len = (uint16_t)est_name_len;
365
366 /* Set group info */
367 if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
368 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
369
370 done:
371 FUNC_LEAVE_API(ret_value)
372 } /* end H5Pset_est_link_info() */
373
374
375 /*-------------------------------------------------------------------------
376 * Function: H5Pget_est_link_info
377 *
378 * Purpose: Returns the est. # of links in a group & the est. length of
379 * the name of each link.
380 *
381 * Return: Non-negative on success/Negative on failure
382 *
383 * Programmer: Quincey Koziol
384 * September 6, 2005
385 *-------------------------------------------------------------------------
386 */
387 herr_t
H5Pget_est_link_info(hid_t plist_id,unsigned * est_num_entries,unsigned * est_name_len)388 H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /*out*/, unsigned *est_name_len /*out*/)
389 {
390 herr_t ret_value = SUCCEED; /* return value */
391
392 FUNC_ENTER_API(FAIL)
393 H5TRACE3("e", "ixx", plist_id, est_num_entries, est_name_len);
394
395 /* Get values */
396 if(est_num_entries || est_name_len) {
397 H5P_genplist_t *plist; /* Property list pointer */
398 H5O_ginfo_t ginfo; /* Group information structure */
399
400 /* Get the plist structure */
401 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
402 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
403
404 /* Get group info */
405 if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
406 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
407
408 if(est_num_entries)
409 *est_num_entries = ginfo.est_num_entries;
410 if(est_name_len)
411 *est_name_len = ginfo.est_name_len;
412 } /* end if */
413
414 done:
415 FUNC_LEAVE_API(ret_value)
416 } /* end H5Pget_est_link_info() */
417
418
419 /*-------------------------------------------------------------------------
420 * Function: H5Pset_link_creation_order
421 *
422 * Purpose: Set the flags for creation order of links in a group
423 *
424 * Return: Non-negative on success/Negative on failure
425 *
426 * Programmer: Quincey Koziol
427 * September 12, 2006
428 *-------------------------------------------------------------------------
429 */
430 herr_t
H5Pset_link_creation_order(hid_t plist_id,unsigned crt_order_flags)431 H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags)
432 {
433 H5P_genplist_t *plist; /* Property list pointer */
434 H5O_linfo_t linfo; /* Link information structure */
435 herr_t ret_value = SUCCEED; /* Return value */
436
437 FUNC_ENTER_API(FAIL)
438 H5TRACE2("e", "iIu", plist_id, crt_order_flags);
439
440 /* Check for bad combination of flags */
441 if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED))
442 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index")
443
444 /* Get the plist structure */
445 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
446 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
447
448 /* Get link info */
449 if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
450 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info")
451
452 /* Update fields */
453 linfo.track_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE);
454 linfo.index_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE);
455
456 /* Set link info */
457 if(H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
458 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info")
459
460 done:
461 FUNC_LEAVE_API(ret_value)
462 } /* end H5Pset_link_creation_order() */
463
464
465 /*-------------------------------------------------------------------------
466 * Function: H5Pget_link_creation_order
467 *
468 * Purpose: Returns the flag indicating that creation order is tracked
469 * for links in a group.
470 *
471 * Return: Non-negative on success/Negative on failure
472 *
473 * Programmer: Quincey Koziol
474 * September 12, 2006
475 *-------------------------------------------------------------------------
476 */
477 herr_t
H5Pget_link_creation_order(hid_t plist_id,unsigned * crt_order_flags)478 H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /*out*/)
479 {
480 herr_t ret_value = SUCCEED; /* return value */
481
482 FUNC_ENTER_API(FAIL)
483 H5TRACE2("e", "ix", plist_id, crt_order_flags);
484
485 /* Get values */
486 if(crt_order_flags) {
487 H5P_genplist_t *plist; /* Property list pointer */
488 H5O_linfo_t linfo; /* Link information structure */
489
490 /* Reset the value to return */
491 *crt_order_flags = 0;
492
493 /* Get the plist structure */
494 if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
495 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
496
497 /* Get link info */
498 if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
499 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info")
500
501 *crt_order_flags |= linfo.track_corder ? H5P_CRT_ORDER_TRACKED : 0;
502 *crt_order_flags |= linfo.index_corder ? H5P_CRT_ORDER_INDEXED : 0;
503 } /* end if */
504
505 done:
506 FUNC_LEAVE_API(ret_value)
507 } /* end H5Pget_link_creation_order() */
508
509