Routines for reading/writing tables in HDF5 files.
These routines are basic routines for reading and writing tables in HDF5 files.
Prototypes | |
LALH5Dataset * | XLALH5TableAlloc (LALH5File UNUSED *file, const char UNUSED *name, size_t UNUSED ncols, const char UNUSED **cols, const LALTYPECODE UNUSED *types, const size_t UNUSED *offsets, size_t UNUSED rowsz) |
Allocates a LALH5Dataset dataset to hold a table. More... | |
int | XLALH5TableAppend (LALH5Dataset UNUSED *dset, const size_t UNUSED *offsets, const size_t UNUSED *colsz, size_t UNUSED nrows, size_t UNUSED rowsz, const void UNUSED *data) |
Appends rows of data to a LALH5Dataset dataset holding a table. More... | |
int | XLALH5TableRead (void UNUSED *data, const LALH5Dataset UNUSED *dset, const size_t UNUSED *offsets, const size_t UNUSED *colsz, size_t UNUSED rowsz) |
Reads table data from a LALH5Dataset. More... | |
int | XLALH5TableReadRows (void UNUSED *data, const LALH5Dataset UNUSED *dset, const size_t UNUSED *offsets, const size_t UNUSED *colsz, size_t UNUSED row0, size_t UNUSED nrows, size_t UNUSED rowsz) |
Reads certain rows of table data from a LALH5Dataset. More... | |
int | XLALH5TableReadColumns (void UNUSED *data, const LALH5Dataset UNUSED *dset, const char UNUSED *cols, const size_t UNUSED *offsets, const size_t UNUSED *colsz, size_t UNUSED row0, size_t UNUSED nrows, size_t UNUSED rowsz) |
Reads certain columns of table data from a LALH5Dataset. More... | |
size_t | XLALH5TableQueryNRows (const LALH5Dataset UNUSED *dset) |
Gets the number of rows in a LALH5Dataset containing table data. More... | |
size_t | XLALH5TableQueryNColumns (const LALH5Dataset UNUSED *dset) |
Gets the number of columns in a LALH5Dataset containing table data. More... | |
size_t | XLALH5TableQueryRowSize (const LALH5Dataset UNUSED *dset) |
Gets the number of bytes in a row in a LALH5Dataset containing table data. More... | |
int | XLALH5TableQueryColumnName (char UNUSED *name, size_t UNUSED size, const LALH5Dataset UNUSED *dset, int UNUSED pos) |
Gets the name of a column in a LALH5Dataset containing table data. More... | |
size_t | XLALH5TableQueryColumnSize (const LALH5Dataset UNUSED *dset, int UNUSED pos) |
Gets the size in bytes of a column in a LALH5Dataset containing table data. More... | |
LALTYPECODE | XLALH5TableQueryColumnType (const LALH5Dataset UNUSED *dset, int UNUSED pos) |
Gets the type of data stored in a column in a LALH5Dataset containing table data. More... | |
size_t | XLALH5TableQueryColumnOffset (const LALH5Dataset UNUSED *dset, int UNUSED pos) |
Gets the offset of the data in a column in a LALH5Dataset containing table data. More... | |
LALH5Dataset* XLALH5TableAlloc | ( | LALH5File UNUSED * | file, |
const char UNUSED * | name, | ||
size_t UNUSED | ncols, | ||
const char UNUSED ** | cols, | ||
const LALTYPECODE UNUSED * | types, | ||
const size_t UNUSED * | offsets, | ||
size_t UNUSED | rowsz | ||
) |
Allocates a LALH5Dataset dataset to hold a table.
This routine creates a dataset with name name
within an HDF5 file associated with the LALH5File file
structure and allocates a LALH5Dataset structure associated with the dataset. The type of data to be stored are table data comprised of rows of size rowsz
; each row having ncols
columns with names cols
, types types
, and offsets offsets
.
with the LALH5Dataset dset
and stores the data in the buffer data
. This buffer should be sufficiently large to hold the requested rows of the dataset, which is comprised of a number of rows each of size rowsz
. Each row is comprised of a number of columns which are named in the comma-separated list in string cols
. The offsets of the columns and the sizes of the columns in each row of data is provided by the arrays offsets
and colsz
respectively.
The following example shows how to create a dataset named particles in which particle data can be stored.
file | Pointer to a LALH5File in which to create the dataset. |
name | Pointer to a string with the name of the dataset to create (also the table name). |
ncols | Number of columns in each row. |
cols | Pointer to an array of strings giving the column names. |
types | Pointer to an array of LALTYPECODE values specifying the data type of each column. |
offsets | Pointer to an array of offsets for each column. |
rowsz | Size of each row of data. |
NULL | An error occurred creating the dataset. |
Definition at line 3225 of file H5FileIOLowLevel.c.
int XLALH5TableAppend | ( | LALH5Dataset UNUSED * | dset, |
const size_t UNUSED * | offsets, | ||
const size_t UNUSED * | colsz, | ||
size_t UNUSED | nrows, | ||
size_t UNUSED | rowsz, | ||
const void UNUSED * | data | ||
) |
Appends rows of data to a LALH5Dataset dataset holding a table.
This routine appends nrows
rows of data each having size rowsz
to a HDF5 table dataset associated with the LALH5Dataset structure dset
. The data is contained in data
and the offsets and sizes of each column are given by the arrays offsets
and colsz
.
The following example shows how to append rows to a dataset named particles in which particle data is stored.
dset | Pointer to a LALH5Dataset containing the table into which the rows will be appended. |
offsets | Pointer to an array of offsets for each column. |
colsz | Pointer to an array of sizes of each column. |
nrows | Number of rows of data that will be appended. |
rowsz | Size of each row of data. |
data | Pointer to a memory in which contains the data to be appended. |
0 | Success. |
-1 | Failure. |
Definition at line 3350 of file H5FileIOLowLevel.c.
int XLALH5TableRead | ( | void UNUSED * | data, |
const LALH5Dataset UNUSED * | dset, | ||
const size_t UNUSED * | offsets, | ||
const size_t UNUSED * | colsz, | ||
size_t UNUSED | rowsz | ||
) |
Reads table data from a LALH5Dataset.
This routine reads the table data from a HDF5 dataset associated with the LALH5Dataset dset
and stores the data in the buffer data
. This buffer should be sufficiently large to hold the entire contents of the dataset, which is comprised of a number of rows each of size rowsz
. The number of rows can be determined with the routine XLALH5TableQueryNRows(). Each row is comprised of a number of columns, which can be determined with the routine XLALH5TableQueryNColumns(). The offsets of the columns and the sizes of the columns in each row of data is provided by the arrays offsets
and colsz
respectively.
The following example shows how to read the data from a table named particles.
data | Pointer to a memory in which to store the data. |
dset | Pointer to a LALH5Dataset from which to extract the data. |
offsets | Pointer to an array of offsets for each column. |
colsz | Pointer to an array of sizes of each column. |
rowsz | Size of each row of data. |
0 | Success. |
-1 | Failure. |
Definition at line 3404 of file H5FileIOLowLevel.c.
int XLALH5TableReadRows | ( | void UNUSED * | data, |
const LALH5Dataset UNUSED * | dset, | ||
const size_t UNUSED * | offsets, | ||
const size_t UNUSED * | colsz, | ||
size_t UNUSED | row0, | ||
size_t UNUSED | nrows, | ||
size_t UNUSED | rowsz | ||
) |
Reads certain rows of table data from a LALH5Dataset.
This routine reads certain rows of table data from a HDF5 dataset associated with the LALH5Dataset dset
and stores the data in the buffer data
. This buffer should be sufficiently large to hold the requested nrows
rows of the dataset, starting with row row0
(the first row is row 0), which is comprised of a number of rows each of size rowsz
. Each row is comprised of a number of columns, which can be determined with the routine XLALH5TableQueryNColumns(). The offsets of the columns and the sizes of the columns in each row of data is provided by the arrays offsets
and colsz
respectively.
The following example shows how to read rows 2 to 5 inclusive (where the first row is row 0) of data from a table named particles.
data | Pointer to a memory in which to store the data. |
dset | Pointer to a LALH5Dataset from which to extract the data. |
offsets | Pointer to an array of offsets for each column. |
colsz | Pointer to an array of sizes of each column. |
row0 | The first row to read. |
nrows | The Number of rows to read. |
rowsz | Size of each row of data. |
0 | Success. |
-1 | Failure. |
Definition at line 3461 of file H5FileIOLowLevel.c.
int XLALH5TableReadColumns | ( | void UNUSED * | data, |
const LALH5Dataset UNUSED * | dset, | ||
const char UNUSED * | cols, | ||
const size_t UNUSED * | offsets, | ||
const size_t UNUSED * | colsz, | ||
size_t UNUSED | row0, | ||
size_t UNUSED | nrows, | ||
size_t UNUSED | rowsz | ||
) |
Reads certain columns of table data from a LALH5Dataset.
This routine reads certain columns of table data from a HDF5 dataset associated with the LALH5Dataset dset
and stores the data in the buffer data
. This buffer should be sufficiently large to hold the requested rows of the dataset, which is comprised of a number of rows each of size rowsz
. Each row is comprised of a number of columns which are named in the comma-separated list in string cols
. The offsets of the columns and the sizes of the columns in each row of data is provided by the arrays offsets
and colsz
respectively.
The following example shows how to read rows 2 to 5 inclusive (where the first row is row 0) of certain columns of data from a table named particles.
data | Pointer to a memory in which to store the data. |
dset | Pointer to a LALH5Dataset from which to extract the data. |
cols | Pointer to an string listing the column names separated by commas. |
offsets | Pointer to an array of offsets for each column. |
colsz | Pointer to an array of sizes of each column. |
row0 | The first row to read. |
nrows | The Number of rows to read. |
rowsz | Size of each row of data. |
0 | Success. |
-1 | Failure. |
Definition at line 3519 of file H5FileIOLowLevel.c.
size_t XLALH5TableQueryNRows | ( | const LALH5Dataset UNUSED * | dset | ) |
Gets the number of rows in a LALH5Dataset containing table data.
dset | Pointer to a LALH5Dataset containing table data to be queried. |
(size_t)(-1) | Failure. |
Definition at line 3541 of file H5FileIOLowLevel.c.
size_t XLALH5TableQueryNColumns | ( | const LALH5Dataset UNUSED * | dset | ) |
Gets the number of columns in a LALH5Dataset containing table data.
dset | Pointer to a LALH5Dataset containing table data to be queried. |
(size_t)(-1) | Failure. |
Definition at line 3565 of file H5FileIOLowLevel.c.
size_t XLALH5TableQueryRowSize | ( | const LALH5Dataset UNUSED * | dset | ) |
Gets the number of bytes in a row in a LALH5Dataset containing table data.
dset | Pointer to a LALH5Dataset containing table data to be queried. |
(size_t)(-1) | Failure. |
Definition at line 3590 of file H5FileIOLowLevel.c.
int XLALH5TableQueryColumnName | ( | char UNUSED * | name, |
size_t UNUSED | size, | ||
const LALH5Dataset UNUSED * | dset, | ||
int UNUSED | pos | ||
) |
Gets the name of a column in a LALH5Dataset containing table data.
This routines gets the name of a column of data in a LALH5Dataset dset
that contains table data. The index pos
identifies which column's name is returned. The result is written into the buffer pointed to by name
, the size of which is size
bytes. If name
is NULL, no data is copied but the routine returns the length of the string. Therefore, this routine can be called once to determine the amount of memory required, the memory can be allocated, and then it can be called a second time to read the string. If the parameter size
is less than or equal to the string length then only $p size-1 bytes of the string are copied to the buffer name
.
name
should be allocated to be one byte larger. name | Pointer to a buffer into which the string will be written. |
size | Size in bytes of the buffer into which the string will be written. |
dset | Pointer to a LALH5Dataset containing table data to be queried. |
pos | The index identifying which column of the table. |
0 | Success. |
-1 | Failure. |
Definition at line 3634 of file H5FileIOLowLevel.c.
size_t XLALH5TableQueryColumnSize | ( | const LALH5Dataset UNUSED * | dset, |
int UNUSED | pos | ||
) |
Gets the size in bytes of a column in a LALH5Dataset containing table data.
dset | Pointer to a LALH5Dataset containing table data to be queried. |
pos | The index identifying which column of the table. |
-1 | Failure. |
Definition at line 3673 of file H5FileIOLowLevel.c.
LALTYPECODE XLALH5TableQueryColumnType | ( | const LALH5Dataset UNUSED * | dset, |
int UNUSED | pos | ||
) |
Gets the type of data stored in a column in a LALH5Dataset containing table data.
dset | Pointer to a LALH5Dataset containing table data to be queried. |
pos | The index identifying which column of the table. |
LALTYPECODE
of the datatype of the specified column entry in the HDF5 dataset associated with the specified LALH5Dataset. -1 | Failure. |
Definition at line 3727 of file H5FileIOLowLevel.c.
size_t XLALH5TableQueryColumnOffset | ( | const LALH5Dataset UNUSED * | dset, |
int UNUSED | pos | ||
) |
Gets the offset of the data in a column in a LALH5Dataset containing table data.
dset | Pointer to a LALH5Dataset containing table data to be queried. |
pos | The index identifying which column of the table. |
(size_t)(-1) | Failure. |
Definition at line 3769 of file H5FileIOLowLevel.c.