SparseFile::Reference< Data_T > Class Template Reference

`#include <SparseFile.h>`

## Public Types

typedef Sparse::SparseBlock< Data_T > * | BlockPtrs
typedef Reference * | Ptr

## Public Member Functions

float | averageLoads () const
| Returns the average number of loads per accessed block in this file, for cache statistics.
int | blockSize (int blockIdx) const
| Returns the number of bytes used by the data in the block.
void | closeFile ()
| Closes the file. Will be re-opened as needed.
void | decBlockRef (int blockIdx)
| Decrement reference count on a block.
bool | fileIsOpen ()
| Checks if the file used by this reference is open already.
void | incBlockRef (int blockIdx)
| Increment reference count on a block, indicates the block is currently in use, so prevents it from being unloaded.
void | loadBlock (int blockIdx)
| Loads the block with the given index into memory. We don't pass in a reference to where the data should go since this is already know in the blocks data member.
long long int | memSize () const
| Memory use for the Reference.
int | numLoadedBlocks () const
| Returns the total number of blocks that are currently loaded, for statistics.
void | openFile ()
| Opens the file. This is done just before the first request to loadBlock. This is delayed so that the original file open has closed the file and doesn't cause any Hdf5 hiccups.
void | resetCacheStatistics ()
| Resets counts of total block loads.
void | setNumBlocks (int numBlocks)
| Sets the number of blocks used by the SparseField we're supporting.
int | totalLoadedBlocks () const
| Returns the total number of blocks that were ever loaded (max 1 per block, not the number of blocks), for statistics.
int | totalLoads () const
| Returns the total number of loads of the blocks of this file, for cache statistics.
void | unloadBlock (int blockIdx)
| Unloads the block with the given index from memory.
| ~Reference ()
| Destructor.

## Static Public Member Functions

static Ptr | create (const std::string a_filename, const std::string a_layerPath)
| Returns a shared pointer to a reference. Preferred way of creating References.

## Public Attributes

std::vector< int > | blockLoaded
| Whether each block is loaded. We don't use bools since vector<bool> is weird.
boost::mutex * | blockMutex
| Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-safe updates of the ref counts.
int | blockMutexSize
| Size of the mutex array. Used as modulus base.
BlockPtrs | blocks
| Pointers to each block. This is so we can go in and manipulate them as we please.
std::vector< bool > | blockUsed
| Flags of whether the blocks have been accessed since they were last considered for deallocation by the Second-chance/Clock caching system.
std::vector< int > | fileBlockIndices
| Index in file for each block.
std::string | filename
std::string | layerPath
std::vector< int > | loadCounts
| Per-block counts of the number of times each block has been loaded, for cache statistics.
int | numBlocks
int | numVoxels
int | occupiedBlocks
std::vector< int > | refCounts
| Per-block counts of the number of current references to the blocks. If a block's ref count is non-zero, then the block shouldn't be unloaded.
int | valuesPerBlock

## Private Types

typedef boost::mutex | Mutex

## Private Member Functions

Reference & | operator= (const Reference &o)
| Assignment operator. Clears ref counts and rebuilds mutex array.
| Reference (const Reference &o)
| Copy constructor. Clears ref counts and rebuilds mutex array.
| Reference (const std::string filename, const std::string layerPath)
| Constructor. Requires the filename and layer path of the field to be known.

## Private Attributes

hid_t | m_fileHandle
| Holds the Hdf5 handle to the file.
Hdf5Util::H5ScopedGopen | m_layerGroup
| Hold the group containing the data open for the duration of the Reference's existence.
Mutex | m_mutex
| Mutex to prevent two threads from modifying conflicting data.
size_t | m_numActiveBlocks
| Number of currently active blocks.
IArchivePtr | m_ogArchive
| Ogawa archive.
OgIGroupPtr | m_ogLayerGroup
| Ogawa layer group.
OgSparseDataReader< Data_T > * | m_ogReader
| Pointer to the ogawa reader. NULL at construction time. Created in openFile().
boost::shared_ptr< OgSparseDataReader< Data_T > > | m_ogReaderPtr
| Shared pointer to the ogawa reader.
OgIGroupPtr | m_ogRoot
| Ogawa archive root.
SparseDataReader< Data_T > * | m_reader
| Pointer to the reader object. NULL at construction time. Created in openFile().

