Utility used for reading portions of an HDF5 dataset. More...
#include <ReadHDF5Dataset.hpp>
Classes | |
class | Exception |
Public Types | |
typedef int | Comm |
Public Member Functions | |
ReadHDF5Dataset (const char *debug_desc, hid_t data_set_handle, bool parallel, const Comm *communicator=0, bool close_data_set_on_destruct=true) | |
Setup to read entire table. More... | |
ReadHDF5Dataset (const char *debug_desc, bool parallel, const Comm *communicator=0) | |
void | init (hid_t data_set_handle, bool close_data_set_on_destruct=true) |
bool | will_close_data_set () const |
void | close_data_set_on_destruct (bool val) |
~ReadHDF5Dataset () | |
void | set_file_ids (const Range &file_ids, EntityHandle start_id, hsize_t row_cout, hid_t data_type) |
Change file ids to read from. More... | |
void | set_all_file_ids (hsize_t row_count, hid_t data_type) |
Read all values in dataset (undo set_file_ids) More... | |
bool | done () const |
Return false if more data to read, true otherwise. More... | |
void | read (void *buffer, size_t &rows_read) |
Read rows of table. More... | |
Range::const_iterator | next_file_id () const |
Return position in Range of file IDs at which next read will start. More... | |
void | null_read () |
Do null read operation. More... | |
unsigned | columns () const |
void | set_column (unsigned c) |
unsigned long | get_read_count () const |
const char * | get_debug_desc () const |
Static Public Member Functions | |
static void | set_hyperslab_selection_limit (size_t val) |
static void | default_hyperslab_selection_limit () |
static void | append_hyperslabs () |
static void | or_hyperslabs () |
Private Member Functions | |
Range::const_iterator | next_end (Range::const_iterator iter) |
Private Attributes | |
Range | internalRange |
used when reading entire dataset More... | |
bool | closeDataSet |
close dataset in destructor More... | |
hsize_t | dataSetOffset [64] |
hsize_t | dataSetCount [64] |
hid_t | dataSet |
Handle for HDF5 data set. More... | |
hid_t | dataSpace |
Data space for data set. More... | |
hid_t | dataType |
Data type client code wants for data. More... | |
hid_t | fileType |
Data type as stored in data set. More... | |
hid_t | ioProp |
Used to specify collective IO. More... | |
int | dataSpaceRank |
Rank of data set. More... | |
hsize_t | rowsInTable |
Total number of rows in dataset. More... | |
bool | doConversion |
True if dataType != fileType. More... | |
bool | nativeParallel |
If true then reading different data on different procs. More... | |
hsize_t | readCount |
Number of actual reads to do. More... | |
hsize_t | bufferSize |
size of buffer passed to read , in number of rows More... | |
const Comm * | mpiComm |
Range::const_iterator | currOffset |
Range::const_iterator | rangeEnd |
EntityHandle | startID |
std::string | mpeDesc |
Static Private Attributes | |
static bool | haveMPEEvents = false |
static std::pair< int, int > | mpeReadEvent |
static std::pair< int, int > | mpeReduceEvent |
static size_t | hyperslabSelectionLimit = DEFAULT_HYPERSLAB_SELECTION_LIMIT |
static H5S_seloper_t | hyperslabSelectOp = H5S_SELECT_OR |
Utility used for reading portions of an HDF5 dataset.
Implement iterative read of table where:
NOTE: This class also implements an RAII pattern for the data set handle: It will close the data set in its destructor unless it is specified to the constructor that only a single column should be read.
NOTE: This class will always do collective IO for parallel reads.
Definition at line 38 of file ReadHDF5Dataset.hpp.
typedef int moab::ReadHDF5Dataset::Comm |
Definition at line 44 of file ReadHDF5Dataset.hpp.
moab::ReadHDF5Dataset::ReadHDF5Dataset | ( | const char * | debug_desc, |
hid_t | data_set_handle, | ||
bool | parallel, | ||
const Comm * | communicator = 0 , |
||
bool | close_data_set_on_destruct = true |
||
) |
Setup to read entire table.
data_set_handle | The HDF5 DataSet to read. |
parallel | Doing true partial-read parallel read (as opposed to read and delete where collective IO is done for everything because all procs read the same stuff.) |
communictor | If parallel is true and io_prop is H5FD_MPIO_COLLECTIVE , then this must be a pointer to the MPI_Communicator value. |
close_data_set_on_destruct | Call H5Dclose on passed data_set_handle in desturctor. |
\NOTE If parallel
is true
and io_prop
is H5FD_MPIO_COLLECTIVE
, then not only must communicator
be non-null, but this call must be made collectively!
\NOTE Class instance will not be usable until one of either set_file_ids
or set_all_file_ids
is called.
Definition at line 85 of file ReadHDF5Dataset.cpp.
References moab::allocate_mpe_state(), haveMPEEvents, init(), ioProp, mpeReadEvent, mpeReduceEvent, mpiComm, and nativeParallel.
moab::ReadHDF5Dataset::ReadHDF5Dataset | ( | const char * | debug_desc, |
bool | parallel, | ||
const Comm * | communicator = 0 |
||
) |
Definition at line 60 of file ReadHDF5Dataset.cpp.
References moab::allocate_mpe_state(), haveMPEEvents, ioProp, mpeReadEvent, mpeReduceEvent, mpiComm, and nativeParallel.
moab::ReadHDF5Dataset::~ReadHDF5Dataset | ( | ) |
Definition at line 231 of file ReadHDF5Dataset.cpp.
References closeDataSet, dataSet, dataSpace, fileType, and ioProp.
|
inlinestatic |
Use non-standard 'APPEND' operation for hyperslab selection
Definition at line 166 of file ReadHDF5Dataset.hpp.
References hyperslabSelectOp.
Referenced by moab::ReadHDF5::set_up_read().
|
inline |
Definition at line 85 of file ReadHDF5Dataset.hpp.
References closeDataSet.
unsigned moab::ReadHDF5Dataset::columns | ( | ) | const |
Definition at line 137 of file ReadHDF5Dataset.cpp.
References dataSetCount, and dataSpaceRank.
Referenced by read().
|
static |
Definition at line 33 of file ReadHDF5Dataset.cpp.
References moab::DEFAULT_HYPERSLAB_SELECTION_LIMIT, and hyperslabSelectionLimit.
Referenced by moab::ReadHDF5::set_up_read().
|
inline |
Return false if more data to read, true otherwise.
Test if the iterative read has reached the end.
Definition at line 116 of file ReadHDF5Dataset.hpp.
References currOffset, rangeEnd, and readCount.
Referenced by moab::ReadHDF5VarLen::read_data(), moab::ReadHDF5::read_dense_tag(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5VarLen::read_offsets(), moab::ReadHDF5::read_set_data(), moab::ReadHDF5::read_sparse_tag(), moab::ReadHDF5::read_sparse_tag_indices(), and moab::ReadHDF5::read_tag_values_partial().
|
inline |
Definition at line 154 of file ReadHDF5Dataset.hpp.
References mpeDesc.
Referenced by moab::ReadHDF5VarLen::read_data(), moab::ReadHDF5VarLen::read_offsets(), and moab::ReadHDF5::read_set_data().
|
inline |
Definition at line 150 of file ReadHDF5Dataset.hpp.
References readCount.
Referenced by moab::ReadHDF5VarLen::read_data(), moab::ReadHDF5::read_dense_tag(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5VarLen::read_offsets(), moab::ReadHDF5::read_sparse_tag(), moab::ReadHDF5::read_sparse_tag_indices(), and moab::ReadHDF5::read_tag_values_partial().
void moab::ReadHDF5Dataset::init | ( | hid_t | data_set_handle, |
bool | close_data_set_on_destruct = true |
||
) |
Definition at line 116 of file ReadHDF5Dataset.cpp.
References closeDataSet, currOffset, dataSet, dataSetCount, dataSetOffset, dataSpace, dataSpaceRank, moab::Range::end(), fileType, internalRange, rangeEnd, and rowsInTable.
Referenced by moab::ReadHDF5::read_set_ids_recursive(), and ReadHDF5Dataset().
|
private |
Definition at line 154 of file ReadHDF5Dataset.cpp.
References bufferSize, moab::Range::const_iterator::end_of_block(), hyperslabSelectionLimit, and rangeEnd.
Referenced by read(), and set_file_ids().
|
inline |
Return position in Range
of file IDs at which next read will start.
Definition at line 132 of file ReadHDF5Dataset.hpp.
References currOffset.
void moab::ReadHDF5Dataset::null_read | ( | ) |
Do null read operation.
Do a read call requesting no data. This functionality is provided so as to allow collective IO when not all processes need to make the same number of read calls. To prevent deadlock in this case, processes that have finished their necessary read calls can call this function so that all processes are calling the read method collectively.
Definition at line 297 of file ReadHDF5Dataset.cpp.
References dataSet, dataSpace, fileType, and ioProp.
Referenced by read(), and moab::ReadHDF5::read_set_data().
|
inlinestatic |
Revert to default select behavior for standard HDF5 library
Definition at line 171 of file ReadHDF5Dataset.hpp.
References hyperslabSelectOp.
void moab::ReadHDF5Dataset::read | ( | void * | buffer, |
size_t & | rows_read | ||
) |
Read rows of table.
Read up to max_num_rows from data set.
buffer | Memory in which to store values read from data set |
rows_read | The actual number of rows read from the table. Will never exceed max_rows . |
Definition at line 240 of file ReadHDF5Dataset.cpp.
References buffer, columns(), currOffset, dataSet, dataSetCount, dataSetOffset, dataSpace, dataSpaceRank, dataType, doConversion, moab::Range::const_iterator::end_of_block(), fileType, hyperslabSelectOp, ioProp, MPE_Log_event, mpeDesc, mpeReadEvent, next_end(), null_read(), rangeEnd, readCount, and startID.
Referenced by moab::ReadHDF5VarLen::read_data(), moab::ReadHDF5::read_dense_tag(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5VarLen::read_offsets(), moab::ReadHDF5::read_set_data(), moab::ReadHDF5::read_sparse_tag(), moab::ReadHDF5::read_sparse_tag_indices(), and moab::ReadHDF5::read_tag_values_partial().
void moab::ReadHDF5Dataset::set_all_file_ids | ( | hsize_t | row_count, |
hid_t | data_type | ||
) |
Read all values in dataset (undo set_file_ids)
row_count | Read buffer size in number of table rows. |
data_type | The data type of the buffer into which table values are to be read. |
Definition at line 224 of file ReadHDF5Dataset.cpp.
References moab::Range::clear(), moab::Range::insert(), internalRange, rowsInTable, and set_file_ids().
Referenced by moab::ReadHDF5::read_sparse_tag_indices(), and moab::ReadHDF5::read_tag_values_partial().
void moab::ReadHDF5Dataset::set_column | ( | unsigned | c | ) |
Definition at line 147 of file ReadHDF5Dataset.cpp.
References dataSetCount, dataSetOffset, and dataSpaceRank.
Referenced by moab::ReadHDF5::read_nodes().
void moab::ReadHDF5Dataset::set_file_ids | ( | const Range & | file_ids, |
EntityHandle | start_id, | ||
hsize_t | row_cout, | ||
hid_t | data_type | ||
) |
Change file ids to read from.
file_ids | List of rows to read from dataset |
start_id | Rows of dataset are enumerating beginning with this value. Thus the offset row to be read from dataset will be file_ids.begin() - start_id . |
row_count | Read buffer size in number of table rows. |
data_type | The data type of the buffer into which table values are to be read. |
Definition at line 174 of file ReadHDF5Dataset.cpp.
References moab::Range::begin(), bufferSize, currOffset, dataType, doConversion, moab::Range::end(), fileType, MPE_Log_event, mpeDesc, mpeReduceEvent, mpiComm, nativeParallel, next_end(), rangeEnd, readCount, and startID.
Referenced by moab::ReadHDF5VarLen::read_data(), moab::ReadHDF5::read_dense_tag(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5VarLen::read_offsets(), moab::ReadHDF5::read_set_data(), moab::ReadHDF5::read_sparse_tag(), moab::ReadHDF5::read_tag_values_partial(), and set_all_file_ids().
|
inlinestatic |
Definition at line 159 of file ReadHDF5Dataset.hpp.
References hyperslabSelectionLimit.
Referenced by moab::ReadHDF5::set_up_read().
|
inline |
Definition at line 81 of file ReadHDF5Dataset.hpp.
References closeDataSet.
|
private |
size of buffer passed to read
, in number of rows
Definition at line 194 of file ReadHDF5Dataset.hpp.
Referenced by next_end(), and set_file_ids().
|
private |
close dataset in destructor
Definition at line 181 of file ReadHDF5Dataset.hpp.
Referenced by close_data_set_on_destruct(), init(), will_close_data_set(), and ~ReadHDF5Dataset().
|
private |
Definition at line 197 of file ReadHDF5Dataset.hpp.
Referenced by done(), init(), next_file_id(), read(), and set_file_ids().
|
private |
Handle for HDF5 data set.
Definition at line 183 of file ReadHDF5Dataset.hpp.
Referenced by init(), null_read(), read(), and ~ReadHDF5Dataset().
|
private |
Definition at line 182 of file ReadHDF5Dataset.hpp.
Referenced by columns(), init(), read(), and set_column().
|
private |
Definition at line 182 of file ReadHDF5Dataset.hpp.
Referenced by init(), read(), and set_column().
|
private |
Data space for data set.
Definition at line 184 of file ReadHDF5Dataset.hpp.
Referenced by init(), null_read(), read(), and ~ReadHDF5Dataset().
|
private |
Rank of data set.
Definition at line 188 of file ReadHDF5Dataset.hpp.
Referenced by columns(), init(), read(), and set_column().
|
private |
Data type client code wants for data.
Definition at line 185 of file ReadHDF5Dataset.hpp.
Referenced by read(), and set_file_ids().
|
private |
True if dataType != fileType.
Definition at line 190 of file ReadHDF5Dataset.hpp.
Referenced by read(), and set_file_ids().
|
private |
Data type as stored in data set.
Definition at line 186 of file ReadHDF5Dataset.hpp.
Referenced by init(), null_read(), read(), set_file_ids(), and ~ReadHDF5Dataset().
|
staticprivate |
Definition at line 200 of file ReadHDF5Dataset.hpp.
Referenced by ReadHDF5Dataset().
|
staticprivate |
Definition at line 205 of file ReadHDF5Dataset.hpp.
Referenced by default_hyperslab_selection_limit(), next_end(), and set_hyperslab_selection_limit().
|
staticprivate |
Definition at line 206 of file ReadHDF5Dataset.hpp.
Referenced by append_hyperslabs(), or_hyperslabs(), and read().
|
private |
used when reading entire dataset
Definition at line 179 of file ReadHDF5Dataset.hpp.
Referenced by init(), and set_all_file_ids().
|
private |
Used to specify collective IO.
Definition at line 187 of file ReadHDF5Dataset.hpp.
Referenced by null_read(), read(), ReadHDF5Dataset(), and ~ReadHDF5Dataset().
|
private |
Definition at line 203 of file ReadHDF5Dataset.hpp.
Referenced by get_debug_desc(), read(), and set_file_ids().
|
staticprivate |
Definition at line 201 of file ReadHDF5Dataset.hpp.
Referenced by read(), and ReadHDF5Dataset().
|
staticprivate |
Definition at line 202 of file ReadHDF5Dataset.hpp.
Referenced by ReadHDF5Dataset(), and set_file_ids().
|
private |
Definition at line 195 of file ReadHDF5Dataset.hpp.
Referenced by ReadHDF5Dataset(), and set_file_ids().
|
private |
If true then reading different data on different procs.
Definition at line 191 of file ReadHDF5Dataset.hpp.
Referenced by ReadHDF5Dataset(), and set_file_ids().
|
private |
Definition at line 197 of file ReadHDF5Dataset.hpp.
Referenced by done(), init(), next_end(), read(), and set_file_ids().
|
private |
Number of actual reads to do.
Definition at line 193 of file ReadHDF5Dataset.hpp.
Referenced by done(), get_read_count(), read(), and set_file_ids().
|
private |
Total number of rows in dataset.
Definition at line 189 of file ReadHDF5Dataset.hpp.
Referenced by init(), and set_all_file_ids().
|
private |
Definition at line 198 of file ReadHDF5Dataset.hpp.
Referenced by read(), and set_file_ids().