1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
|
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<head>
<title>Chapter 6: HDF5 Objects and Identifiers</title>
<!--(Meta)==========================================================-->
<!--(Links)=========================================================-->
<!--( Begin styles definition )=====================================-->
<link href="ed_styles/NewUGelect.css" rel="stylesheet" type="text/css">
<!--( End styles definition )=======================================-->
</head>
<body>
<!-- #BeginLibraryItem "/ed_libs/styles_UG.lbi" -->
<!--
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-->
<!-- #EndLibraryItem --><!-- HEADER LEFT "HDF5 User's Guide" -->
<!-- HEADER RIGHT "HDF5 Groups" -->
<div align="center">
<a name="TOP">
<h2>Chapter 6<br><font size="7">HDF5 Objects and Identifiers</font></h2>
</a>
</div>
<a name="Intro">
<h3>6.1. Introduction</h3>
</a>
<p>The core strengths of HDF5 are the capacity to handle large amounts
of complex data and the flexibility to manage that data efficiently. The
building blocks that give an HDF5 file its capacity and flexibility are
groups and datasets. Datasets will be described in the next chapter. In
this chapter, groups will be described, and since links are
closely intertwined with groups, links will also be discussed.</p>
<p>Groups and links can be used to arrange data in a meaningful way.
For example, objects (groups or datasets) that are used together can
be grouped together. Data that comes from similar sources might also be
grouped together. </p>
<p>When groups are nested, they create a hierarchy. This
hierarchy is similar to the tree structure employed on UNIX file
systems using directories and files and on Apple Macintosh and
Microsoft Windows systems using folders and files. HDF5 groups are
analogous to the directories and folders; HDF5 datasets are analogous
to the files.</p>
<p>The structure of an HDF5 file can also be compared to a geographic
map. Cities and towns are like datasets. They come in a wide variety of
configurations. Roads are like links that help us get to datasets.
Countries, states, and counties are like groups: they help us place
the cities and towns where we live and work. </p>
<!-- NEW PAGE -->
<p>In the rest of this chapter, the following topics will be
discussed:</p>
<ul>
<li>Groups and group structure</li>
<li>Links</li>
<li>Programming with groups and links</li>
<li>Retrieving information about objects in a group</li>
<li>Discovery of the structure of an HDF5 file and the contained objects</li>
<li>Examples of file structures</li>
<li>Function calls provided for working with groups and links</li>
</ul>
<br />
<!-- NEW PAGE -->
<a name="DGroupObj"><a name="DefiningGroupsAndLinks">
<h3 class=pagebefore>6.2. Defining Groups and Links</h3>
</a></a>
<p>Groups and links provide the way for application programs to navigate
to datasets. A <em><b>group</b></em> is a collection of links.
A <em><b>link</b></em> is a connection between a group and an object. When we
use the term link, we mean a connection between a group and an object
that is unidirectional, has a single source, and has a single target.
</p>
<p>The purpose of this section is to describe the basic characteristics
of groups and links. </p>
<a name="Groups">
<h4>6.2.1. Groups</h4>
</a>
<p>A group is a collection of links. If we could peer inside a group,
we would see a list of the links that are the members of the group. </p>
<p>Groups do not have names. When we speak of a group, we use the name
of the link that is connected to the group. </p>
<p>Groups are used to organize objects. If we were organizing our data
by year, we might set up groups for 2010, 2009, and 2008 data. To do this,
our file might have three links named 2010, 2009, and 2008 in the root
group. The groups that are the targets of these three links might have
links to datasets that hold our data.</p>
<p>To work with groups, application programs use the Groups interface.
The names of the function calls in this interface start with H5G.</p>
<a name="TheRootGroup">
<h4>6.2.2. The Root Group</h4>
</a>
<p>When a file is created, a group that we call the root group is
created. The root group is the designated starting point for access
to objects in the file.</p>
<p>There is no name for this group just as there is no name
applied to any object. When we write about the root group, when we
need to specify the root group in a parameter, we use a
slash, <code>/</code>. </p>
<p>Every group is created with a hard link. The link that is created
with the root group is slightly different from other links in that it
does not have a name and cannot be changed. This means the root group
cannot be moved or deleted. See the <a href="#HardAndSymbolicLinks">
“Hard and Symbolic Links”</a> section for more information.</p>
<a name="LinkPaths">
<h4>6.2.3. Link Paths</h4>
</a>
<p>A link is a connection or association between a group and an object.
A group is the source of the link, and the object is the target of the
link. </p>
<p>Every link has a name, and no object has a name. When
we talk about an object, we might call the object by the link's name.
Suppose a group has a link named Y1, and the target of Y1 is a
dataset. If we refer to the dataset as Y1, what we really mean is
the dataset that is the target of the link called Y1. See the figure
below. </p>
<p>As more data is added to our file, we can nest datasets within
groups and groups within groups. As we add links to groups, we need
to remember that link names need to be unique within each group. </p>
<p>To navigate to a group or dataset, we combine the links to the group
or dataset into a <em><b>link path</b></em>. Link names can be used in
more than one place as long as the link paths are unique.</p>
<p>A link path can be absolute or relative. An absolute
link path starts at the root group. A relative link path starts
from some other known position such as the current working group. </p>
<p>A link path looks like a path name in a file system tree structure.
Each link name is separated from another link name by a slash,
<code>/</code>. The link name following a slash is always a member of
the object that is the target of the link name preceding that slash.
For example, in the link path <code>/GroupA/GroupB/Dataset1</code>,
the link <code>GroupB</code> is a member of the group that is the target
of the link <code>GroupA</code>.</p>
<p>The first component in a link path may be any of the
following:</p>
<ul>
<li>The special character dot (., a period), the current group</li>
<li>The special character slash (/), the root group</li>
<li>The name of a link that is a member of the current group</li>
</ul>
<p>Link names may be any string of ASCII or UTF-8 characters that do
not contain a slash or a dot. These are reserved as noted above.
However, users are advised to avoid the use of punctuation and
non-printing characters in link names: these may create problems for
other software. </p>
<p>In an <em><b>absolute link path</b></em> for an object, we start with
a slash as the root group, and then we add other link names
separated by slashes to get to the object. An example might be
<code>/GroupA/GroupB/Dataset1</code>. What we are really saying
when we write <code>/GroupA/GroupB/Dataset1</code> is the following:
to get to the dataset that is the target of the <code>Dataset1</code> link,
start at the root group, look for the link called <code>GroupA</code>, and
follow it. The <code>GroupA</code> link is a member of the root group.
Next, look for the link called <code>GroupB</code>, and follow it.
<code>GroupB</code> is a member of the group that is the target of
the link called <code>GroupA</code>. Finally, find the link called
<code>Dataset1</code> in the group that is the target of the link called
<code>GroupB</code>, and follow it. </p>
<p>A <em><b>relative link path</b></em> starts from some group other
than the root group. If the current working location in the file shown
in the figure below is the group that is the target of the link
<code>YB</code>, then the dataset that is the target of the
<code>Y3</code> link can be identified by the relative link path
<code>YC/Y3</code>.</p>
<p>There may be multiple link paths to an object. In the figure below,
the dataset that is the target of the absolute link path
<code>/YA/Y1</code> is the same dataset that is the target of the
absolute link path <code>/YA/YB/YC/Y3</code>. </p>
<p>The dataset that is the target of the <code>Y1</code> and
<code>Y3</code> links might be accessed using different relative link
paths from the <code>YB</code> group (the group that is the target of
the <code>YB</code> link). Possible relative link paths are
<code>YC/Y3</code> and <code>YC/YD/Y1</code>.</p>
<table align="center" width="500" border="0">
<tr valign="center" align="center">
<td class="fullImgTableImgCell" width="500">
<img height="250" src="Images/groups_fig2a.jpg"
alt="An HDF5 file with a directed graph group structure including a
circular reference"></td>
</tr>
<tr valign="center" align="left">
<td class="fullImgTableCapCell"><span class="figureNumber">
Figure 1. An HDF5 file with a directed graph group structure including a
circular reference </span><br />
Groups are represented by circles, links by arrows, and datasets
by rectangles.
</td>
</tr>
</table>
<p>Note that relative link paths in HDF5 do not employ the
<code>../ </code> notation. The <code>../ </code> notation is used
in UNIX to indicate a parent directory and is not used in HDF5 to indicate
a parent group.</p>
<p>Another feature to note in the figure above is what the link
<code>YD</code> represents. Since the underlying structure of an HDF5
file is a directed graph, circular references such as <code>YD</code>
are possible. If the structure of an HDF5 file kept to a strict tree
structure like that used in file systems, then circular references
would not be possible. In the figure above, the dataset specified
by the <code>/YA/Y1</code> link path could also be specified with
the following link path: <code>/YA/YB/YC/YD/Y1</code>. Another
example is the ZBB link in the <a href="#ExamplesOfGroupsAndLinks">
“Examples of Groups and Links”</a> section below. </p>
<a name="HardAndSymbolicLinks">
<h4>6.2.4. Hard and Symbolic Links</h4>
</a>
<p>There are two types of links: hard and symbolic. Hard links are
constructed with a physical address, and symbolic links are constructed
with names. Characteristics of hard and symbolic links are listed below.</p>
<p>Characteristics of a hard link:</p>
<ul>
<li>A hard link is made with a physical address in the file</li>
<li>A hard link occurs within a single file</li>
<li>When a group or dataset is created, a hard link is also
created </li>
<li>At least one hard link exists for every group or dataset </li>
<li>A hard link and the group or dataset that is the target of the link
exist together (hard links cannot dangle) </li>
<li>A hard link is created using <code>H5Lcreate_hard</code></li>
<li>A group or dataset may be the target of more than one hard link </li>
<li>If a group or dataset is not the target of at least one hard link,
then the group or dataset cannot be accessed, and the space occupied
by the group or dataset will be reclaimed the next time the
<code>h5repack</code> tool is run</li>
<li>The target of a hard link will increase its reference count by one
when the hard link is created, and the reference count will decline
by one when the hard link is deleted</li>
</ul>
<p>Characteristics of a symbolic link:</p>
<ul>
<li>A symbolic link uses a name rather than a physical address</li>
<li>The target of a symbolic link can be changed</li>
<li>There are two types of symbolic links: soft and external</li>
<li>The target of a soft symbolic link (a soft link) will be a group
or dataset within a file</li>
<li>The target of an external symbolic link (an external link) will be
a group or dataset in another file</li>
<li>A symbolic link can exist with or without its target object
(symbolic links can dangle) </li>
<ul>
<li>Suppose a symbolic link is created. The target object may or
may not exist when the symbolic link is created. When an application
opens the target object via the symbolic link, then either the
target will be opened, or an error message will be generated.</li>
</li>
</ul>
<li>A symbolic link can be created with <code>H5Lcreate_soft</code> or
<code>H5Lcreate_external</code>
<li>A group or dataset may be the target of more than one symbolic
link</li>
<li>The target of a symbolic link will not change its reference count
when the symbolic link is created or deleted</li>
</ul>
<p>For more information, see the
<a href="#ReferenceCount">“Reference Count”</a> and
<a href="#ProgModelCreatingHardLinks">“Creating Hard Links”</a>
sections below.</p>
<p>User-defined links might be hard or symbolic, or they might be some
kind of combination. See the <code>H5Lcreate_ud</code> function call in
the <a href="../RM/RM_H5Front.html" target="RMwindow"><cite>HDF5 Reference
Manual</cite></a>.</p>
<a name="ExamplesOfGroupsAndLinks">
<h4>6.2.5. Examples of Groups and Links</h4>
</a>
<p>The figures below illustrate the range of possibilities for groups
and links. In the figures, circles are used to represent groups,
rectangles are used for datasets, and arrows are used for links.</p>
<p>In the figure below, the group structure is hierarchical in the same
way a file system operates.</p>
<table align="center" width="500" border="0">
<tr valign="center" align="center">
<td class="fullImgTableImgCell">
<img height="250" src="Images/groups_fig1a.jpg"
alt="Strictly hierarchical HDF5 group structure"></td>
</tr>
<tr valign="center" align="left">
<td class="fullImgTableCapCell"><span class="figureNumber">Figure 2.
An HDF5 file with a strictly hierarchical group structure</span></td>
</tr>
</table>
<br />
<p>In the figure below, the structure takes advantage of the directed
graph’s allowance of circular references and illustrates
an extreme case in which a group via link ZBB is a member of itself.
A possible reference to a member dataset such as
<code>/ZA/ZB/ZBB/Z2</code> could be set up. Directed graph structures
can become quite complex.</p>
<table align="center" width="500" border="0">
<tr valign="center" align="center">
<td class="fullImgTableImgCell" width="500">
<img height="250" src="Images/groups_fig3a.jpg"
alt="Directed graph HDF5 group structure with self-reference"></td>
</tr>
<tr>
<td class="fullImgTableCapCell"><span class="figureNumber">
Figure 3. An HDF5 file with a directed graph group structure and
one group as a member of itself</span></td>
</tr>
</table>
<br />
<p>The figure below shows an external link. The target of the link path
<code>/MA/MB/MC/NA/N2</code> is a dataset in FileN.h5.</p>
<table align="center" width="500" border="0">
<tr valign="center" align="center">
<td class="fullImgTableImgCell" width="500">
<img height="250" src="Images/groups_fig3b.jpg"
alt="An HDF5 file with a link to another HDF5 file"></td>
</tr>
<tr valign="center" align="left">
<td class="fullImgTableCapCell"><span class="figureNumber">
Figure 4. An HDF5 file with a symbolic link to another HDF5 file
</span></td>
</tr>
</table>
<a name="SummaryOfGroupAndLinkCharacteristics">
<h4>6.2.6. Summary of Group and Link Characteristics</h4>
</a>
<p>Here is a summary of group and link characteristics:</p>
<p>Groups</p>
<ul>
<li>Groups do not have names</li>
<li>Groups hold links</li>
<li>Groups can be empty</li>
<li>Groups do not hold objects</li>
<li>The root group is automatically created when the HDF5
file is created</li>
<li>The root group cannot be deleted</li>
<li>H5G function calls are part of the Groups interface</li>
</ul>
<p>Links</p>
<ul>
<li>Each link has a name</li>
<li>Link names are unique within a group</li>
<li>The target of each link is only one group or dataset</li>
<li>Each group or dataset is the target of at least one hard link </li>
<li>A group or dataset may be the target of many links</li>
<li>Links may create circular references</li>
<li> A link path is made of the links that it takes to get to a group
or a dataset</li>
<li> The links in a link path are separated by slashes</li>
<li>A link path may be absolute or relative</li>
<li>A link may be hard or symbolic</li>
<li>H5L function calls are part of the Links interface</li>
</ul>
<p>See <a href="#NotesForAdvancedLinkUsers">“Notes for Advanced
Link Users”</a> for more information.</p>
<br />
<!-- NEW PAGE -->
<a name="ProgModel">
<h3 class=pagebefore>6.3. Programming Model: Working with Groups
and Links</h3>
</a>
<p>The purpose of this section is to describe more specifically how
common operations can be done.</p>
<p>The table below shows some common group and link operations and
the function calls used. These operations are implemented in the
H5G, the H5L, and the H5O APIs. See
“<a href="#GroupFuncSums">Group and Link Function Summaries</a>”
below for more information.</p>
<table x-use-null-cells
class="ColumnTable"
width="600"
cellspacing="0"
align="center">
<tr valign="bottom">
<td colspan="2" align="left" class="figureNumber">Table 1.
Common group, link, and object function calls</td>
</tr>
<tr valign="top">
<td class="ColumnLeftHdr" width="60%">
<p><span class="TableHead">To do this operation:</span></td>
<td class="ColumnRightHdr" width="40%">
<p><span class="TableHead">Use this function call:</span></td>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Create a group</td>
<td class="ColumnRightCell"> <p><code>H5Gcreate</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Open a group</td>
<td class="ColumnRightCell"> <p><code>H5Gopen</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Close a group</td>
<td class="ColumnRightCell"> <p><code>H5Gclose</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Add an object to a group
(create a link from a group to an object)</td>
<td class="ColumnRightCell"> <p><code>H5Lcreate_hard, H5Lcreate_soft,
H5Lcreate_external</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Remove an object from a group
(remove from a group the link to an object)</td>
<td class="ColumnRightCell"> <p><code>H5Ldelete</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Get the identifier for an object</td>
<td class="ColumnRightCell"> <p><code>H5Ovisit, H5Oget_info</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Get the identifiers for all of the
objects in a group</td>
<td class="ColumnRightCell"> <p><code>H5Ovisit</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Get the name of a link</td>
<td class="ColumnRightCell"> <p><code>H5Lget_info</code></td>
</tr>
<tr valign="top">
<td class="ColumnLeftCell"> <p>Get the names of all the links
in a group</td>
<td class="ColumnRightCell"> <p><code>H5Literate, H5Lvisit</code></td>
</tr>
</table>
<p>When a new object is created, the HDF5 Library executes the
link operation in the background immediately after creating the object.
In other words, the creation operation creates the object and creates
the hard link that connects the object to a group.</p>
<a name="ProgModelCreateGroup">
<h4>6.3.1. Creating a Group</h4>
</a>
<p>To create a group, use the <code>H5Gcreate</code> macro.
When used, <code>H5Gcreate</code> creates a group, opens the group
(returns an identifier that can be used in other operations), and
creates a hard link. </p>
<p>To create a simple group, specify values for the <code>loc_id</code>
and <code>name</code> parameters and use the default property list
parameter value (<code>H5P_DEFAULT</code>) for the property list
parameters. The <code>loc_id</code> parameter is used to specify the
location identifier. The location identifier is the object
identifier for the file or group where the new group will be connected.
The value of the <code>name</code> parameter will be a link or link path.
If the value of <code>loc_id</code> is a file identifier, then the
value of the <code>name</code> parameter will be an absolute link path.
If the value of <code>loc_id</code> is a group identifier, then the
value of the <code>name</code> parameter should be a relative link path
from the group specified with the <code>loc_id</code> parameter.
See <a href="#LinkPaths">“Link Paths”</a> and
<a href="#IdentifiersAndLinkPaths">“Identifiers and Link
Paths”</a> for more information. </p>
<p>The code in the example below creates three groups. </p>
<p>The first group that is created is the target of the
<code>Data</code> link. The <code>Data</code> link
is a member of the root group, and the location identifier
<code>file_id</code> is the object identifier for the file. The
identifier for the file was returned to the application as a result of
the file being opened in the second line of the example.</p>
<p>Two other groups are then created and linked to the group that is
the target of the <code>Data</code> link. The first group uses the
file identifier <code>file_id</code> and an absolute link path
for the name of the link. The second group uses the group
identifier <code>group_id</code> and a relative link path for the name
of the link. The identifier <code>group_id</code> was returned when
the group that is the target of the <code>Data</code> link was
created.</p>
<table x-use-null-cells
width="600"
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td class="fullImgTableImgCell">
<pre>
hid_t file;
file = H5Fopen(....);
group = H5Gcreate(file_id, "/Data", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
group_new1 = H5Gcreate(file_id, "/Data/Data_new1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
group_new2 = H5Gcreate(group_id, "Data_new2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
</pre>
</td></tr>
<tr>
<td align="left" class="fullImgTableCapCell">
<span class="figureNumber">Example 1.
Creating three new groups</span><br />
The default property list parameter is <code>H5P_DEFAULT</code>.
</td></tr>
</table>
<p>The three groups created in the example above are shown in the figure
below.</p>
<table align="center" width="500" border="0">
<tr valign="center" align="center">
<td class="fullImgTableImgCell" width="500">
<img height="250" src="Images/groups_fig5a.jpg"
alt="An HDF5 file with a link to another HDF5 file"></td>
</tr>
<tr valign="center" align="left">
<td class="fullImgTableCapCell"><span class="figureNumber">
Figure 5. Creating groups
</span></td>
</tr>
</table>
<br />
<table align="center" width="500" class="greenframe2">
<tr ><td>
<p><b>Programming reminder</b></p>
<p>Applications should keep track of every
identifier that is returned to the application. After the application
is finished using an object or file, the appropriate close function
call should be executed with the identifier of the object or file that
will be closed. See <a href="#ClosingAGroup">“Closing a
Group”</a> for more information. </p>
</td>
</tr>
</table>
<!-- NEW PAGE -->
<a name="OpeningAGroup">
<h4>6.3.2. Opening a Group</h4>
</a>
<p>It is often useful to explicitly open a group when working with
objects that are the targets of links that are members of that group.
To open a group, use the <code>H5Gopen</code> macro. </p>
<p>The example below refers to the groups in Figure 5 above and
illustrates different ways to open groups. Opening a dataset is a similar
process. </p>
<p>To open an object using a relative link path, an application
must first open the group or file on which the relative link path is
based. In the first line of the example below, a previously-acquired
file identifier, <code>file_id</code>, is used to open the group
that is the target of the <code>/Data</code> link path, and then
the returned group identifier, <code>group_id</code>, and a relative
link path, <code>Data_new1</code>, are used to open the group that is the
target of the <code>Data_new1</code> link.</p>
<p>To open an object using an absolute link path, the application
can use the file identifier, <code>file_id</code>, and an absolute link
path. In the third line of the example below, <code>file_id</code> is used
with <code>/Data/Data_new2</code> to open the group that is the target of
the <code>Data_new2</code> link.</p>
<table x-use-null-cells
width="600"
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td class="fullImgTableImgCell">
<pre>
group = H5Gopen(file_id, "/Data", H5P_DEFAULT);
group1 = H5Gopen(group_id, "Data_new1", H5P_DEFAULT);
group2 = H5Gopen(file_id, "/Data/Data_new2", H5P_DEFAULT);
</pre>
</td></tr>
<tr>
<td align="left" class="fullImgTableCapCell">
<span class="figureNumber">Example 2.
Open groups with relative and absolute link paths</span>
</td></tr>
</table>
<a name="CreatingADataset">
<h4>6.3.3. Creating a Dataset</h4>
</a>
<p>The process of creating a dataset is like the process of creating
a group that was discussed above. When a dataset is created, a hard
link to it is automatically created. The link will be a member of a
group, and when we talk about the dataset, we will use the name of
the link to refer to the dataset. As with groups, a dataset may be
created in a group by specifying an absolute link path or a relative
link path. The example below illustrates both approaches to creating
a dataset in the group that is the target of the <code>/Data</code>
link. The absolute link path to the first dataset is
<code>/Data/CData</code>. The <code>H5Dcreate</code> macro uses a
previously-acquired <code>file_id</code> and the default property list
parameter <code>H5P_DEFAULT</code>. For the second dataset, the example
first opens the group which will be the source of the link to the
dataset, and then uses the <code>group_id</code> and the relative link
<code>Cdata2</code> to create and locate the dataset.</p>
<table x-use-null-cells
width="600"
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td class="fullImgTableImgCell">
<pre>
dataspace = H5Screate_simple(RANK, dims, NULL);
dataset1 = H5Dcreate(file_id, "/Data/CData", H5T_NATIVE_INT,
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
group = H5Gopen(file_id, "/Data", H5P_DEFAULT);
dataset2 = H5Dcreate(group_id, "Cdata2", H5T_NATIVE_INT,
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
</pre>
</td></tr>
<tr>
<td align="left" class="fullImgTableCapCell">
<span class="figureNumber">Example 3.
Create datasets using absolute and relative link paths</span>
</td></tr>
</table>
<!-- NEW PAGE -->
<a name="ClosingAGroup">
<h4>6.3.4. Closing a Group</h4>
</a>
<p>To ensure the integrity of HDF5 objects and to release system
resources, an application should always call the appropriate
close function when it is through working with an HDF5 object.
In the case of groups, <code>H5Gclose</code> ends access to the group
and releases any resources the HDF5 Library has maintained
in support of that access including the group identifier. </p>
<p>As illustrated in the example below, all that is required for an
<code>H5Gclose</code> call is the group identifier acquired when
the group was opened. There are no relative versus absolute link path
considerations.</p>
<table x-use-null-cells
width="600"
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td class="fullImgTableImgCell">
<pre>
herr_t status;
status = H5Gclose(group_id);
</pre>
</td></tr>
<tr>
<td align="left" class="fullImgTableCapCell">
<span class="figureNumber">Example 4.
Close a group</span>
</td></tr>
</table>
<p>A non-negative return value indicates that the group was successuflly
closed and the resources released; a negative return value indicates that
the attempt to close the group or release resources failed.</p>
<a name="ProgModelCreatingHardLinks">
<h4>6.3.5. Creating Hard Links </h4>
</a>
<p>When a group or a dataset is created, a hard link is also created.
This hard link gives the group or dataset a location in the file.
After a group or dataset is created, additional hard links can be
explicitly added by means of the <code>H5Lcreate_hard</code> function
call to improve access and resource efficiency. See the
<a href="#DefiningGroupsAndLinks"> “Defining Groups and
Links”</a> section for more information.</p>
<p>The code in the example below illustrates the creation of a hard link
named <code>Y3</code>.
Once that link is created, the dataset that is the target of the
absolute link path <code>/YA/Y1</code> can also be accessed by means
of the absolute link path <code>/YA/YB/YC/Y3</code>. </p>
<p>Here are some comments for each line in the example below.</p>
<ol>
<li>The file is opened. The identifier <code>file_id</code> is
returned.</li>
<li>The group that is the target of the <code>/YA/YB/YC</code> link
is opened and returns the <code>group_id</code> identifier.</li>
<li>The <code>Y3</code> link is created. The <code>file_id</code>
identifier and the absolute link path <code>/YA/Y1</code> are
used to specify the dataset that will be the target of the new
link. The <code>group_id</code> identifier specifies the group
that is the target of the <code>/YA/YB/YC</code> link is the
source of the new link. The new link is named <code>Y3</code>.
The default property list value (<code>H5P_DEFAULT</code>) is
used for the property list parameters.</li>
<li>This line shows an alternate way to create <code>Y3</code>. The
difference between this line and the one above it is the
<code>file_id</code> is used with an absolute link path to
define the new link. </li>
</ol>
</p>
<table x-use-null-cells
width="600"
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td class="fullImgTableImgCell">
<pre>
file = H5Fopen(....);
group = H5Gopen(file_id, "/YA/YB/YC", H5P_DEFAULT);
status = H5Lcreate_hard(file_id, "/YA/Y1", group_id, "Y3",
H5P_DEFAULT, H5P_DEFAULT)
status = H5Lcreate_hard(file_id, "/YA/Y1", file_id, "/YA/YB/YC/Y3",
H5P_DEFAULT, H5P_DEFAULT)
</pre>
</td></tr>
<tr>
<td align="left" class="fullImgTableCapCell">
<span class="figureNumber">Example 5. Create a hard link</span>
</td></tr>
</table>
<br />
<table align="center" width="500" border="0">
<tr valign="center" align="center">
<td class="fullImgTableImgCell" width="500">
<img height="250" src="Images/groups_fig2a_Ex5.jpg"
alt="Create a hard link"></td>
</tr>
<tr valign="center" align="left">
<td class="fullImgTableCapCell"><span class="figureNumber">
Figure 6. Creating hard links
</span></td>
</tr>
</table>
<!-- NEW PAGE -->
<a name="DeletingALink">
<h4>6.3.6. Deleting a Link</h4>
</a>
<p>The <code>H5Ldelete</code> function call can be used to remove
hard, soft, external, and user-defined links. </p>
<p>The example below refers to the link named <code>Y3</code> that was
created in the section above and shows how to remove a link using a
relative link path and an absolute link path. The first line uses the
<code>group_id</code> identifier for the group that is the source
of the link, the name of the link, <code>Y3</code>, and the default
property list parameter, <code>H5P_DEFAULT</code>. The second line
uses the <code>file_id</code> identifier for the file, an absolute
link path, and the default property list parameter. Only the final
link in the absolute link path will be deleted.</p>
<table x-use-null-cells
width="600"
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td class="fullImgTableImgCell">
<pre>
status = H5Ldelete(group_id, "Y3", H5P_DEFAULT);
status = H5Ldelete(file_id, "/YA/YB/YC/Y3", H5P_DEFAULT);
</pre>
</td></tr>
<tr>
<td align="left" class="fullImgTableCapCell">
<span class="figureNumber">Example 6. Delete a link</span>
</td></tr>
</table>
<br />
<table align="center" width="500" class="greenframe2">
<tr ><td>
<p><b>How to avoid deleting the last hard link</b></p>
<p>When the last hard link to an object is deleted, the object is no
longer accessible. Note that <code>H5Ldelete</code> will not prevent
you from deleting the last link to an object. To see if an object has
only one link, use the <code>H5Oget_info</code> function. If the value
of the rc (reference count) field in <code>object_info</code> is greater
than 1, then a link to the object can be deleted without making the
object inaccessible.</p>
<p>It is possible to delete the last hard link to an object and not make
the object inaccessible. Suppose your application opens a dataset and
then deletes the last hard link to the dataset. While
the dataset is open, your application still has a connection to the
dataset through the identifier returned when the dataset was opened.
If your application creates a hard link to the dataset before
it closes the dataset, then the dataset will still be accessible
after the dataset is closed.</p>
</td>
</tr>
</table>
<a name="CreatingSymbolicLinks">
<h4>6.3.7. Creating Symbolic Links</h4>
</a>
<p>Symbolic links are based on names and not on physical file addresses.
Symbolic links are similar to the soft links, aliases, and shortcuts
that are used with various operating systems. Programmers can use
symbolic links to more easily work with any long link paths they may
be using and to work with objects in other HDF5 files. There are two
kinds of symbolic links: soft and external. Soft links are
used within a single file. External links are used to connect files.</p>
<p>A big difference between symbolic links and hard links is the status
of the target when the link is created. The target of a hard link must
exist when the hard link is created. The target of a symbolic link may
or may not exist when the link is created. If a symbolic link is created
and the target does not exist, the link is said to dangle or to be a
dangling link. So, symbolic links are more flexible than hard links.</p>
<p><b>To create a soft link</b>, use the <code>H5Lcreate_soft</code>
function call. The function call has five parameters. The last two are
property lists. In the example below, the default property list value
<code>H5P_DEFAULT</code> is used. The first three parameters are
called in the <cite>HDF5 Reference Manual</cite> <code>target_path</code>,
<code>link_loc_id</code>, and <code>link_name</code>. </p>
<p>The value of <code>target_path</code> is a link path to the target of
the soft link. This is not the soft link. This is what the soft link
resolves to when the soft link is used. The links in this link path
may or may not exist when the soft link is created, but the links and
any intermediate groups in this link path must exist when the soft link
is first used in order for the soft link to work. </p>
<p>The value of <code>link_loc_id</code> is a file identifier or a
group identifier. If the value of this parameter is a file identifier,
then the values of the <code>target_path</code> and
<code>link_name</code> parameters should be absolute link paths. If
the value of this parameter is a group identifier, then the values of
the <code>target_path</code> and <code>link_name</code> parameters
could be either relative or absolute link paths. A relative link
path would start from the group identifier's group. </p>
<p>The value of <code>link_name</code> is the name of the new soft
link. In the example below, the new soft link is called
<code>2010</code>.</p>
<p>The example below creates a soft link called <code>2010</code>
with a <code>link_loc_id</code> of <code>file_id</code> and a
<code>target_path</code> of <code>/YA/YB/YC/Y3</code>. The example
then opens the dataset that is the target of the soft link.</p>
<table x-use-null-cells
width="600"
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td class="fullImgTableImgCell">
<pre>
status = H5Lcreate_soft("/YA/YB/YC/Y3", file_id, "/2010", H5P_DEFAULT, H5P_DEFAULT);
dataset = H5Dopen(file_id, "/2010", H5P_DEFAULT);
</pre>
</td></tr>
<tr>
<td align="left" class="fullImgTableCapCell">
<span class="figureNumber">Example 7. Create a soft link</span>
</td></tr>
</table>
<p>The figure below illustrates the new soft link created in the
example above. </p>
<table align="center" width="500" border="0">
<tr valign="center" align="center">
<td class="fullImgTableImgCell" width="500">
<img height="250" src="Images/groups_fig2a_Ex8.jpg"
alt="Creating a soft link"></td>
</tr>
<tr valign="center" align="left">
<td class="fullImgTableCapCell"><span class="figureNumber">
Figure 7. Creating a soft link</span><br />
Groups are represented by circles, links by arrows, and datasets
by rectangles.
</td>
</tr>
</table>
<p><b>To create an external link</b>, use the
<code>H5Lcreate_external</code> function call. The parameters used with
<code>H5Lcreate_external</code> are the same as those used with
<code>H5Lcreate_soft</code> except that an HDF5 file is also specified.
See the <cite>HDF5 Reference Manual</cite> for more information.</p>
<p>See the <a href="#NotesForAdvancedLinkUsers">“Notes for
Advanced Link Users”</a> section for more information. </p>
<a name="DiscoverInfo">
<h4 class=pagebefore>6.3.8. Discovering Information about Objects</h4>
</a>
<p>There is often a need to retrieve information about a particular object.
The <code>H5Lget_info</code> and <code>H5Oget_info</code> functions fill
this niche by returning a description of the object or link in an
<code>H5L_info_t</code> or <code>H5O_info_t</code> structure.</p>
<a name="DiscoverGrObjs">
<h4 class=pagebefore>6.3.9. Discovering Objects in a Group</h4>
</a>
<p>To examine all the objects or links in a group,
use the <code>H5Literate</code> or <code>H5Ovisit</code> functions to
examine the objects, and use
the <code>H5Lvisit</code> function to examine the links.
The <code>H5Literate</code> function is useful both with a single group and
in an iterative process that examines an entire file
or section of a file (such as the contents of a group or the contents
of all the groups that are members of that group)
and acts on objects as they are encountered. The <code>H5Ovisit</code>
function recursively visits all objects accessible from a specified object.
The <code>H5Lvisit</code> function recursively visits all the links
starting from a specified group. </p>
<!-- NEW PAGE -->
<a name="DiscoverAll">
<h4 class=pagebefore>6.3.10. Discovering all of the Objects in the File</h4>
</a>
<p>The structure of an HDF5 file is
<span class="termDefinition">self-describing</span>,
meaning that an application can navigate an HDF5 file
to discover and understand all the objects it contains.
This is an iterative process wherein the structure is traversed as a graph,
starting at one node and recursively visiting linked nodes.
To explore the entire file, the traversal should start at the root group.</p>
<!-- NEW PAGE -->
<a name="UsingH5Dump">
<h3 class=pagebefore>6.3.11. Using <code>h5dump</code></h3>
</a>
<p>The <code>h5dump</code> application program is a command-line
utility that is distributed with HDF5. It can be used to inspect
the contents of an HDF5 file. It can show the structure of a file
so that you can determine where to create an object or so that you
can verify that your application program actually created an object.</p>
<p>In the case of the new group created in the
“<a href="#ProgModelCreateGroup">Creating a group</a>” section,
the following <code>h5dump</code> command will display the
contents of <code>FileA.h5</code>:</p>
<dir><pre>
h5dump FileA.h5
</pre></dir>
<p>
Assuming that the discussed objects, <code>GroupA</code> and
<code>GroupB</code> are the only objects that exist in
<code>FileA.h5</code>, the output will look something like the
following:</p>
<dir><pre>
HDF5 "FileA.h5" {
GROUP "/" {
GROUP GroupA {
GROUP GroupB {
}
}
}
}
</pre></dir>
<p>
The <code>h5dump</code> program is described on the
<a href="../RM/Tools.html" target="RMwindow">Tools</a> page of the
<a href="../RM/RM_H5Front.html"
target="RMwindow"><cite>HDF5 Reference Manual</cite></a>.</p>
<p>The HDF5 DDL grammar is described in the document
<a href="../ddl.html" target="RMwindow">DDL in BNF for HDF5</a>,
an element of this <cite>HDF5 User’s Guide</cite>.</p>
<br />
<br />
<!-- NEW PAGE -->
<a name="Examples">
<h3 class=pagebefore>6.4. Examples of Group Structures</h3></a>
<p>This section presents several samples of possible HDF5 group
structures.</p>
<table x-use-null-cells
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td align="center" class="fullImgTableImgTopCell">
<img src="Images/groups_fig27_a.JPG">
</td><td align="center" valign="top" class="fullImgTableImgTopCell"> </td>
<td align="center" class="fullImgTableImgTopCell">
<img src="Images/groups_fig27_b.JPG">
</td>
</tr>
<tr>
<td align="center" width="50%">
a) The file contains three groups:
the root group, <code>/group1</code>, and <code>/group2</code>.
</td><td align="center" valign="top"> </td>
<td align="center" width="50%">
b) The dataset <code>dset1</code> (or <code>/group1/dset1</code>)
is created in <code>/group1</code>.
</td>
</tr>
<tr valign="top">
<td align="center">
<img src="Images/groups_fig27_aa.JPG">
</td><td align="center" valign="top"> </td>
<td align="center">
<img src="Images/groups_fig27_bb.JPG">
</td>
</tr>
<tr>
<td align="center" valign="top" class="fullImgTableImgBottomCell">
c) A link named <code>dset2</code> is created in <code>/group2</code>.
</td><td align="center" valign="top" class="fullImgTableImgBottomCell"> </td>
<td align="center" class="fullImgTableImgBottomCell">
d) The <code>dset1</code> link is removed. The dataset is still in the
file, but can be accessed only as <code>/group2/dset2</code>.
</td>
</tr>
<tr>
<td height="24" colspan="3" align="left" class="fullImgTableCapCell">
<span class="figureNumber">Figure 8. Some group structures</span>
</td>
</tr>
</table>
<p>The figure above shows examples of the structure of a file with three
groups and one dataset. The file in Figure 8a contains three groups:
the root group and two member groups. In Figure 8b, a dataset has been
created and linked to <code>/group1</code> with the link named
<code>dset1</code>. In Figure 8c, a link named <code>dset2</code> from
<code>/group2</code> to the dataset has been added. Note that there is
only one copy of the dataset; there are two links to it, and it can be
accessed either as <code>/group1/dset1</code> or as
<code>/group2/dset2</code>. Figure 8d above illustrates that one of the
two links to the dataset can be deleted. In this case, the link from
<code>/group1</code> has been removed. The dataset itself has not
been deleted; it is still in the file, but it can only be accessed as
<code>/group1/dset2</code>.</p>
<!-- NEW PAGE -->
<table x-use-null-cells
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td align="center" class="fullImgTableImgTopCell">
<img src="Images/groups_fig28_a.JPG">
</td><td align="center" valign="top" class="fullImgTableImgTopCell"> </td>
<td align="center" class="fullImgTableImgTopCell">
<img src="Images/groups_fig28_b.JPG">
</td>
</tr>
<tr>
<td align="center" width="50%">
a) <code>dset1</code> has two names:
<code>/group2/dset1</code> and <code>/group1/GXX/dset1</code>.
</td><td> </td>
<td align="center" width="50%">
b) <code>dset1</code> again has two names:
<code>/group1/dset1</code> and <code>/group1/dset2</code>.
</td>
</tr>
<tr valign="top">
<td align="center">
<img src="Images/groups_fig28_c.JPG">
</td><td> </td>
<td align="center">
<img src="Images/groups_fig28_d.JPG">
</td>
</tr>
<tr>
<td align="center" valign="top" class="fullImgTableImgBottomCell">
c) <code>dset1</code> has three names:
<code>/group1/dset1</code>, <code>/group2/dset2</code>,
and <code>/group1/GXX/dset2</code>.
</td><td align="center" valign="top" class="fullImgTableImgBottomCell"> </td>
<td align="center" class="fullImgTableImgBottomCell">
d) <code>dset1</code> has many available path names.
</td>
</tr>
<tr>
<td height="24" colspan="3" align="left" class="fullImgTableCapCell">
<span class="figureNumber">Figure 9. More sample group structures</span>
</td>
</tr>
</table>
<p>The figure above illustrates loops in an HDF5 group structure.
The file in Figure 9a contains three groups and a dataset.
The group that is the target of the <code>group2</code> link is a
member of the root group and is also a member of the group that is the
target of the <code>group1</code> link. The group that is the target
of the <code>group2</code> link can be accessed by either of two link
paths: <code>/group2</code> or <code>/group1/GXX</code>.
Similarly, the dataset can be accessed by these link paths:
<code>/group2/dset1</code> or <code>/group1/GXX/dset1</code>.</p>
<p>Figure 9b illustrates a different case: the dataset is the target
of two links that are both members of the same group. In this case,
the dataset again has two names: <code>/group1/dset1</code> and
<code>/group1/dset2</code>.</p>
<!-- NEW PAGE -->
<p>In Figure 9c, the dataset that is the target of the <code>dset1</code>
link is a member of two groups. The dataset has three absolute link
paths: <code>/group1/dset1</code>, <code>/group2/dset2</code>, and
<code>/group1/GXX/dset2</code>. </p>
<p>In Figure 9d, two of the groups are members of each other, and the
dataset is a member of both groups. In this case, there are an infinite
number of paths to the dataset because <code>GXX</code> and
<code>GYY</code> can be traversed any number of times on the way from
the root group, <code>/</code>, to the dataset. This can yield a link path
such as <code>/group1/GXX/GYY/GXX/GYY/GXX/dset2</code>.</p>
<table x-use-null-cells
cellspacing="0"
class="fullImgTable"
align="center">
<tr valign="top">
<td align="center" class="fullImgTableImgTopCell">
<img src="Images/groups_fig29_a.JPG">
</td><td align="center" valign="top" class="fullImgTableImgTopCell"> </td>
<td align="center" class="fullImgTableImgTopCell">
<img src="Images/groups_fig29_b.JPG">
</td>
</tr>
<tr>
<td align="center" valign="top" width="48%">
a) The file contains only hard links.
</td><td> </td>
<td align="center" valign="top" width="48%">
b) The <code>dset2</code> soft link is added.
</td>
</tr>
<tr valign="top">
<td align="center">
<img src="Images/groups_fig29_c.JPG">
</td><td> </td>
<td align="center">
<img src="Images/groups_fig29_d.JPG">
</td>
</tr>
<tr>
<td align="center" valign="top" class="fullImgTableImgBottomCell">
c) A soft link named <code>dset3</code> is added with a target
that does not yet exist.
</td><td align="center" valign="top" class="fullImgTableImgBottomCell"> </td>
<td align="center" valign="top" class="fullImgTableImgBottomCell">
d) The target of the soft link is created or linked.
</td>
</tr>
<tr>
<td height="24" colspan="3" align="left" class="fullImgTableCapCell">
<span class="figureNumber">Figure 10. Hard and soft links</span>
</td>
</tr>
</table>
<!-- NEW PAGE -->
<p>
The figure above takes us into the realm of soft links.
The original file, in Figure 10a, contains only three hard links.
In Figure 10b, a soft link named <code>dset2</code> has been created.
The source of the new link is the group that is the target of the
<code>group2</code> link. The target of the new link is also the target
of the <code>/group1/dset1</code> link path.</p>
<p>In Figure 10c, another soft link, <code>dset3</code>, has been created
in the group that is the target of the <code>group2</code> link. The
target <code>dset3</code> does not yet exist. That target object has
been added in Figure 10d along with the hard link <code>dset</code>. The
target dataset is now accessible as either <code>/group2/dset</code> or
<code>/group2/dset3</code>.</p>
<br />
<!-- NEW PAGE -->
<a name="GroupFuncSums">
<h3 class=pagebefore>6.5. Group and Link Function Summaries</h3>
</a>
<p>Function calls that can be used with groups (H5G functions) and
property list functions that can used with groups (H5P functions) are
listed below. A number of group functions have been deprecated. Most
of these have been replaced by link (H5L) or object (H5O) functions.
These replacement functions are also listed below. For more information
on any of these interfaces or functions, see the
<a href="../RM/RM_H5Front.html" target="RMwindow"><cite>HDF5 Reference
Manual</cite></a>.</p>
<br />
<table x-use-null-cells
class="functTable"
width="600"
cellspacing="0"
align="center">
<tr valign="bottom">
<td colspan="2" align="left" valign="bottom" class="figureNumber">
Function Listing 1. Group functions (H5G)</td>
</tr>
<tr valign="top">
<td class="functTableLeftHdr">
<span class="TableHead">C Function<br>F90 Function</span>
</td>
<td class="functTableRightHdr">
<span class="TableHead">Purpose</span>
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableCell">
<code>H5Gcreate<br>h5gcreate_f</code>
</td>
<td colspan=1
rowspan=1
class="functTableCell">
Creates and opens a new group. The C function is a
macro: see <a href="../RM/APICompatMacros.html">“API
Compatibility Macros in HDF5.”</a>
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableCell">
<code>H5Gcreate_anon<br>h5gcreate_anon_f</code>
</td>
<td colspan=1
rowspan=1
class="functTableCell">
Creates and opens a new group without linking it into the file
structure.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Gopen<br>h5gopen_f</code>
</td>
<td class="functTableCell">
Opens an existing group. The C function is a
macro: see <a href="../RM/APICompatMacros.html">“API
Compatibility Macros in HDF5.”</a>
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Gclose<br>h5gclose_f</code>
</td>
<td class="functTableCell">
Closes the specified group.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Gget_create_plist<br>h5gget_create_plist_f</code>
</td>
<td class="functTableCell">
Gets a group creation property list identifier.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Gget_info<br>h5gget_info_f</code>
</td>
<td class="functTableCell">
Retrieves information about a group.
Use instead of <code>H5Gget_num_objs</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Gget_info_by_idx<br>h5gget_info_by_idx_f</code>
</td>
<td class="functTableCell">
Retrieves information about a group according to the groups
position within an index.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Gget_info_by_name<br>h5gget_info_by_name_f</code>
</td>
<td class="functTableCell">
Retrieves information about a group.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>(none)<br>h5gget_obj_info_idx_f</code>
</td>
<td class="functTableCell">
Returns name and type of the group member identified by its index.
Use with the <code>h5gn_members_f</code> function.
<code>h5gget_obj_info_idx_f</code> and <code>h5gn_members_f</code>
are the Fortran equivalent of
the C function <code>H5Literate</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableBottom">
<code>(none)<br>h5gn_members_f</code>
</td>
<td class="functTableBottom">
Returns the number of group members.
Use with the <code>h5gget_obj_info_idx_f</code> function.
</td>
</tr>
</table>
<br />
<table x-use-null-cells
class="functTable"
width="600"
cellspacing="0"
align="center">
<tr valign="bottom">
<td colspan="2" align="left" valign="bottom" class="figureNumber">
Function Listing 2. Link (H5L) and object (H5O) functions</td>
</tr>
<tr valign="top">
<td class="functTableLeftHdr">
<span class="TableHead">C Function<br>F90 Function</span>
</td>
<td class="functTableRightHdr">
<span class="TableHead">Purpose</span>
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableCell">
<code>H5Lcreate_hard<br>h5lcreate_hard_f</code>
</td>
<td colspan=1
rowspan=1
class="functTableCell">
Creates a hard link to an object.
Replaces <code>H5Glink</code> and <code>H5Glink2</code>.
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableCell">
<code>H5Lcreate_soft<br>h5lcreate_soft_f</code>
</td>
<td colspan=1
rowspan=1
class="functTableCell">
Creates a symbolic link to an object in the same file.
Replaces <code>H5Glink</code> and <code>H5Glink2</code>.
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableCell">
<code>H5Lcreate_external<br>h5lcreate_external_f</code>
</td>
<td colspan=1
rowspan=1
class="functTableCell">
Creates a symbolic link to an object in a different file.
Replaces <code>H5Glink</code> and <code>H5Glink2</code>.
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableCell">
<code>H5Lcreate_ud<br>(none)</code>
</td>
<td colspan=1
rowspan=1
class="functTableCell">
Creates a user-defined link.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Lget_val<br>(none)</code>
</td>
<td class="functTableCell">
Returns the value of a symbolic link.
Replaces <code>H5Gget_linkval</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Literate<br>(none)</code>
</td>
<td class="functTableCell">
Iterates through links in a group.
Replaces <code>H5Giterate</code>.
See also <code>H5Ovisit</code> and <code>H5Lvisit</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Lget_info<br>h5lget_info_f</code>
</td>
<td class="functTableCell">
Returns information about a link.
Replaces <code>H5Gget_objinfo</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Oget_info<br>(none)</code>
</td>
<td class="functTableCell">
Retrieves the metadata for an object.
Replaces <code>H5Gget_objinfo</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Lget_name_by_idx<br>h5lget_name_by_idx_f</code>
</td>
<td class="functTableCell">
Retrieves name of the nth link in a group according to the order
within a specified field or index.
Replaces <code>H5Gget_objname_by_idx</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Oget_info_by_idx<br>(none)</code>
</td>
<td class="functTableCell">
Retrieves the metadata for an object which is identified
by an index position.
Replaces <code>H5Gget_objtype_by_idx</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Oset_comment<br>(none)</code>
</td>
<td class="functTableCell">
Sets the comment for specified object.
Replaces <code>H5Gset_comment</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Oget_comment<br>(none)</code>
</td>
<td class="functTableCell">
Gets the comment for specified object.
Replaces <code>H5Gget_comment</code>.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Ldelete<br>h5ldelete_f</code>
</td>
<td class="functTableCell">
Removes a link from a group.
Replaces <code>H5Gunlink</code>.
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableBottom">
<code>H5Lmove<br>h5lmove_f</code>
</td>
<td colspan=1
rowspan=1
class="functTableBottom">
Renames a link within an HDF5 file.
Replaces <code>H5Gmove</code> and <code>H5Gmove2</code>.
</td>
</tr>
</table>
<br />
<table x-use-null-cells
class="functTable"
width=100%
cellspacing="0"
align="center">
<tr valign="bottom">
<td colspan="2" align="left" valign="bottom" class="figureNumber">
Function Listing 3. Group creation property list functions (H5P)</td>
</tr>
<tr valign="top">
<td class="functTableLeftHdr">
<span class="TableHead">C Function<br>F90 Function</span>
</td>
<td class="functTableRightHdr">
<span class="TableHead">Purpose</span>
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pall_filters_avail<br>(none)</code>
</td>
<td class="functTableCell">
Verifies that all required filters are available.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_filter<br>h5pget_filter_f</code>
</td>
<td class="functTableCell">
Returns information about a filter in a pipeline. The C function is a
macro: see <a href="../RM/APICompatMacros.html">“API
Compatibility Macros in HDF5.”</a>
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_filter_by_id<br>h5pget_filter_by_id_f</code>
</td>
<td class="functTableCell">
Returns information about the specified filter. The C function is a
macro: see <a href="../RM/APICompatMacros.html">“API
Compatibility Macros in HDF5.”</a>
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_nfilters<br>h5pget_nfilters_f</code>
</td>
<td class="functTableCell">
Returns the number of filters in the pipeline.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pmodify_filter<br>h5pmodify_filter_f</code>
</td>
<td class="functTableCell">
Modifies a filter in the filter pipeline.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Premove_filter<br>h5premove_filter_f</code>
</td>
<td class="functTableCell">
Deletes one or more filters in the filter pipeline.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_deflate<br>h5pset_deflate_f</code>
</td>
<td class="functTableCell">
Sets the deflate (GNU gzip) compression method and compression level.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_filter<br>h5pset_filter_f</code>
</td>
<td class="functTableCell">
Adds a filter to the filter pipeline.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_fletcher32<br>h5pset_fletcher32_f</code>
</td>
<td class="functTableCell">
Sets up use of the Fletcher32 checksum filter.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_fletcher32<br>h5pset_fletcher32_f</code>
</td>
<td class="functTableCell">
Sets up use of the Fletcher32 checksum filter.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_link_phase_change<br>h5pset_link_phase_change_f</code>
</td>
<td class="functTableCell">
Sets the parameters for conversion between compact and dense groups.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_link_phase_change<br>h5pget_link_phase_change_f</code>
</td>
<td class="functTableCell">
Queries the settings for conversion between compact and dense groups.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_est_link_info<br>h5pset_est_link_info_f</code>
</td>
<td class="functTableCell">
Sets estimated number of links and length of link names in a group.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_est_link_info<br>h5pget_est_link_info_f</code>
</td>
<td class="functTableCell">
Queries data required to estimate required local heap or object header size.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_nlinks<br>h5pset_nlinks_f</code>
</td>
<td class="functTableCell">
Sets maximum number of soft or user-defined link traversals.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_nlinks<br>h5pget_nlinks_f</code>
</td>
<td class="functTableCell">
Retrieves the maximum number of link traversals.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_link_creation_order<br>h5pset_link_creation_order_f</code>
</td>
<td class="functTableCell">
Sets creation order tracking and indexing for links in a group.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_link_creation_order<br>h5pget_link_creation_order_f</code>
</td>
<td class="functTableCell">
Queries whether link creation order is tracked and/or indexed in a group.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pset_create_intermediate_group<br>h5pset_create_inter_group_f</code>
</td>
<td class="functTableCell">
Specifies in the property list whether to create missing intermediate
groups.
</td>
</tr>
<tr valign="top">
<td class="functTableCell">
<code>H5Pget_create_intermediate_group<br>(none)</code>
</td>
<td class="functTableCell">
Determines whether the property is set to enable creating missing
intermediate groups.
</td>
</tr>
<tr valign="top">
<td colspan=1
rowspan=1
class="functTableCell">
<code>H5Pset_char_encoding<br>h5pset_char_encoding_f</code>
</td>
<td colspan=1
rowspan=1
class="functTableCell">
Sets the character encoding used to encode a string.
Use to set ASCII or UTF-8 character encoding for object names.
</td>
</tr>
<tr valign="top">
<td class="functTableBottom">
<code>H5Pget_char_encoding<br>h5pget_char_encoding_f</code>
</td>
<td class="functTableBottom">
Retrieves the character encoding used to create a string.
</td>
</tr>
</table>
<br />
<!-- NEW PAGE -->
<a name="NotesForAdvancedLinkUsers">
<h3 class=pagebefore>6.6. Notes for Advanced Link Users</h3>
</a>
<p>The purpose of this section is to provide extra information about
links.</p>
<a name="LinkIndexingAndCompactGroupStorage">
<h4>6.6.1. Link Indexing and Compact Group Storage </h4>
</a>
<p>In HDF5 Release 1.8.0, a second link indexing and group storage
format was added. The new format enables more efficient compact storage
for very small groups, improved link indexing for large groups,
and other advanced features. The original link indexing format - links
are stored in a B-tree in the group’s local heap - remains the
default. The new implementation is required for external and user-defined
links and also enables the use of link names consisting of non-ASCII
character sets. For more information, see the “Group Implementations
in HDF5” section in the “H5G: Group Interface” section
in the <a href="../RM/RM_H5Front.html" target="RMwindow"><cite>HDF5
Reference Manual</cite></a>.</p>
<a name="ReferenceCount">
<h4>6.6.2. Reference Count</h4>
</a>
<p>The library maintains for each object a count of the number of
hard links that have the object as their target. This is the
reference count. When the object is created, a hard link is also
created, and the reference count for the object is set to one. The
reference count for an object is incremented or decremented each time
a hard link with the object as the target is created or deleted. If an
object becomes the target of a symbolic link, the reference count will
not be changed. Objects that have a reference count of zero are eligible
for deletion. If the reference count goes to zero, the library does not
immediately remove the object. The object will be removed during the
next running of the <code>h5repack</code> tool. For more information on
the reference count, see the <code>H5Oincr_refcount</code> function call
in the <a href="../RM/RM_H5Front.html" target="RMwindow">
<cite>HDF5 Reference Manual</cite></a>. </p>
<a name="IdentifiersAndLinkPaths">
<h4>6.6.3. Identifiers and Link Paths</h4>
</a>
<p>Identifiers are generated and returned to an application when a
group or file is created or opened. Identifiers are then used in the
<code>loc_id</code> parameter along with link paths in the
<code>name</code> parameter of function calls to create or open other
groups and links. Link paths can be either absolute or relative. The
purpose of this section is to describe the possible kinds of identifiers
and the appropriate link path type for each kind of identifier. </p>
<p><b>File identifier and absolute link path.</b> When a file is created
or opened by an application, a file identifier is returned. When the
file identifier is used in a function call, the name parameter should
specify an absolute link path. With the file identifier and an absolute
link path, the function call will be able to identify the file to work
on and the location of the object from the root group. To operate on
the root group, use a file identifier and a slash, <code>/</code>. </p>
<p><b>Group identifer and relative link path.</b> When a group is created
or opened, a group identifier is returned. When the group identifier is
used in a function call, the <code>name</code> parameter can specify
either a relative link path or an absolute link path. With the group
identifier and a relative link path, the function call will be able
to identify the group and the location of the object from the group.
With the group identifier and an absolute link path, the function
call will be able to identify the file to work on and the location
of the object from the root group.</p>
<p><b>Any identifier and absolute link path.</b> With any identifier
and an absolute link path, a function call can create or open a group
or link that is not connected to the identifier. The function call
uses the identifier to specify the file to work in and uses the
absolute link path to specify the link to the created or opened
group or dataset from the root group.</p>
<table align="center" width="500" class="greenframe2">
<tr ><td>
<p><b>Programming reminder</b></p>
<p>An application should track every identifier that has been
returned to it. When the application is finished using the resource
that is associated with the identifier, the identifier should be
released by closing the resource. For example, use
<code>H5Gclose</code> to close a group, or use <code>H5Oclose</code>
to close an object. See <a href="#ClosingAGroup">“Closing a
Group”</a> for more information. </p>
</td>
</tr>
</table>
<a name="MovingOrRenamingAnObject">
<h4>6.6.4. Moving or Renaming an Object</h4>
</a>
<p>When we talk about renaming or moving an object, we do not actually
rename or move the object. An object does not have a name: the name
comes from a link. An object cannot be moved. When the object is created,
it is put in a permanent location in the file. What changes is the
link path to the object. </p>
<p>One way to rename or move an object is to use the
<code>H5Lmove</code> function call. This function call will delete the
existing link and create a new link in one operation. </p>
<p>Another way to rename or move an object is to use the
<code>H5Ldelete</code> function call and one of the
<code>H5Lcreate_*</code> function calls. These function calls will delete
the existing link and create a new link. </p>
<p>Exercise caution in the use of <code>H5Lmove</code> and
<code>H5Ldelete</code> as these functions each include a step that
deletes a link to an object. If the link that is removed is the only
hard link to the object, that object will become permanently inaccessible
in the file. </p>
<p>Scenario 1: Removing the last link</p>
<p>To avoid removing the last link to an object or otherwise making an
object inaccessible, use the <code>H5Oget_info</code>
function. Confirm that the value of the reference count field (rc) is
greater than 1. </p>
<p>Scenario 2: Moving a link that isolates an object</p>
<p>Consider the following example. Assume that the group that is the
target of the <code>group2</code> link can only be accessed via the
following absolute link path: <code>/top_group/group1/group2/</code>.</p>
<p>Suppose <code>H5Lmove</code> is used to move <code>top_group</code>
to the group that is the target of the <code>group2</code> link.
Since <code>top_group</code> was the only route from the root group to
<code>group1</code> (the group that is the target of the
<code>group1</code> link), there is no longer a path by which we can access
<code>group1</code>, <code>group2</code>, or any member datasets.
And since <code>top_group</code> is now a member of <code>group2</code>,
<code>top_group</code> itself and any member datasets have thereby also
become inaccessible.</p>
<p>For more information on any of these functions, see the
<a href="../RM/RM_H5Front.html" target="RMwindow"><cite>HDF5
Reference Manual</cite></a>.</p>
<a name="StrongAndWeakLinks">
<h4>6.6.5. Strong and Weak Links</h4>
</a>
<p>Hard links have a physical address in a file and are kept track of
through the reference count. Symbolic links are known by name and
do not effect the reference count for an object. User-defined links
blur this neat division of links into hard and symbolic types. A
user-defined link might be built so that it changes the reference
count like a hard link and so that it can dangle like a symbolic link.</p>
<p>In addition to hard and symbolic links, it might be also be useful
to think about links as being strong or weak. A strong link effects
the reference count of an object. Deleting the last strong link would
make the object inaccessible. A hard link would be a strong link as
would any user-defined link that effected the reference count. A weak
link does not effect the reference count of an object. A weak link
would be more flexible and ambiguous like symbolic links. </p>
<!-- HEADER RIGHT " " -->
</body>
</html>
|