## Detailed Description

template<class Data_T>
class SparseFile::Reference< Data_T >

Handles information about and block loading for a single SparseField as referenced on disk

Definition at line 105 of file SparseFile.h.

## Member Typedef Documentation

## Ptr

template<class Data_T>

typedef Reference* SparseFile::Reference< Data_T >::Ptr

Definition at line 116 of file SparseFile.h.

## BlockPtrs

template<class Data_T>

typedef Sparse::SparseBlock<Data_T>* SparseFile::Reference< Data_T >::BlockPtrs

Definition at line 120 of file SparseFile.h.

## Mutex

template<class Data_T>

typedef boost::mutex SparseFile::Reference< Data_T >::Mutex

private

Definition at line 215 of file SparseFile.h.

## Constructor & Destructor Documentation

## ~Reference()

template<class Data_T>

SparseFile::Reference< Data_T >::~Reference | ( |  | ) |

Destructor.

Definition at line 572 of file SparseFile.h.

{
closeFile();
if (m_reader) {
delete m_reader;
}
if (blockMutex)
delete [] blockMutex;
}
SparseFile::Reference::closeFile
void closeFile()
Closes the file. Will be re-opened as needed.
Definition SparseFile.h:710
SparseFile::Reference::m_reader
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition SparseFile.h:239
SparseFile::Reference::blockMutex
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition SparseFile.h:156

References blockMutex, closeFile(), and m_reader.

## Reference() [1/2]

template<class Data_T>

SparseFile::Reference< Data_T >::Reference | ( | const std::string | filename,
|  | const std::string | layerPath )

private

Constructor. Requires the filename and layer path of the field to be known.

Definition at line 559 of file SparseFile.h.

: filename(a_filename), layerPath(a_layerPath),
valuesPerBlock(-1), numVoxels(-1), numBlocks(-1), occupiedBlocks(-1),
blockMutex(NULL), m_fileHandle(-1), m_reader(NULL), m_ogReader(NULL),
m_numActiveBlocks(0)
{
/* Empty */
}
SparseFile::Reference
Definition SparseFile.h:106
SparseFile::Reference::layerPath
std::string layerPath
Definition SparseFile.h:128
SparseFile::Reference::valuesPerBlock
int valuesPerBlock
Definition SparseFile.h:129
SparseFile::Reference::filename
std::string filename
Definition SparseFile.h:127
SparseFile::Reference::numBlocks
int numBlocks
Definition SparseFile.h:131
SparseFile::Reference::m_ogReader
OgSparseDataReader< Data_T > * m_ogReader
Pointer to the ogawa reader. NULL at construction time. Created in openFile().
Definition SparseFile.h:245
SparseFile::Reference::numVoxels
int numVoxels
Definition SparseFile.h:130
SparseFile::Reference::m_fileHandle
hid_t m_fileHandle
Holds the Hdf5 handle to the file.
Definition SparseFile.h:231
SparseFile::Reference::occupiedBlocks
int occupiedBlocks
Definition SparseFile.h:132
SparseFile::Reference::m_numActiveBlocks
size_t m_numActiveBlocks
Number of currently active blocks.
Definition SparseFile.h:257

References blockMutex, filename, layerPath, m_fileHandle, m_numActiveBlocks, m_ogReader, m_reader, numBlocks, numVoxels, occupiedBlocks, and valuesPerBlock.

Referenced by create(), operator=(), and Reference().

## Reference() [2/2]

template<class Data_T>

SparseFile::Reference< Data_T >::Reference | ( | const Reference< Data_T > & | o | ) |

private

Copy constructor. Clears ref counts and rebuilds mutex array.

Definition at line 587 of file SparseFile.h.

{
m_ogReaderPtr.reset();
m_ogReader = NULL;
m_reader = NULL;
blockMutex = NULL;
*this = o;
}
SparseFile::Reference::m_ogReaderPtr
boost::shared_ptr< OgSparseDataReader< Data_T > > m_ogReaderPtr
Shared pointer to the ogawa reader.
Definition SparseFile.h:242

References blockMutex, m_ogReader, m_ogReaderPtr, m_reader, and Reference().

## Member Function Documentation

