This class gets used by SparseFieldIO and SparseFileManager to read the block data. On creation it will open the data set and not close it until the object is destroyed.
More...
#include <SparseDataReader.h>
|
void | readBlock (int idx, Data_T &result) |
| Reads a block, storing the data in result, which is assumed to contain enough room for m_valuesPerBlock entries. More...
|
|
void | readBlockList (int idx, const std::vector< Data_T * > &memoryList) |
| Reads a series of blocks, storing each block of data in memoryList, which is assumed to contain enough room for m_valuesPerBlock entries. More...
|
|
| SparseDataReader (hid_t location, int valuesPerBlock, int occupiedBlocks) |
| Constructor. Requires knowledge of the Hdf5 location where data is stored. More...
|
|
template<class Data_T>
class SparseDataReader< Data_T >
This class gets used by SparseFieldIO and SparseFileManager to read the block data. On creation it will open the data set and not close it until the object is destroyed.
Definition at line 70 of file SparseDataReader.h.
◆ SparseDataReader()
Constructor. Requires knowledge of the Hdf5 location where data is stored.
Definition at line 107 of file SparseDataReader.h.
const std::string k_dataStr
◆ readBlock()
Reads a block, storing the data in result, which is assumed to contain enough room for m_valuesPerBlock entries.
Definition at line 120 of file SparseDataReader.h.
137 if (dataSet.
id() < 0)
138 throw OpenDataSetException(
"Couldn't open data set: " +
k_dataStr);
141 fileDataSpace.
open(dataSet.
id());
142 dataType.
open(dataSet.
id());
143 if (fileDataSpace.
id() < 0)
144 throw GetDataSpaceException(
"Couldn't get data space");
145 if (dataType.
id() < 0)
146 throw GetDataTypeException(
"Couldn't get data type");
150 memDataSpace.
create(H5S_SIMPLE);
151 H5Sset_extent_simple(memDataSpace.
id(), 1, memDims, NULL);
154 H5Sget_simple_extent_dims(fileDataSpace.
id(), dims, NULL);
156 throw FileIntegrityException(
"Block length mismatch in "
160 throw FileIntegrityException(
"Block count mismatch in "
172 status = H5Sselect_hyperslab(fileDataSpace.
id(), H5S_SELECT_SET,
173 offset, NULL, count, NULL);
176 throw ReadHyperSlabException(
"Couldn't select slab in readBlock(): " +
177 boost::lexical_cast<std::string>(idx));
181 memDataSpace.
id(), fileDataSpace.
id(),
182 H5P_DEFAULT, &result);
FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
boost::recursive_mutex::scoped_lock GlobalLock
hid_t id() const
Query the hid_t value.
Scoped object - opens a dataset on creation and closes it on destruction.
void open(hid_t dataset_id)
Scoped object - opens a dataset on creation and closes it on destruction.
void open(hid_t dataset_id)
Scoped object - opens a dataset on creation and closes it on destruction.
void open(hid_t parentLocation, const std::string &name, hid_t dapl_id)
Scoped object - creates a dataspace on creation and closes it on destruction.
void create(H5S_class_t type)
Namespace for Exception objects.
Contains utility functions and classes for Hdf5 files.
References Hdf5Util::H5ScopedScreate::create(), g_hdf5Mutex, Hdf5Util::H5Base::id(), Hdf5Util::H5ScopedDget_space::open(), Hdf5Util::H5ScopedDget_type::open(), and Hdf5Util::H5ScopedDopen::open().
◆ readBlockList()
template<class Data_T >
void SparseDataReader< Data_T >::readBlockList |
( |
int |
idx, |
|
|
const std::vector< Data_T * > & |
memoryList |
|
) |
| |
Reads a series of blocks, storing each block of data in memoryList, which is assumed to contain enough room for m_valuesPerBlock entries.
Definition at line 188 of file SparseDataReader.h.
206 if (dataSet.
id() < 0)
207 throw OpenDataSetException(
"Couldn't open data set: " +
k_dataStr);
210 fileDataSpace.
open(dataSet.
id());
211 dataType.
open(dataSet.
id());
212 if (fileDataSpace.
id() < 0)
213 throw GetDataSpaceException(
"Couldn't get data space");
214 if (dataType.
id() < 0)
215 throw GetDataTypeException(
"Couldn't get data type");
219 memDataSpace.
create(H5S_SIMPLE);
220 H5Sset_extent_simple(memDataSpace.
id(), 1, memDims, NULL);
223 H5Sget_simple_extent_dims(fileDataSpace.
id(), dims, NULL);
225 throw FileIntegrityException(
"Block length mismatch in "
229 throw FileIntegrityException(
"Block count mismatch in "
238 count[0] = memoryList.size();
241 status = H5Sselect_hyperslab(fileDataSpace.
id(), H5S_SELECT_SET,
242 offset, NULL, count, NULL);
244 throw ReadHyperSlabException(
"Couldn't select slab in readBlockList():" +
245 boost::lexical_cast<std::string>(idxLo));
252 fileDims[0] = memoryList.size();
254 localMemDataSpace.
create(H5S_SIMPLE);
255 H5Sset_extent_simple(localMemDataSpace.
id(), 2, fileDims, NULL);
259 int bytesPerValue = 0;
262 if (t == H5T_NATIVE_CHAR)
264 else if (t == H5T_NATIVE_SHORT)
266 else if (t == H5T_NATIVE_FLOAT)
268 else if (t == H5T_NATIVE_DOUBLE)
272 int dim =
sizeof(Data_T) / bytesPerValue;
275 status = H5Dread(dataSet.
id(),
277 localMemDataSpace.
id(),
279 H5P_DEFAULT, &bigblock[0]);
282 throw Hdf5DataReadException(
"Couldn't read slab " +
283 boost::lexical_cast<std::string>(idxLo));
287 for (
size_t i = 0; i < memoryList.size(); ++i) {
288 memcpy(memoryList[i],
References Hdf5Util::H5ScopedScreate::create(), g_hdf5Mutex, DataTypeTraits< T >::h5type(), Hdf5Util::H5Base::id(), Hdf5Util::H5ScopedDget_space::open(), Hdf5Util::H5ScopedDget_type::open(), and Hdf5Util::H5ScopedDopen::open().
◆ m_location
◆ m_valuesPerBlock
◆ m_occupiedBlocks
◆ k_dataStr
The documentation for this class was generated from the following file: