/src/hdf5/src/H5Dsingle.c
Line | Count | Source |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the LICENSE file, which can be found at the root of the source code * |
8 | | * distribution tree, or in https://www.hdfgroup.org/licenses. * |
9 | | * If you do not have access to either file, you may request a copy from * |
10 | | * help@hdfgroup.org. * |
11 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | | |
13 | | /* |
14 | | * Purpose: Single Chunk I/O functions. |
15 | | * This is used when the dataset has only 1 chunk (with or without filter): |
16 | | * cur_dims[] is equal to max_dims[] is equal to the chunk dims[] |
17 | | * non-filter chunk record: [address of the chunk] |
18 | | * filtered chunk record: [address of the chunk, chunk size, filter mask] |
19 | | */ |
20 | | |
21 | | /****************/ |
22 | | /* Module Setup */ |
23 | | /****************/ |
24 | | |
25 | | #include "H5Dmodule.h" /* This source code file is part of the H5D module */ |
26 | | |
27 | | /***********/ |
28 | | /* Headers */ |
29 | | /***********/ |
30 | | #include "H5private.h" /* Generic Functions */ |
31 | | #include "H5Dpkg.h" /* Datasets */ |
32 | | #include "H5Eprivate.h" /* Error handling */ |
33 | | #include "H5MFprivate.h" /* File space management */ |
34 | | |
35 | | /****************/ |
36 | | /* Local Macros */ |
37 | | /****************/ |
38 | | |
39 | | /******************/ |
40 | | /* Local Typedefs */ |
41 | | /******************/ |
42 | | |
43 | | /********************/ |
44 | | /* Local Prototypes */ |
45 | | /********************/ |
46 | | |
47 | | /* Single Chunk Index chunking I/O ops */ |
48 | | static herr_t H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, |
49 | | haddr_t dset_ohdr_addr); |
50 | | static herr_t H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info); |
51 | | static herr_t H5D__single_idx_open(const H5D_chk_idx_info_t *idx_info); |
52 | | static herr_t H5D__single_idx_close(const H5D_chk_idx_info_t *idx_info); |
53 | | static herr_t H5D__single_idx_is_open(const H5D_chk_idx_info_t *idx_info, bool *is_open); |
54 | | static bool H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage); |
55 | | static herr_t H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, |
56 | | const H5D_t *dset); |
57 | | static herr_t H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); |
58 | | static herr_t H5D__single_idx_load_metadata(const H5D_chk_idx_info_t *idx_info); |
59 | | static int H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, |
60 | | void *chunk_udata); |
61 | | static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); |
62 | | static herr_t H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info); |
63 | | static herr_t H5D__single_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, |
64 | | const H5D_chk_idx_info_t *idx_info_dst); |
65 | | static herr_t H5D__single_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); |
66 | | static herr_t H5D__single_idx_reset(H5O_storage_chunk_t *storage, bool reset_addr); |
67 | | static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); |
68 | | |
69 | | /*********************/ |
70 | | /* Package Variables */ |
71 | | /*********************/ |
72 | | |
73 | | /* Non Index chunk I/O ops */ |
74 | | const H5D_chunk_ops_t H5D_COPS_SINGLE[1] = {{ |
75 | | false, /* Single Chunk indexing doesn't current support SWMR access */ |
76 | | H5D__single_idx_init, /* init */ |
77 | | H5D__single_idx_create, /* create */ |
78 | | H5D__single_idx_open, /* open */ |
79 | | H5D__single_idx_close, /* close */ |
80 | | H5D__single_idx_is_open, /* is_open */ |
81 | | H5D__single_idx_is_space_alloc, /* is_space_alloc */ |
82 | | H5D__single_idx_insert, /* insert */ |
83 | | H5D__single_idx_get_addr, /* get_addr */ |
84 | | H5D__single_idx_load_metadata, /* load_metadata */ |
85 | | NULL, /* resize */ |
86 | | H5D__single_idx_iterate, /* iterate */ |
87 | | H5D__single_idx_remove, /* remove */ |
88 | | H5D__single_idx_delete, /* delete */ |
89 | | H5D__single_idx_copy_setup, /* copy_setup */ |
90 | | NULL, /* copy_shutdown */ |
91 | | H5D__single_idx_size, /* size */ |
92 | | H5D__single_idx_reset, /* reset */ |
93 | | H5D__single_idx_dump, /* dump */ |
94 | | NULL /* destroy */ |
95 | | }}; |
96 | | |
97 | | /*****************************/ |
98 | | /* Library Private Variables */ |
99 | | /*****************************/ |
100 | | |
101 | | /*******************/ |
102 | | /* Local Variables */ |
103 | | /*******************/ |
104 | | |
105 | | /*------------------------------------------------------------------------- |
106 | | * Function: H5D__single_idx_init |
107 | | * |
108 | | * Purpose: Initialize the indexing information for a dataset. |
109 | | * |
110 | | * Return: Non-negative on success/Negative on failure |
111 | | * |
112 | | *------------------------------------------------------------------------- |
113 | | */ |
114 | | static herr_t |
115 | | H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, |
116 | | haddr_t H5_ATTR_UNUSED dset_ohdr_addr) |
117 | 1 | { |
118 | 1 | FUNC_ENTER_PACKAGE_NOERR |
119 | | |
120 | | /* Check args */ |
121 | 1 | assert(idx_info); |
122 | 1 | assert(idx_info->f); |
123 | 1 | assert(idx_info->pline); |
124 | 1 | assert(idx_info->layout); |
125 | | |
126 | 1 | if (idx_info->pline->nused) { |
127 | 0 | idx_info->layout->u.chunk.flags |= H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER; |
128 | |
|
129 | 0 | if (!H5_addr_defined(idx_info->layout->storage.u.chunk.idx_addr)) { |
130 | 0 | idx_info->layout->storage.u.chunk.u.single.nbytes = 0; |
131 | 0 | idx_info->layout->storage.u.chunk.u.single.filter_mask = 0; |
132 | 0 | } |
133 | 0 | } |
134 | 1 | else |
135 | 1 | idx_info->layout->u.chunk.flags = 0; |
136 | | |
137 | 1 | FUNC_LEAVE_NOAPI(SUCCEED) |
138 | 1 | } /* end H5D__single_idx_init() */ |
139 | | |
140 | | /*------------------------------------------------------------------------- |
141 | | * Function: H5D__single_idx_create |
142 | | * |
143 | | * Purpose: Set up Single Chunk Index: filtered or non-filtered |
144 | | * |
145 | | * Return: Non-negative on success |
146 | | * Negative on failure. |
147 | | * |
148 | | *------------------------------------------------------------------------- |
149 | | */ |
150 | | static herr_t |
151 | | H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info) |
152 | 0 | { |
153 | 0 | FUNC_ENTER_PACKAGE_NOERR |
154 | | |
155 | | /* Check args */ |
156 | 0 | assert(idx_info); |
157 | 0 | assert(idx_info->f); |
158 | 0 | assert(idx_info->pline); |
159 | 0 | assert(idx_info->layout); |
160 | 0 | assert(idx_info->layout->u.chunk.max_nchunks == idx_info->layout->u.chunk.nchunks); |
161 | 0 | assert(idx_info->layout->u.chunk.nchunks == 1); |
162 | 0 | assert(!H5_addr_defined(idx_info->layout->storage.u.chunk.idx_addr)); |
163 | |
|
164 | 0 | if (idx_info->pline->nused) |
165 | 0 | assert(idx_info->layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER); |
166 | 0 | else |
167 | 0 | assert(!(idx_info->layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER)); |
168 | |
|
169 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
170 | 0 | } /* end H5D__single_idx_create() */ |
171 | | |
172 | | /*------------------------------------------------------------------------- |
173 | | * Function: H5D__single_idx_open |
174 | | * |
175 | | * Purpose: Opens an existing "single" index. Currently a no-op. |
176 | | * |
177 | | * Return: SUCCEED (can't fail) |
178 | | * |
179 | | *------------------------------------------------------------------------- |
180 | | */ |
181 | | static herr_t |
182 | | H5D__single_idx_open(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info) |
183 | 0 | { |
184 | 0 | FUNC_ENTER_PACKAGE_NOERR |
185 | | |
186 | | /* NO OP */ |
187 | |
|
188 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
189 | 0 | } /* end H5D__single_idx_open() */ |
190 | | |
191 | | /*------------------------------------------------------------------------- |
192 | | * Function: H5D__single_idx_close |
193 | | * |
194 | | * Purpose: Closes an existing "single" index. Currently a no-op. |
195 | | * |
196 | | * Return: SUCCEED (can't fail) |
197 | | * |
198 | | *------------------------------------------------------------------------- |
199 | | */ |
200 | | static herr_t |
201 | | H5D__single_idx_close(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info) |
202 | 0 | { |
203 | 0 | FUNC_ENTER_PACKAGE_NOERR |
204 | | |
205 | | /* NO OP */ |
206 | |
|
207 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
208 | 0 | } /* end H5D__single_idx_close() */ |
209 | | |
210 | | /*------------------------------------------------------------------------- |
211 | | * Function: H5D__single_idx_is_open |
212 | | * |
213 | | * Purpose: Query if the index is opened or not |
214 | | * |
215 | | * Return: SUCCEED (can't fail) |
216 | | * |
217 | | *------------------------------------------------------------------------- |
218 | | */ |
219 | | static herr_t |
220 | | H5D__single_idx_is_open(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info, bool *is_open) |
221 | 0 | { |
222 | 0 | FUNC_ENTER_PACKAGE_NOERR |
223 | |
|
224 | 0 | assert(idx_info); |
225 | 0 | assert(idx_info->layout); |
226 | 0 | assert(H5D_CHUNK_IDX_SINGLE == idx_info->layout->storage.u.chunk.idx_type); |
227 | 0 | assert(is_open); |
228 | |
|
229 | 0 | *is_open = true; |
230 | |
|
231 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
232 | 0 | } /* end H5D__single_idx_is_open() */ |
233 | | |
234 | | /*------------------------------------------------------------------------- |
235 | | * Function: H5D__single_idx_is_space_alloc |
236 | | * |
237 | | * Purpose: Query if space is allocated for the single chunk |
238 | | * |
239 | | * Return: Non-negative on success/Negative on failure |
240 | | * |
241 | | *------------------------------------------------------------------------- |
242 | | */ |
243 | | static bool |
244 | | H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage) |
245 | 0 | { |
246 | 0 | FUNC_ENTER_PACKAGE_NOERR |
247 | | |
248 | | /* Check args */ |
249 | 0 | assert(storage); |
250 | |
|
251 | 0 | FUNC_LEAVE_NOAPI((bool)H5_addr_defined(storage->idx_addr)) |
252 | 0 | } /* end H5D__single_idx_is_space_alloc() */ |
253 | | |
254 | | /*------------------------------------------------------------------------- |
255 | | * Function: H5D__single_idx_insert |
256 | | * |
257 | | * Purpose: Allocate space for the single chunk |
258 | | * |
259 | | * Return: Non-negative on success/Negative on failure |
260 | | * |
261 | | *------------------------------------------------------------------------- |
262 | | */ |
263 | | static herr_t |
264 | | H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, const H5D_t *dset) |
265 | 0 | { |
266 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
267 | |
|
268 | 0 | FUNC_ENTER_PACKAGE |
269 | | |
270 | | /* Sanity checks */ |
271 | 0 | assert(idx_info); |
272 | 0 | assert(idx_info->f); |
273 | 0 | assert(idx_info->pline); |
274 | 0 | assert(idx_info->layout); |
275 | 0 | assert(idx_info->layout->u.chunk.nchunks == 1); |
276 | 0 | assert(idx_info->layout->u.chunk.max_nchunks == 1); |
277 | 0 | assert(udata); |
278 | | |
279 | | /* Set the address for the chunk */ |
280 | 0 | assert(H5_addr_defined(udata->chunk_block.offset)); |
281 | 0 | idx_info->layout->storage.u.chunk.idx_addr = udata->chunk_block.offset; |
282 | |
|
283 | 0 | if (idx_info->pline->nused > 0) { |
284 | 0 | idx_info->layout->storage.u.chunk.u.single.nbytes = udata->chunk_block.length; |
285 | 0 | idx_info->layout->storage.u.chunk.u.single.filter_mask = udata->filter_mask; |
286 | 0 | } /* end if */ |
287 | |
|
288 | 0 | if (dset) |
289 | 0 | if (dset->shared->dcpl_cache.fill.alloc_time != H5D_ALLOC_TIME_EARLY || idx_info->pline->nused > 0) |
290 | | /* Mark the layout dirty so that the address of the single chunk will be flushed later */ |
291 | 0 | if (H5D__mark(dset, H5D_MARK_LAYOUT) < 0) |
292 | 0 | HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark layout as dirty"); |
293 | | |
294 | 0 | done: |
295 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
296 | 0 | } /* H5D__single_idx_insert() */ |
297 | | |
298 | | /*------------------------------------------------------------------------- |
299 | | * Function: H5D__single_idx_get_addr |
300 | | * |
301 | | * Purpose: Get the file address of a chunk. |
302 | | * Save the retrieved information in the udata supplied. |
303 | | * |
304 | | * Return: Non-negative on success/Negative on failure |
305 | | * |
306 | | *------------------------------------------------------------------------- |
307 | | */ |
308 | | static herr_t |
309 | | H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) |
310 | 0 | { |
311 | 0 | FUNC_ENTER_PACKAGE_NOERR |
312 | | |
313 | | /* Sanity checks */ |
314 | 0 | assert(idx_info); |
315 | 0 | assert(idx_info->f); |
316 | 0 | assert(idx_info->pline); |
317 | 0 | assert(idx_info->layout); |
318 | 0 | assert(idx_info->layout->u.chunk.nchunks == 1); |
319 | 0 | assert(idx_info->layout->u.chunk.max_nchunks == 1); |
320 | 0 | assert(udata); |
321 | |
|
322 | 0 | udata->chunk_block.offset = idx_info->layout->storage.u.chunk.idx_addr; |
323 | 0 | if (idx_info->layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { |
324 | 0 | udata->chunk_block.length = idx_info->layout->storage.u.chunk.u.single.nbytes; |
325 | 0 | udata->filter_mask = idx_info->layout->storage.u.chunk.u.single.filter_mask; |
326 | 0 | } /* end if */ |
327 | 0 | else { |
328 | 0 | udata->chunk_block.length = idx_info->layout->u.chunk.size; |
329 | 0 | udata->filter_mask = 0; |
330 | 0 | } /* end else */ |
331 | 0 | if (!H5_addr_defined(udata->chunk_block.offset)) |
332 | 0 | udata->chunk_block.length = 0; |
333 | |
|
334 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
335 | 0 | } /* H5D__single_idx_get_addr() */ |
336 | | |
337 | | /*------------------------------------------------------------------------- |
338 | | * Function: H5D__single_idx_load_metadata |
339 | | * |
340 | | * Purpose: Load additional chunk index metadata beyond the chunk index |
341 | | * itself. Currently a no-op. |
342 | | * |
343 | | * Return: Non-negative on success/Negative on failure |
344 | | * |
345 | | *------------------------------------------------------------------------- |
346 | | */ |
347 | | static herr_t |
348 | | H5D__single_idx_load_metadata(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info) |
349 | 0 | { |
350 | 0 | FUNC_ENTER_PACKAGE_NOERR |
351 | | |
352 | | /* NO OP */ |
353 | |
|
354 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
355 | 0 | } /* H5D__single_idx_load_metadata() */ |
356 | | |
357 | | /*------------------------------------------------------------------------- |
358 | | * Function: H5D__single_idx_iterate |
359 | | * |
360 | | * Purpose: Make callback for the single chunk |
361 | | * |
362 | | * Return: Non-negative on success/Negative on failure |
363 | | * |
364 | | *------------------------------------------------------------------------- |
365 | | */ |
366 | | static int |
367 | | H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) |
368 | 0 | { |
369 | 0 | H5D_chunk_rec_t chunk_rec; /* generic chunk record */ |
370 | 0 | int ret_value = -1; /* Return value */ |
371 | |
|
372 | 0 | FUNC_ENTER_PACKAGE_NOERR |
373 | | |
374 | | /* Sanity checks */ |
375 | 0 | assert(idx_info); |
376 | 0 | assert(idx_info->f); |
377 | 0 | assert(idx_info->pline); |
378 | 0 | assert(idx_info->layout); |
379 | 0 | assert(chunk_cb); |
380 | 0 | assert(chunk_udata); |
381 | 0 | assert(H5_addr_defined(idx_info->layout->storage.u.chunk.idx_addr)); |
382 | | |
383 | | /* Initialize generic chunk record */ |
384 | 0 | memset(&chunk_rec, 0, sizeof(chunk_rec)); |
385 | 0 | chunk_rec.chunk_addr = idx_info->layout->storage.u.chunk.idx_addr; |
386 | |
|
387 | 0 | if (idx_info->layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { |
388 | 0 | chunk_rec.nbytes = idx_info->layout->storage.u.chunk.u.single.nbytes; |
389 | 0 | chunk_rec.filter_mask = idx_info->layout->storage.u.chunk.u.single.filter_mask; |
390 | 0 | } /* end if */ |
391 | 0 | else { |
392 | 0 | chunk_rec.nbytes = idx_info->layout->u.chunk.size; |
393 | 0 | chunk_rec.filter_mask = 0; |
394 | 0 | } /* end else */ |
395 | | |
396 | | /* Make "generic chunk" callback */ |
397 | 0 | if ((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) |
398 | 0 | HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); |
399 | |
|
400 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
401 | 0 | } /* end H5D__single_idx_iterate() */ |
402 | | |
403 | | /*------------------------------------------------------------------------- |
404 | | * Function: H5D__single_idx_remove |
405 | | * |
406 | | * Purpose: Remove the single chunk |
407 | | * |
408 | | * Return: Non-negative on success/Negative on failure |
409 | | * |
410 | | *------------------------------------------------------------------------- |
411 | | */ |
412 | | static herr_t |
413 | | H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) |
414 | 0 | { |
415 | 0 | hsize_t nbytes; /* Size of all chunks */ |
416 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
417 | |
|
418 | 0 | FUNC_ENTER_PACKAGE |
419 | | |
420 | | /* Sanity checks */ |
421 | 0 | assert(idx_info); |
422 | 0 | assert(idx_info->f); |
423 | 0 | assert(idx_info->pline); |
424 | 0 | assert(idx_info->layout); |
425 | 0 | assert(H5_addr_defined(idx_info->layout->storage.u.chunk.idx_addr)); |
426 | |
|
427 | 0 | if (idx_info->layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) |
428 | 0 | nbytes = idx_info->layout->storage.u.chunk.u.single.nbytes; |
429 | 0 | else |
430 | 0 | nbytes = idx_info->layout->u.chunk.size; |
431 | |
|
432 | 0 | if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->layout->storage.u.chunk.idx_addr, nbytes) < 0) |
433 | 0 | HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free dataset chunks"); |
434 | | |
435 | 0 | idx_info->layout->storage.u.chunk.idx_addr = HADDR_UNDEF; |
436 | |
|
437 | 0 | done: |
438 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
439 | 0 | } /* H5D__single_idx_remove() */ |
440 | | |
441 | | /*------------------------------------------------------------------------- |
442 | | * Function: H5D__single_idx_delete |
443 | | * |
444 | | * Purpose: Delete raw data storage for entire dataset (i.e. the only |
445 | | * chunk) |
446 | | * |
447 | | * Return: Success: Non-negative |
448 | | * Failure: negative |
449 | | * |
450 | | *------------------------------------------------------------------------- |
451 | | */ |
452 | | static herr_t |
453 | | H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) |
454 | 0 | { |
455 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
456 | |
|
457 | 0 | FUNC_ENTER_PACKAGE_NOERR |
458 | | |
459 | | /* Sanity checks */ |
460 | 0 | assert(idx_info); |
461 | 0 | assert(idx_info->f); |
462 | 0 | assert(idx_info->pline); |
463 | 0 | assert(idx_info->layout); |
464 | |
|
465 | 0 | if (H5_addr_defined(idx_info->layout->storage.u.chunk.idx_addr)) |
466 | 0 | ret_value = H5D__single_idx_remove(idx_info, NULL); |
467 | 0 | else |
468 | 0 | assert(!H5_addr_defined(idx_info->layout->storage.u.chunk.idx_addr)); |
469 | |
|
470 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
471 | 0 | } /* end H5D__single_idx_delete() */ |
472 | | |
473 | | /*------------------------------------------------------------------------- |
474 | | * Function: H5D__single_idx_copy_setup |
475 | | * |
476 | | * Purpose: Set up any necessary information for copying the single |
477 | | * chunk |
478 | | * |
479 | | * Return: Non-negative on success/Negative on failure |
480 | | * |
481 | | *------------------------------------------------------------------------- |
482 | | */ |
483 | | static herr_t |
484 | | H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info_src, |
485 | | const H5D_chk_idx_info_t *idx_info_dst) |
486 | 0 | { |
487 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
488 | |
|
489 | 0 | FUNC_ENTER_PACKAGE |
490 | | |
491 | | /* Check args */ |
492 | 0 | assert(idx_info_src); |
493 | 0 | assert(idx_info_src->f); |
494 | 0 | assert(idx_info_src->pline); |
495 | 0 | assert(idx_info_src->layout); |
496 | 0 | assert(H5_addr_defined(idx_info_src->layout->storage.u.chunk.idx_addr)); |
497 | |
|
498 | 0 | assert(idx_info_dst); |
499 | 0 | assert(idx_info_dst->f); |
500 | 0 | assert(idx_info_dst->pline); |
501 | 0 | assert(idx_info_dst->layout); |
502 | | |
503 | | /* Set copied metadata tag */ |
504 | 0 | H5_BEGIN_TAG(H5AC__COPIED_TAG) |
505 | | |
506 | | /* Set up information at the destination file */ |
507 | 0 | if (H5D__single_idx_create(idx_info_dst) < 0) |
508 | 0 | HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage"); |
509 | | |
510 | | /* Reset metadata tag */ |
511 | 0 | H5_END_TAG |
512 | | |
513 | 0 | done: |
514 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
515 | 0 | } /* end H5D__single_idx_copy_setup() */ |
516 | | |
517 | | /*------------------------------------------------------------------------- |
518 | | * Function: H5D__single_idx_size |
519 | | * |
520 | | * Purpose: Retrieve the amount of index storage for the chunked dataset |
521 | | * |
522 | | * Return: Success: Non-negative |
523 | | * Failure: negative |
524 | | * |
525 | | *------------------------------------------------------------------------- |
526 | | */ |
527 | | static herr_t |
528 | | H5D__single_idx_size(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, hsize_t *index_size) |
529 | 0 | { |
530 | 0 | FUNC_ENTER_PACKAGE_NOERR |
531 | | |
532 | | /* Check args */ |
533 | 0 | assert(index_size); |
534 | |
|
535 | 0 | *index_size = 0; |
536 | |
|
537 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
538 | 0 | } /* end H5D__single_idx_size() */ |
539 | | |
540 | | /*------------------------------------------------------------------------- |
541 | | * Function: H5D__single_idx_reset |
542 | | * |
543 | | * Purpose: Reset indexing information. |
544 | | * |
545 | | * Return: Non-negative on success/Negative on failure |
546 | | * |
547 | | *------------------------------------------------------------------------- |
548 | | */ |
549 | | static herr_t |
550 | | H5D__single_idx_reset(H5O_storage_chunk_t *storage, bool reset_addr) |
551 | 1 | { |
552 | 1 | FUNC_ENTER_PACKAGE_NOERR |
553 | | |
554 | | /* Check args */ |
555 | 1 | assert(storage); |
556 | | |
557 | | /* Reset index info */ |
558 | 1 | if (reset_addr) |
559 | 0 | storage->idx_addr = HADDR_UNDEF; |
560 | | |
561 | 1 | FUNC_LEAVE_NOAPI(SUCCEED) |
562 | 1 | } /* end H5D__single_idx_reset() */ |
563 | | |
564 | | /*------------------------------------------------------------------------- |
565 | | * Function: H5D__single_idx_dump |
566 | | * |
567 | | * Purpose: Dump the address of the single chunk |
568 | | * |
569 | | * Return: Non-negative on success/Negative on failure |
570 | | * |
571 | | *------------------------------------------------------------------------- |
572 | | */ |
573 | | static herr_t |
574 | | H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) |
575 | 0 | { |
576 | 0 | FUNC_ENTER_PACKAGE_NOERR |
577 | | |
578 | | /* Check args */ |
579 | 0 | assert(storage); |
580 | 0 | assert(stream); |
581 | |
|
582 | 0 | fprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr); |
583 | |
|
584 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
585 | 0 | } /* end H5D__single_idx_dump() */ |