## create()

template<class Data_T>

Reference< Data_T >::Ptr SparseFile::Reference< Data_T >::create | ( | const std::string | a_filename,
|  | const std::string | a_layerPath )

static

Returns a shared pointer to a reference. Preferred way of creating References.

Definition at line 660 of file SparseFile.h.

{
return Ptr(new Reference(a_filename, a_layerPath));
}
SparseFile::Reference::Reference
Reference(const std::string filename, const std::string layerPath)
Constructor. Requires the filename and layer path of the field to be known.
Definition SparseFile.h:559
SparseFile::Reference::Ptr
Reference * Ptr
Definition SparseFile.h:116

References Reference().

Referenced by SparseFileManager::getNextId().

## fileIsOpen()

template<class Data_T>

bool SparseFile::Reference< Data_T >::fileIsOpen | ( |  | ) |

Checks if the file used by this reference is open already.

Definition at line 669 of file SparseFile.h.

{
return m_fileHandle >= 0;
}

References m_fileHandle.

Referenced by openFile().

## setNumBlocks()

template<class Data_T>

void SparseFile::Reference< Data_T >::setNumBlocks | ( | int | numBlocks | ) |

Sets the number of blocks used by the SparseField we're supporting.

Definition at line 677 of file SparseFile.h.

{
boost::mutex::scoped_lock lock(m_mutex);
// Store number of blocks in member variable
numBlocks = a_numBlocks;
fileBlockIndices.resize(numBlocks);
blockLoaded.resize(numBlocks, 0);
#if !F3D_NO_BLOCKS_ARRAY
blocks.resize(numBlocks, 0);
#endif
blockUsed.resize(numBlocks, false);
loadCounts.resize(numBlocks, 0);
refCounts.resize(numBlocks, 0);
if (blockMutex)
delete[] blockMutex;
#if F3D_SHORT_MUTEX_ARRAY
# if F3D_NO_BLOCKS_ARRAY
blockMutexSize = std::min(numBlocks, F3D_MUTEX_ARRAY_SIZE);
# else
blockMutexSize = std::min(blocks.size(),
static_cast<size_t>(F3D_MUTEX_ARRAY_SIZE));
# endif
blockMutex = new boost::mutex[blockMutexSize];
#else
blockMutex = new boost::mutex[numBlocks];
#endif
}
SparseFile::Reference::blockUsed
std::vector< bool > blockUsed
Flags of whether the blocks have been accessed since they were last considered for deallocation by th...
Definition SparseFile.h:145
SparseFile::Reference::blocks
BlockPtrs blocks
Pointers to each block. This is so we can go in and manipulate them as we please.
Definition SparseFile.h:141
SparseFile::Reference::fileBlockIndices
std::vector< int > fileBlockIndices
Index in file for each block.
Definition SparseFile.h:135
SparseFile::Reference::m_mutex
Mutex m_mutex
Mutex to prevent two threads from modifying conflicting data.
Definition SparseFile.h:254
SparseFile::Reference::blockMutexSize
int blockMutexSize
Size of the mutex array. Used as modulus base.
Definition SparseFile.h:159
SparseFile::Reference::blockLoaded
std::vector< int > blockLoaded
Whether each block is loaded. We don't use bools since vector<bool> is weird.
Definition SparseFile.h:138
SparseFile::Reference::refCounts
std::vector< int > refCounts
Per-block counts of the number of current references to the blocks. If a block's ref count is non-zer...
Definition SparseFile.h:152
SparseFile::Reference::loadCounts
std::vector< int > loadCounts
Per-block counts of the number of times each block has been loaded, for cache statistics.
Definition SparseFile.h:148

References blockLoaded, blockMutex, blockMutexSize, blocks, blockUsed, F3D_MUTEX_ARRAY_SIZE, fileBlockIndices, loadCounts, m_mutex, numBlocks, and refCounts.

## openFile()

template<class Data_T>

void SparseFile::Reference< Data_T >::openFile | ( |  | ) |

Opens the file. This is done just before the first request to loadBlock. This is delayed so that the original file open has closed the file and doesn't cause any Hdf5 hiccups.

Definition at line 537 of file SparseFile.cpp.

