The HDF5 Packet Table API is designed to allow records to be appended to and read from a table. Packet Table datasets are chunked, allowing them to grow as needed.
The Packet Table API, with the H5PT prefix, is not to be confused with the H5TB Table API (H5TB prefix). The H5TB APIs are stateless (H5TB Tables do not need to be opened or closed) but H5PT Packet Tables require less performance overhead. Also, H5TB Tables support insertions and deletions, while H5PT Packet Tables support only append operations. H5TB functions should not be called on tables created with the H5PT API, or vice versa.
Packet Tables are datasets in an HDF5 file, so while their contents
should not be changed outside of the H5PT API calls, the datatypes
of Packet Tables can be queried using
H5Dget_type.
Packet Tables can also be given attributes using the normal HDF5 APIs.
The following functions are part of the HDF5 Packet Table API.
Programming Hint:
The following line includes the HDF5 Packet Table package, H5PT,
in C applications:
#include "hdf5_hl.h"
Without this include, an application will not have access to
these functions.
The C Interfaces:
|
Creation and Opening Storage Table Index |
Retrieval Query |
H5PTcreate_fl creates and opens a
packet table named dset_name attached to
the object specified by the identifier loc_id.
It should be closed with H5PTclose.
The datatype, dtype_id, may specify
any datatype, including variable-length data.
If dtype_id specifies a compound datatype,
one or more fields in that compound type may be variable-length.
loc_id dset_name dtype_id chunk_size compression 0 through 9.
Level 0 is faster but offers the least compression;
level 9 is slower but offers maximum compression.
A setting of -1 indicates that no compression
is desired.H5PTopen opens an existing packet table in the file
or group specified by loc_id. dset_name is the name
of the packet table and is used to identify it in the file. This function is
used to open both fixed-length packet tables and variable-length packet tables.
The packet table should later be closed with H5PTclose. loc_id dset_name H5PTclose ends access to a packet table specified by
table_id. table_id H5PTappend writes nrecords packets to the end
of a packet table specified by table_id. data
is a buffer containing the data to be written. For a packet table
holding fixed-length packets, this data should be in the packet table's
datatype. For a variable-length packet table, the data should be in the
form of hvl_t structs. table_id nrecords data get_next can iterate through the packets in
order. H5PTcreate_index initializes a packet
table's index, and should be called before using
get_next.
The index must be initialized every time a packet table is created
or opened; this information is lost when the packet table is closed. table_id get_next can iterate through the packets in
order. H5PTset_index sets this index to point
to a user-specified packet (the packets are zero-indexed). table_id index H5PTread_packets reads nrecords packets starting
at packet number start from a packet table specified by
table_id. data is a buffer into which the
data should be read.hvl_t structs, each
containing the length of the data and a pointer to it in memory.
table_id start nrecords data H5PTread_packets reads nrecords packets
starting with the "current index" from a packet table
specified by table_id. The packet table's index
is set and reset with H5PTset_index and
H5PTcreate_index.
data is a buffer into which the data should
be read.
For a packet table holding variable-length records, the data returned
in the buffer will be in form of a hvl_t struct
containing the length of the data and a pointer to it in memory.
table_id nrecords data H5PTget_num_packets returns by reference the
number of packets in a packet table specified by
table_id. table_id nrecords H5PTis_valid returns a non-negative value if
table_id corresponds to an open packet table,
and returns a negative value otherwise. table_id table_id is a valid packet table, otherwise returns a negative value.