44 #ifndef _INCLUDED_Field3D_SparseDataReader_H_ 45 #define _INCLUDED_Field3D_SparseDataReader_H_ 68 template <
class Data_T>
87 void readBlockList(
int idx,
const std::vector<Data_T*>& memoryList);
107 template <
class Data_T>
124 throw OpenDataSetException(
"Couldn't open data set: " +
k_dataStr);
130 throw GetDataSpaceException(
"Couldn't get data space");
132 throw GetDataTypeException(
"Couldn't get data type");
142 throw FileIntegrityException(
"Block length mismatch in " 145 if (dims[0] != static_cast<hsize_t>(occupiedBlocks))
146 throw FileIntegrityException(
"Block count mismatch in " 152 template <
class Data_T>
170 offset, NULL, count, NULL);
173 throw ReadHyperSlabException(
"Couldn't select slab in readBlock(): " +
174 boost::lexical_cast<std::string>(idx));
179 H5P_DEFAULT, &result);
184 template <
class Data_T>
186 (
int idxLo,
const std::vector<Data_T*>& memoryList)
199 count[0] = memoryList.size();
203 offset, NULL, count, NULL);
205 throw ReadHyperSlabException(
"Couldn't select slab in readBlockList():" +
206 boost::lexical_cast<std::string>(idxLo));
213 memDims[0] = memoryList.size();
215 localMemDataSpace.
create(H5S_SIMPLE);
216 H5Sset_extent_simple(localMemDataSpace.
id(), 2, memDims, NULL);
220 int bytesPerValue = 0;
223 if (t == H5T_NATIVE_CHAR)
225 else if (t == H5T_NATIVE_SHORT)
227 else if (t == H5T_NATIVE_FLOAT)
229 else if (t == H5T_NATIVE_DOUBLE)
233 int dim =
sizeof(Data_T) / bytesPerValue;
238 localMemDataSpace.
id(),
240 H5P_DEFAULT, &bigblock[0]);
243 throw Hdf5DataReadException(
"Couldn't read slab " +
244 boost::lexical_cast<std::string>(idxLo));
248 for (
size_t i = 0; i < memoryList.size(); ++i) {
249 memcpy(memoryList[i],
void open(hid_t dataset_id)
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Hdf5Util::H5ScopedScreate m_memDataSpace
Contains utility functions and classes for Hdf5 files.
Scoped object - opens a dataset on creation and closes it on destruction.
Namespace for Exception objects.
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 enoug...
SparseDataReader(hid_t location, int valuesPerBlock, int occupiedBlocks)
Constructor. Requires knowledge of the Hdf5 location where data is stored.
Scoped object - opens a dataset on creation and closes it on destruction.
boost::recursive_mutex::scoped_lock GlobalLock
Contains various utility functions for Hdf5.
Hdf5Util::H5ScopedDget_space m_fileDataSpace
void open(hid_t dataset_id)
void readBlock(int idx, Data_T &result)
Reads a block, storing the data in result, which is assumed to contain enough room for m_valuesPerBlo...
const std::string k_dataStr
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.
void open(hid_t parentLocation, const std::string &name, hid_t dapl_id)
Hdf5Util::H5ScopedDget_type m_dataType
Scoped object - creates a dataspace on creation and closes it on destruction.
FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
Hdf5Util::H5ScopedDopen m_dataSet
void create(H5S_class_t type)
Scoped object - opens a dataset on creation and closes it on destruction.
hid_t id() const
Query the hid_t value.