{
using namespace Exc;
using namespace Hdf5Util;
boost::mutex::scoped_lock lock_A(m_mutex);
// check that the file wasn't already opened before obtaining the lock
if (fileIsOpen()) {
return;
}
// First try Ogawa ---
m_ogArchive.reset(new Alembic::Ogawa::IArchive(filename));
if (m_ogArchive->isValid()) {
m_ogRoot.reset(new OgIGroup(*m_ogArchive));
m_ogLayerGroup.reset(new OgIGroup(m_ogRoot->findGroup(layerPath)));
if (m_ogLayerGroup->isValid()) {
// Allocate the reader
m_ogReaderPtr.reset(new OgSparseDataReader<Data_T>(*m_ogLayerGroup,
numVoxels,
occupiedBlocks,
true));
m_ogReader = m_ogReaderPtr.get();
// Done
return;
}
}
// Then, try HDF5 ---
{
// Hold the global lock
GlobalLock lock(g_hdf5Mutex);
// Open the file
m_fileHandle = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if (m_fileHandle >= 0) {
// Open the layer group
m_layerGroup.open(m_fileHandle, layerPath.c_str());
if (m_layerGroup.id() < 0) {
Msg::print(Msg::SevWarning, "In SparseFile::Reference::openFile: "
"Couldn't find layer group " + layerPath +
" in .f3d file ");
throw FileIntegrityException(filename);
}
} else {
Msg::print(Msg::SevWarning, "In SparseFile::Reference::openFile: "
"Couldn't open HDF5 file ");
throw NoSuchFileException(filename);
}
}
// Re-allocate reader
if (m_reader) {
delete m_reader;
}
m_reader = new SparseDataReader<Data_T>(m_layerGroup.id(),
valuesPerBlock,
occupiedBlocks);
}
SparseFile::Reference::m_ogRoot
OgIGroupPtr m_ogRoot
Ogawa archive root.
Definition SparseFile.h:249
SparseFile::Reference::m_layerGroup
Hdf5Util::H5ScopedGopen m_layerGroup
Hold the group containing the data open for the duration of the Reference's existence.
Definition SparseFile.h:235
SparseFile::Reference::m_ogArchive
IArchivePtr m_ogArchive
Ogawa archive.
Definition SparseFile.h:247
SparseFile::Reference::m_ogLayerGroup
OgIGroupPtr m_ogLayerGroup
Ogawa layer group.
Definition SparseFile.h:251
SparseFile::Reference::fileIsOpen
bool fileIsOpen()
Checks if the file used by this reference is open already.
Definition SparseFile.h:669
Msg::print
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity.
Definition Log.cpp:70

References fileIsOpen(), filename, g_hdf5Mutex, layerPath, m_fileHandle, m_layerGroup, m_mutex, m_ogArchive, m_ogLayerGroup, m_ogReader, m_ogReaderPtr, m_ogRoot, m_reader, numVoxels, occupiedBlocks, Msg::print(), Msg::SevWarning, and valuesPerBlock.

## closeFile()

template<class Data_T>

void SparseFile::Reference< Data_T >::closeFile | ( |  | ) |

Closes the file. Will be re-opened as needed.

Definition at line 710 of file SparseFile.h.

{
if (m_fileHandle >= 0) {
if (H5Fclose(m_fileHandle) < 0) {
Msg::print("In ~Reference(): Error closing file " + filename);
}
}
}

References filename, m_fileHandle, and Msg::print().

Referenced by unloadBlock(), and ~Reference().

## loadBlock()

template<class Data_T>

void SparseFile::Reference< Data_T >::loadBlock | ( | int | blockIdx | ) |

Loads the block with the given index into memory. We don't pass in a reference to where the data should go since this is already know in the blocks data member.

Definition at line 498 of file SparseFile.cpp.

