ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
ritsuko::cvls Namespace Reference

Utilities for reading and validating compressed VLS arrays. More...

Classes

struct  Pointer
 Pointer into the compressed VLS heap. More...
 
class  Stream1dArray
 Stream a 1-dimensional compressed VLS array into memory. More...
 

Functions

template<typename Offset_ , typename Length_ >
H5::CompType define_pointer_datatype ()
 
void validate_pointer_datatype (const H5::CompType &type, const std::size_t offset_precision, const std::size_t length_precision)
 
void validate_pointer_datatype (const H5::DataSet &data, const std::size_t offset_precision, const std::size_t length_precision)
 
template<typename Offset_ , typename Length_ >
bool is_Pointer_out_of_range (const Pointer< Offset_, Length_ > &ptr, const hsize_t heap_length)
 
template<typename Offset_ , typename Length_ >
void validate_scalar_pointer (const H5::DataSet &data, hsize_t heap_length)
 
template<typename Offset_ , typename Length_ >
void validate_1d_pointers (const H5::DataSet &data, hsize_t full_length, hsize_t heap_length)
 
template<typename Offset_ , typename Length_ >
void validate_nd_pointers (const H5::DataSet &data, const std::vector< hsize_t > &dimensions, hsize_t heap_length)
 
void validate_heap (const H5::DataSet &data)
 

Detailed Description

Utilities for reading and validating compressed VLS arrays.

Function Documentation

◆ define_pointer_datatype()

template<typename Offset_ , typename Length_ >
H5::CompType ritsuko::cvls::define_pointer_datatype ( )

Define a compound datatype of a realization of a Pointer type.

Template Parameters
Offset_Unsigned integer type of the starting offset, see Pointer::offset.
Length_Unsigned integer type of the string length, see Pointer::length.
Returns
A HDF5 compound datatype.

◆ is_Pointer_out_of_range()

template<typename Offset_ , typename Length_ >
bool ritsuko::cvls::is_Pointer_out_of_range ( const Pointer< Offset_, Length_ > & ptr,
const hsize_t heap_length )
Template Parameters
Offset_Unsigned integer type of the starting offset, see Pointer::offset.
Length_Unsigned integer type of the string length, see Pointer::length.
Parameters
ptrA Pointer specifying an interval on the heap.
heap_lengthLength of the heap dataset.
Returns
Whether ptr defines an interval within the heap.

◆ validate_1d_pointers()

template<typename Offset_ , typename Length_ >
void ritsuko::cvls::validate_1d_pointers ( const H5::DataSet & data,
hsize_t full_length,
hsize_t heap_length )
inline

Validate the pointer dataset for a 1-dimensional compressed VLS array. An error is thrown if the datatype is not consistent with the expected precision of the Pointer types, or if any pointers are out of range of the associated heap dataset.

Template Parameters
Offset_Unsigned integer type for the starting offset on the heap, see Pointer::offset.
Length_Unsigned integer type for the length of the string, see Pointer::length.
Parameters
dataA HDF5 dataset. It is assumed that this dataset is 1-dimensional.
full_lengthLength of the dataset, i.e., the extent of its sole dimension.
heap_lengthLength of the heap dataset.

◆ validate_heap()

void ritsuko::cvls::validate_heap ( const H5::DataSet & data)
inline

Validate a HDF5 dataset containing the compressed VLS heap. An error is thrown if the dataset is not 1-dimensional or does not contain unsigned 8-bit integers.

Parameters
dataA HDF5 dataset. It may have any shape and its datatype may be of any class.

◆ validate_nd_pointers()

template<typename Offset_ , typename Length_ >
void ritsuko::cvls::validate_nd_pointers ( const H5::DataSet & data,
const std::vector< hsize_t > & dimensions,
hsize_t heap_length )

Check that the pointers for an N-dimensional compressed VLS array is valid. An error is thrown if the datatype is not consistent with the expected precision, or if any pointers are out of range of the associated heap dataset.

Template Parameters
Offset_Unsigned integer type for the starting offset on the heap, see Pointer::offset.
Length_Unsigned integer type for the length of the string, see Pointer::length.
Parameters
dataA non-scalar HDF5 dataset. It is assumed that this dataset has at least 1 dimension.
dimensionsDimensions of the dataset. This should be non-empty.
heap_lengthLength of the heap dataset.

◆ validate_pointer_datatype() [1/2]

void ritsuko::cvls::validate_pointer_datatype ( const H5::CompType & type,
const std::size_t offset_precision,
const std::size_t length_precision )
inline

Validate that a compound HDF5 datatype meets the expectations for storage in a Pointer instance, specifically:

  • It has exactly two members.
  • The first member is named offset and is of an integer datatype that is unsigned and has no more than than offset_precision bits.
  • The second member is named length and is of an integer datatype that is unsigned and has no more than than length_precision bits.
Parameters
typeCompound datatype, typically generated from a H5::DataSet instance.
offset_precisionMaximum number of bits in the integer type used for the start position, see Pointer::offset.
length_precisionMaximum number of bits in the integer type used for the string size, see Pointer::length.

◆ validate_pointer_datatype() [2/2]

void ritsuko::cvls::validate_pointer_datatype ( const H5::DataSet & data,
const std::size_t offset_precision,
const std::size_t length_precision )
inline

Overload of validate_pointer_datatype() that accepts a HDF5 dataset. This will throw an error if the HDF5 dataset does not use a compound datatype that satisfies validate_pointer_datatype().

Parameters
typeA HDF5 dataset. This may have any datatype.
offset_precisionMaximum number of bits in the integer type used for the start position, see Pointer::offset.
length_precisionMaximum number of bits in the integer type used for the string size, see Pointer::length.

◆ validate_scalar_pointer()

template<typename Offset_ , typename Length_ >
void ritsuko::cvls::validate_scalar_pointer ( const H5::DataSet & data,
hsize_t heap_length )
inline

Validate the pointer dataset for a compressed VLS scalar. An error is thrown if the datatype is not consistent with the expected precision of the Pointer types, or if the pointer is out of range of the associated heap dataset.

Template Parameters
Offset_Unsigned integer type for the starting offset on the heap, see Pointer::offset.
Length_Unsigned integer type for the length of the string, see Pointer::length.
Parameters
dataA HDF5 dataset. It is assumed that this dataset is scalar.
heap_lengthLength of the heap dataset.