Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/
HDF5 Last Updated on 2025-12-16
The HDF5 Field Guide
Loading...
Searching...
No Matches
HDF5 Objects

Navigate back: Main / HDF5 User Guide


The HDF5 Object Interface

Introduction

The HDF5 Object interface (H5O) provides functions for managing HDF5 objects at a generic level. While specific object types (groups, datasets, datatypes) have their own interfaces (Groups (H5G), Datasets (H5D), Datatypes (H5T)), the H5O interface enables operations that apply to all object types uniformly.

See also
Objects (H5O) Reference Manual

Object Operations

The H5O interface provides several categories of operations:

  • Object Copying: Copy objects between locations or files using H5Ocopy. This creates a complete copy of the source object including all its attributes and, for groups, can optionally copy contained objects recursively.
  • Object Linking: Create links to objects using H5Olink, enabling multiple names to reference the same object.

Object Traversal

The H5O interface provides powerful traversal capabilities:

  • H5Ovisit recursively visits all objects in a group hierarchy
  • H5Ovisit_by_name performs recursive visitation starting from a named location

These functions invoke a user-supplied callback for each object encountered, enabling custom processing, cataloging, or analysis of file contents.

Object Comments

Objects can have associated comment strings for documentation purposes:

Reference Counting

HDF5 uses reference counting to manage object lifetimes. The library automatically deletes objects when their reference count reaches zero:

Attention
Manual manipulation of reference counts should be used with extreme caution. Improper use can lead to memory leaks or premature object deletion.

Cache Control

For performance optimization, the H5O interface provides cache management functions:

  • H5Orefresh reloads object metadata from disk, discarding cached data
  • H5Oflush writes object metadata to disk immediately

These functions are particularly useful in SWMR (Single Writer Multiple Reader) scenarios.

Summary

The H5O interface provides essential generic object operations:

  • Query object metadata and properties across all object types
  • Copy objects within and between HDF5 files
  • Traverse object hierarchies with custom processing
  • Manage object comments for documentation
  • Control object caching and persistence

Navigate back: Main / HDF5 User Guide