{
boost::mutex::scoped_lock lock(m_mutex);
// Allocate the block
#if F3D_NO_BLOCKS_ARRAY
blocks[blockIdx].resize(numVoxels);
assert(blocks[blockIdx].data != NULL);
// Read the data
assert(m_reader || m_ogReader);
if (m_reader) {
m_reader->readBlock(fileBlockIndices[blockIdx], *blocks[blockIdx].data);
} else {
m_ogReader->readBlock(fileBlockIndices[blockIdx], blocks[blockIdx].data);
}
// Mark block as loaded
blockLoaded[blockIdx] = 1;
// Track count
m_numActiveBlocks++;
#else
blocks[blockIdx]->resize(numVoxels);
assert(blocks[blockIdx]->data != NULL);
// Read the data
assert(m_reader || m_ogReader);
if (m_reader) {
m_reader->readBlock(fileBlockIndices[blockIdx], *blocks[blockIdx]->data);
} else {
m_ogReader->readBlock(fileBlockIndices[blockIdx], blocks[blockIdx]->data);
}
// Mark block as loaded
blockLoaded[blockIdx] = 1;
// Track count
m_numActiveBlocks++;
#endif
}

References blockLoaded, blocks, fileBlockIndices, m_mutex, m_numActiveBlocks, m_ogReader, m_reader, and numVoxels.

## unloadBlock()

template<class Data_T>

void SparseFile::Reference< Data_T >::unloadBlock | ( | int | blockIdx | ) |

Unloads the block with the given index from memory.

Definition at line 722 of file SparseFile.h.

{
// Deallocate the block
#if F3D_NO_BLOCKS_ARRAY
blocks[blockIdx].clear();
#else
blocks[blockIdx]->clear();
#endif
// Mark block as unloaded
blockLoaded[blockIdx] = 0;
// Track count
m_numActiveBlocks--;
#if 0
// If no active blocks, close the file. De-activate for now.
if (m_numActiveBlocks == 0) {
closeFile();
}
#endif
}

References blockLoaded, blocks, closeFile(), and m_numActiveBlocks.

## incBlockRef()

template<class Data_T>

void SparseFile::Reference< Data_T >::incBlockRef | ( | int | blockIdx | ) |

Increment reference count on a block, indicates the block is currently in use, so prevents it from being unloaded.

Definition at line 745 of file SparseFile.h.

{
#if F3D_SHORT_MUTEX_ARRAY
boost::mutex::scoped_lock lock(blockMutex[blockIdx % blockMutexSize]);
#else
boost::mutex::scoped_lock lock(blockMutex[blockIdx]);
#endif
++refCounts[blockIdx];
}

References blockMutex, blockMutexSize, and refCounts.

## decBlockRef()

template<class Data_T>

void SparseFile::Reference< Data_T >::decBlockRef | ( | int | blockIdx | ) |

Decrement reference count on a block.

Definition at line 758 of file SparseFile.h.

{
#if F3D_SHORT_MUTEX_ARRAY
boost::mutex::scoped_lock lock(blockMutex[blockIdx % blockMutexSize]);
#else
boost::mutex::scoped_lock lock(blockMutex[blockIdx]);
#endif
--refCounts[blockIdx];
}

References blockMutex, blockMutexSize, and refCounts.

## blockSize()

template<class Data_T>

int SparseFile::Reference< Data_T >::blockSize | ( | int | blockIdx | ) | const

Returns the number of bytes used by the data in the block.

Definition at line 771 of file SparseFile.h.

{
return numVoxels * sizeof(Data_T);
}

References numVoxels.

## totalLoads()

template<class Data_T>

int SparseFile::Reference< Data_T >::totalLoads | ( |  | ) | const

Returns the total number of loads of the blocks of this file, for cache statistics.

Definition at line 779 of file SparseFile.h.

{
std::vector<int>::const_iterator i = loadCounts.begin();
std::vector<int>::const_iterator end = loadCounts.end();
int numLoads = 0;
for (; i != end; ++i)
numLoads += *i;
return numLoads;
}

References loadCounts.

## numLoadedBlocks()

template<class Data_T>

int SparseFile::Reference< Data_T >::numLoadedBlocks | ( |  | ) | const

Returns the total number of blocks that are currently loaded, for statistics.

Definition at line 793 of file SparseFile.h.

{
std::vector<int>::const_iterator i = blockLoaded.begin();
std::vector<int>::const_iterator end = blockLoaded.end();
int numBlockCounter = 0;
for (; i != end; ++i)
if (*i)
numBlockCounter++;
return numBlockCounter;
}

References blockLoaded.

## totalLoadedBlocks()

template<class Data_T>

int SparseFile::Reference< Data_T >::totalLoadedBlocks | ( |  | ) | const

