Line | Count | Source (jump to first uncovered line) |
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 COPYING 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: v2 B-tree metadata statistics functions. |
15 | | * |
16 | | */ |
17 | | |
18 | | /****************/ |
19 | | /* Module Setup */ |
20 | | /****************/ |
21 | | |
22 | | #include "H5B2module.h" /* This source code file is part of the H5B2 module */ |
23 | | |
24 | | /***********/ |
25 | | /* Headers */ |
26 | | /***********/ |
27 | | #include "H5private.h" /* Generic Functions */ |
28 | | #include "H5B2pkg.h" /* v2 B-trees */ |
29 | | #include "H5Eprivate.h" /* Error handling */ |
30 | | |
31 | | /****************/ |
32 | | /* Local Macros */ |
33 | | /****************/ |
34 | | |
35 | | /******************/ |
36 | | /* Local Typedefs */ |
37 | | /******************/ |
38 | | |
39 | | /********************/ |
40 | | /* Package Typedefs */ |
41 | | /********************/ |
42 | | |
43 | | /********************/ |
44 | | /* Local Prototypes */ |
45 | | /********************/ |
46 | | |
47 | | /*********************/ |
48 | | /* Package Variables */ |
49 | | /*********************/ |
50 | | |
51 | | /*****************************/ |
52 | | /* Library Private Variables */ |
53 | | /*****************************/ |
54 | | |
55 | | /*******************/ |
56 | | /* Local Variables */ |
57 | | /*******************/ |
58 | | |
59 | | /*------------------------------------------------------------------------- |
60 | | * Function: H5B2_stat_info |
61 | | * |
62 | | * Purpose: Retrieve metadata statistics for a v2 B-tree |
63 | | * |
64 | | * Return: SUCCEED (Can't fail) |
65 | | * |
66 | | *------------------------------------------------------------------------- |
67 | | */ |
68 | | herr_t |
69 | | H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) |
70 | 0 | { |
71 | 0 | FUNC_ENTER_NOAPI_NOINIT_NOERR |
72 | | |
73 | | /* Check arguments. */ |
74 | 0 | assert(info); |
75 | | |
76 | | /* Get information about the B-tree */ |
77 | 0 | info->depth = bt2->hdr->depth; |
78 | 0 | info->nrecords = bt2->hdr->root.all_nrec; |
79 | |
|
80 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
81 | 0 | } /* H5B2_stat_info() */ |
82 | | |
83 | | /*------------------------------------------------------------------------- |
84 | | * Function: H5B2_size |
85 | | * |
86 | | * Purpose: Iterate over all the records in the B-tree, collecting |
87 | | * storage info. |
88 | | * |
89 | | * Return: SUCCEED/FAIL |
90 | | * |
91 | | *------------------------------------------------------------------------- |
92 | | */ |
93 | | herr_t |
94 | | H5B2_size(H5B2_t *bt2, hsize_t *btree_size) |
95 | 0 | { |
96 | 0 | H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ |
97 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
98 | |
|
99 | 0 | FUNC_ENTER_NOAPI(FAIL) |
100 | | |
101 | | /* Check arguments. */ |
102 | 0 | assert(bt2); |
103 | 0 | assert(btree_size); |
104 | | |
105 | | /* Set the shared v2 B-tree header's file context for this operation */ |
106 | 0 | bt2->hdr->f = bt2->f; |
107 | | |
108 | | /* Get the v2 B-tree header */ |
109 | 0 | hdr = bt2->hdr; |
110 | | |
111 | | /* Add size of header to B-tree metadata total */ |
112 | 0 | *btree_size += hdr->hdr_size; |
113 | | |
114 | | /* Iterate through records */ |
115 | 0 | if (hdr->root.node_nrec > 0) { |
116 | | /* Check for root node being a leaf */ |
117 | 0 | if (hdr->depth == 0) |
118 | 0 | *btree_size += hdr->node_size; |
119 | 0 | else |
120 | | /* Iterate through nodes */ |
121 | 0 | if (H5B2__node_size(hdr, hdr->depth, &hdr->root, hdr, btree_size) < 0) |
122 | 0 | HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed"); |
123 | 0 | } /* end if */ |
124 | | |
125 | 0 | done: |
126 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
127 | 0 | } /* H5B2_size() */ |