Returns the total number of blocks that were ever loaded (max 1 per block, not the number of blocks), for statistics.

Definition at line 808 of file SparseFile.h.

{
std::vector<int>::const_iterator i = loadCounts.begin();
std::vector<int>::const_iterator li = blockLoaded.begin();
std::vector<int>::const_iterator end = loadCounts.end();
int numBlockCounter = 0;
if (blockLoaded.size() == 0) {
for (; i != end; ++i)
if (*i)
numBlockCounter++;
} else {
assert(loadCounts.size() == blockLoaded.size());
for (; i != end; ++i, ++li)
if (*i || *li)
numBlockCounter++;
}
return numBlockCounter;
}

References blockLoaded, and loadCounts.

## averageLoads()

template<class Data_T>

float SparseFile::Reference< Data_T >::averageLoads | ( |  | ) | const

Returns the average number of loads per accessed block in this file, for cache statistics.

Definition at line 833 of file SparseFile.h.

{
std::vector<int>::const_iterator i = loadCounts.begin();
std::vector<int>::const_iterator end = loadCounts.end();
int numLoads = 0, numBlockCounter = 0;
for (; i != end; ++i) {
if (*i) {
numLoads += *i;
numBlockCounter++;
}
}
return (float)numLoads / std::max(1, numBlockCounter);
}

References loadCounts.

## resetCacheStatistics()

template<class Data_T>

void SparseFile::Reference< Data_T >::resetCacheStatistics | ( |  | ) |

Resets counts of total block loads.

Definition at line 851 of file SparseFile.h.

{
std::vector<int>::iterator li = loadCounts.begin();
std::vector<int>::iterator lend = loadCounts.end();
for (; li != lend; ++li)
*li = 0;
}

References loadCounts.

## memSize()

template<class Data_T>

long long int SparseFile::Reference< Data_T >::memSize | ( |  | ) | const

Memory use for the Reference.

Definition at line 863 of file SparseFile.h.

{
boost::mutex::scoped_lock lock(m_mutex);
return sizeof(*this) +
fileBlockIndices.capacity() * sizeof(int) +
blockLoaded.capacity() * sizeof(int) +
#if !F3D_NO_BLOCKS_ARRAY
blocks.capacity() * sizeof(Sparse::SparseBlock<Data_T>*) +
#endif
blockUsed.capacity() * sizeof(bool) +
loadCounts.capacity() * sizeof(int) +
refCounts.capacity() * sizeof(int) +
#if F3D_SHORT_MUTEX_ARRAY
blockMutexSize * sizeof(boost::mutex) +
#else
numBlocks * sizeof(boost::mutex) +
#endif
sizeof(SparseDataReader<Data_T>);
}

References blockLoaded, blockMutexSize, blocks, blockUsed, F3D_NO_BLOCKS_ARRAY, F3D_SHORT_MUTEX_ARRAY, fileBlockIndices, loadCounts, m_mutex, numBlocks, and refCounts.

## operator=()

template<class Data_T>

Reference< Data_T > & SparseFile::Reference< Data_T >::operator= | ( | const Reference< Data_T > & | o | ) |

private

Assignment operator. Clears ref counts and rebuilds mutex array.

Definition at line 600 of file SparseFile.h.

{
if (this == &o) {
return *this;
}
// Copy public member variables (where appropriate)
filename = o.filename;
layerPath = o.layerPath;
valuesPerBlock = o.valuesPerBlock;
numVoxels = o.numVoxels;
occupiedBlocks = o.occupiedBlocks;
fileBlockIndices = o.fileBlockIndices;
blockLoaded = o.blockLoaded;
blocks = o.blocks;
blockUsed = o.blockUsed;
loadCounts = o.loadCounts;
refCounts = o.refCounts;
if (blockMutex)
delete[] blockMutex;
#if F3D_SHORT_MUTEX_ARRAY
# if F3D_NO_BLOCKS_ARRAY
blockMutexSize = std::min(numBlocks, F3D_MUTEX_ARRAY_SIZE);
# else
blockMutexSize = std::min(static_cast<int>(blocks.size()),
F3D_MUTEX_ARRAY_SIZE);
# endif
blockMutex = new boost::mutex[blockMutexSize];
#else
blockMutex = new boost::mutex[blocks.size()];
#endif
#if 0
// MW: Should this be copying the file handle? Never seems to happen,
// but it also seems bad. Ifdef'ing out for now.
// Copy private member variables (where appropriate)
m_fileHandle = o.m_fileHandle;
// Don't copy id, let hdf5 generate a new one.
if (m_fileHandle >= 0) {
m_layerGroup.open(m_fileHandle, layerPath.c_str());
}
#else
m_fileHandle = -1;
#endif
// Re-allocate reader
if (m_reader)
delete m_reader;
m_reader = NULL;
m_ogReaderPtr.reset();
m_ogReader = NULL;
return *this;
}

References blockLoaded, blockMutex, blockMutexSize, blocks, blockUsed, F3D_MUTEX_ARRAY_SIZE, fileBlockIndices, filename, layerPath, loadCounts, m_fileHandle, m_layerGroup, m_ogReader, m_ogReaderPtr, m_reader, numBlocks, numVoxels, occupiedBlocks, refCounts, Reference(), and valuesPerBlock.

## Member Data Documentation

## filename

template<class Data_T>

std::string SparseFile::Reference< Data_T >::filename

Definition at line 127 of file SparseFile.h.

Referenced by closeFile(), SparseField< Data_T >::copySparseField(), openFile(), operator=(), and Reference().

## layerPath

template<class Data_T>

std::string SparseFile::Reference< Data_T >::layerPath

Definition at line 128 of file SparseFile.h.

Referenced by SparseField< Data_T >::copySparseField(), openFile(), operator=(), and Reference().

## valuesPerBlock

template<class Data_T>

int SparseFile::Reference< Data_T >::valuesPerBlock

Definition at line 129 of file SparseFile.h.

Referenced by SparseField< Data_T >::copySparseField(), openFile(), operator=(), and Reference().

## numVoxels

template<class Data_T>

int SparseFile::Reference< Data_T >::numVoxels

Definition at line 130 of file SparseFile.h.

Referenced by blockSize(), SparseField< Data_T >::copySparseField(), loadBlock(), openFile(), operator=(), and Reference().

## numBlocks

template<class Data_T>

int SparseFile::Reference< Data_T >::numBlocks

Definition at line 131 of file SparseFile.h.

Referenced by memSize(), operator=(), Reference(), and setNumBlocks().

## occupiedBlocks

template<class Data_T>

int SparseFile::Reference< Data_T >::occupiedBlocks

Definition at line 132 of file SparseFile.h.

Referenced by SparseField< Data_T >::copySparseField(), openFile(), operator=(), and Reference().

## fileBlockIndices

template<class Data_T>

std::vector<int> SparseFile::Reference< Data_T >::fileBlockIndices

Index in file for each block.

Definition at line 135 of file SparseFile.h.

Referenced by loadBlock(), memSize(), operator=(), setNumBlocks(), and SparseField< Data_T >::setupReferenceBlocks().

## blockLoaded

template<class Data_T>

std::vector<int> SparseFile::Reference< Data_T >::blockLoaded

Whether each block is loaded. We don't use bools since vector<bool> is weird.

Definition at line 138 of file SparseFile.h.

Referenced by loadBlock(), memSize(), numLoadedBlocks(), operator=(), setNumBlocks(), totalLoadedBlocks(), and unloadBlock().

## blocks

template<class Data_T>

BlockPtrs SparseFile::Reference< Data_T >::blocks

Pointers to each block. This is so we can go in and manipulate them as we please.

Definition at line 141 of file SparseFile.h.

Referenced by loadBlock(), memSize(), operator=(), setNumBlocks(), SparseField< Data_T >::setupReferenceBlocks(), and unloadBlock().

## blockUsed

template<class Data_T>

std::vector<bool> SparseFile::Reference< Data_T >::blockUsed

Flags of whether the blocks have been accessed since they were last considered for deallocation by the Second-chance/Clock caching system.

Definition at line 145 of file SparseFile.h.

Referenced by memSize(), operator=(), and setNumBlocks().

## loadCounts

template<class Data_T>

std::vector<int> SparseFile::Reference< Data_T >::loadCounts

Per-block counts of the number of times each block has been loaded, for cache statistics.

Definition at line 148 of file SparseFile.h.

Referenced by averageLoads(), memSize(), operator=(), resetCacheStatistics(), setNumBlocks(), totalLoadedBlocks(), and totalLoads().

## refCounts

template<class Data_T>

std::vector<int> SparseFile::Reference< Data_T >::refCounts

Per-block counts of the number of current references to the blocks. If a block's ref count is non-zero, then the block shouldn't be unloaded.

Definition at line 152 of file SparseFile.h.

Referenced by decBlockRef(), incBlockRef(), memSize(), operator=(), and setNumBlocks().

## blockMutex

template<class Data_T>

boost::mutex* SparseFile::Reference< Data_T >::blockMutex

Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-safe updates of the ref counts.

Definition at line 156 of file SparseFile.h.

Referenced by decBlockRef(), incBlockRef(), operator=(), Reference(), Reference(), setNumBlocks(), and ~Reference().

## blockMutexSize

template<class Data_T>

int SparseFile::Reference< Data_T >::blockMutexSize

Size of the mutex array. Used as modulus base.

Definition at line 159 of file SparseFile.h.

Referenced by decBlockRef(), incBlockRef(), memSize(), operator=(), and setNumBlocks().

## m_fileHandle

template<class Data_T>

hid_t SparseFile::Reference< Data_T >::m_fileHandle

private

Holds the Hdf5 handle to the file.

Definition at line 231 of file SparseFile.h.

Referenced by closeFile(), fileIsOpen(), openFile(), operator=(), and Reference().

## m_layerGroup

template<class Data_T>

Hdf5Util::H5ScopedGopen SparseFile::Reference< Data_T >::m_layerGroup

private

Hold the group containing the data open for the duration of the Reference's existence.

Definition at line 235 of file SparseFile.h.

Referenced by openFile(), and operator=().

## m_reader

template<class Data_T>

SparseDataReader<Data_T>* SparseFile::Reference< Data_T >::m_reader

private

Pointer to the reader object. NULL at construction time. Created in openFile().

Definition at line 239 of file SparseFile.h.

Referenced by loadBlock(), openFile(), operator=(), Reference(), Reference(), and ~Reference().

## m_ogReaderPtr

template<class Data_T>

boost::shared_ptr<OgSparseDataReader<Data_T> > SparseFile::Reference< Data_T >::m_ogReaderPtr

private

Shared pointer to the ogawa reader.

Definition at line 242 of file SparseFile.h.

Referenced by openFile(), operator=(), and Reference().

## m_ogReader

template<class Data_T>

OgSparseDataReader<Data_T>* SparseFile::Reference< Data_T >::m_ogReader

private

Pointer to the ogawa reader. NULL at construction time. Created in openFile().

Definition at line 245 of file SparseFile.h.

Referenced by loadBlock(), openFile(), operator=(), Reference(), and Reference().

## m_ogArchive

template<class Data_T>

IArchivePtr SparseFile::Reference< Data_T >::m_ogArchive

private

Ogawa archive.

Definition at line 247 of file SparseFile.h.

Referenced by openFile().

## m_ogRoot

template<class Data_T>

OgIGroupPtr SparseFile::Reference< Data_T >::m_ogRoot

private

Ogawa archive root.

Definition at line 249 of file SparseFile.h.

Referenced by openFile().

## m_ogLayerGroup

template<class Data_T>

OgIGroupPtr SparseFile::Reference< Data_T >::m_ogLayerGroup

private

Ogawa layer group.

Definition at line 251 of file SparseFile.h.

Referenced by openFile().

## m_mutex

template<class Data_T>

Mutex SparseFile::Reference< Data_T >::m_mutex

mutable private

Mutex to prevent two threads from modifying conflicting data.

Definition at line 254 of file SparseFile.h.

Referenced by loadBlock(), memSize(), openFile(), and setNumBlocks().

## m_numActiveBlocks

template<class Data_T>

size_t SparseFile::Reference< Data_T >::m_numActiveBlocks

private

Number of currently active blocks.

Definition at line 257 of file SparseFile.h.

Referenced by loadBlock(), Reference(), and unloadBlock().

The documentation for this class was generated from the following files:

- export/SparseFile.h
- src/SparseFile.cpp