Field3D
SparseFile::Reference< Data_T > Class Template Reference

#include <SparseFile.h>

Public Types

typedef std::vector< Sparse::SparseBlock< Data_T > * > BlockPtrs
 
typedef ReferencePtr
 

Public Member Functions

float averageLoads () const
 Returns the average number of loads per accessed block in this file, for cache statistics. More...
 
int blockSize (int blockIdx) const
 Returns the number of bytes used by the data in the block. More...
 
void closeFile ()
 Closes the file. Will be re-opened as needed. More...
 
void decBlockRef (int blockIdx)
 Decrement reference count on a block. More...
 
bool fileIsOpen ()
 Checks if the file used by this reference is open already. More...
 
void incBlockRef (int blockIdx)
 Increment reference count on a block, indicates the block is currently in use, so prevents it from being unloaded. More...
 
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. More...
 
int numLoadedBlocks () const
 Returns the total number of blocks that are currently loaded, for statistics. More...
 
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. More...
 
void resetCacheStatistics ()
 Resets counts of total block loads. More...
 
void setNumBlocks (int numBlocks)
 Sets the number of blocks used by the SparseField we're supporting. More...
 
int totalLoadedBlocks () const
 Returns the total number of blocks that were ever loaded (max 1 per block, not the number of blocks), for statistics. More...
 
int totalLoads () const
 Returns the total number of loads of the blocks of this file, for cache statistics. More...
 
void unloadBlock (int blockIdx)
 Unloads the block with the given index from memory. More...
 
 ~Reference ()
 Destructor. More...
 

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. More...
 

Public Attributes

std::vector< int > blockLoaded
 Whether each block is loaded. We don't use bools since vector<bool> is weird. More...
 
boost::mutex * blockMutex
 Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-safe updates of the ref counts. More...
 
BlockPtrs blocks
 Pointers to each block. This is so we can go in and manipulate them as we please. More...
 
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. More...
 
std::vector< int > fileBlockIndices
 Index in file for each block. More...
 
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. More...
 
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. More...
 
int valuesPerBlock
 

Private Types

typedef boost::mutex Mutex
 

Private Member Functions

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

Private Attributes

hid_t m_fileHandle
 Holds the Hdf5 handle to the file. More...
 
Hdf5Util::H5ScopedGopen m_layerGroup
 Hold the group containing the data open for the duration of the Reference's existence. More...
 
Mutex m_mutex
 Mutex to prevent two threads from modifying conflicting data. More...
 
size_t m_numActiveBlocks
 Number of currently active blocks. More...
 
SparseDataReader< Data_T > * m_reader
 Pointer to the reader object. NULL at construction time. Created in openFile(). More...
 

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 96 of file SparseFile.h.

Member Typedef Documentation

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

Definition at line 107 of file SparseFile.h.

template<class Data_T>
typedef std::vector<Sparse::SparseBlock<Data_T>*> SparseFile::Reference< Data_T >::BlockPtrs

Definition at line 109 of file SparseFile.h.

template<class Data_T>
typedef boost::mutex SparseFile::Reference< Data_T >::Mutex
private

Definition at line 193 of file SparseFile.h.

Constructor & Destructor Documentation

template<class Data_T >
SparseFile::Reference< Data_T >::~Reference ( )

Destructor.

Definition at line 533 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockMutex, SparseFile::Reference< Data_T >::closeFile(), and SparseFile::Reference< Data_T >::m_reader.

534 {
535  closeFile();
536 
537  if (m_reader)
538  delete m_reader;
539 
540  if (blockMutex)
541  delete [] blockMutex;
542 }
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition: SparseFile.h:217
void closeFile()
Closes the file. Will be re-opened as needed.
Definition: SparseFile.h:681
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition: SparseFile.h:140
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 520 of file SparseFile.h.

Referenced by SparseFile::Reference< Data_T >::create().

522  : filename(a_filename), layerPath(a_layerPath),
524  blockMutex(NULL), m_fileHandle(-1), m_reader(NULL),
526 {
527  /* Empty */
528 }
size_t m_numActiveBlocks
Number of currently active blocks.
Definition: SparseFile.h:224
hid_t m_fileHandle
Holds the Hdf5 handle to the file.
Definition: SparseFile.h:209
std::string layerPath
Definition: SparseFile.h:114
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition: SparseFile.h:217
std::string filename
Definition: SparseFile.h:113
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition: SparseFile.h:140
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 547 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockMutex, and SparseFile::Reference< Data_T >::m_reader.

548 {
549  m_reader = NULL;
550  blockMutex = NULL;
551  *this = o;
552 }
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition: SparseFile.h:217
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition: SparseFile.h:140

Member Function Documentation

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 604 of file SparseFile.h.

References SparseFile::Reference< Data_T >::Reference().

Referenced by SparseFileManager::getNextId().

606 {
607  return Ptr(new Reference(a_filename, a_layerPath));
608 }
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:520
template<class Data_T >
bool SparseFile::Reference< Data_T >::fileIsOpen ( )

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

Definition at line 613 of file SparseFile.h.

References SparseFile::Reference< Data_T >::m_fileHandle.

Referenced by SparseFileManager::activateBlock(), and SparseFile::Reference< Data_T >::openFile().

614 {
615  return m_fileHandle >= 0;
616 }
hid_t m_fileHandle
Holds the Hdf5 handle to the file.
Definition: SparseFile.h:209
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 621 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockLoaded, SparseFile::Reference< Data_T >::blockMutex, SparseFile::Reference< Data_T >::blocks, SparseFile::Reference< Data_T >::blockUsed, SparseFile::Reference< Data_T >::fileBlockIndices, SparseFile::Reference< Data_T >::loadCounts, SparseFile::Reference< Data_T >::m_mutex, and SparseFile::Reference< Data_T >::refCounts.

622 {
623  boost::mutex::scoped_lock lock(m_mutex);
624 
625  fileBlockIndices.resize(numBlocks);
626  blockLoaded.resize(numBlocks, 0);
627  blocks.resize(numBlocks, 0);
628  blockUsed.resize(numBlocks, false);
629  loadCounts.resize(numBlocks, 0);
630  refCounts.resize(numBlocks, 0);
631  if (blockMutex)
632  delete[] blockMutex;
633  blockMutex = new boost::mutex[numBlocks];
634 }
std::vector< int > blockLoaded
Whether each block is loaded. We don&#39;t use bools since vector<bool> is weird.
Definition: SparseFile.h:122
std::vector< bool > blockUsed
Flags of whether the blocks have been accessed since they were last considered for deallocation by th...
Definition: SparseFile.h:129
std::vector< int > fileBlockIndices
Index in file for each block.
Definition: SparseFile.h:119
std::vector< int > refCounts
Per-block counts of the number of current references to the blocks. If a block&#39;s ref count is non-zer...
Definition: SparseFile.h:136
Mutex m_mutex
Mutex to prevent two threads from modifying conflicting data.
Definition: SparseFile.h:221
BlockPtrs blocks
Pointers to each block. This is so we can go in and manipulate them as we please. ...
Definition: SparseFile.h:125
std::vector< int > loadCounts
Per-block counts of the number of times each block has been loaded, for cache statistics.
Definition: SparseFile.h:132
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition: SparseFile.h:140
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 639 of file SparseFile.h.

References SparseFile::Reference< Data_T >::fileIsOpen(), SparseFile::Reference< Data_T >::filename, g_hdf5Mutex, Hdf5Util::H5Base::id(), SparseFile::Reference< Data_T >::layerPath, SparseFile::Reference< Data_T >::m_fileHandle, SparseFile::Reference< Data_T >::m_layerGroup, SparseFile::Reference< Data_T >::m_mutex, SparseFile::Reference< Data_T >::m_reader, SparseFile::Reference< Data_T >::occupiedBlocks, Hdf5Util::H5ScopedGopen::open(), Msg::print(), Msg::SevWarning, and SparseFile::Reference< Data_T >::valuesPerBlock.

Referenced by SparseFileManager::activateBlock().

640 {
641  using namespace Exc;
642  using namespace Hdf5Util;
643 
644  boost::mutex::scoped_lock lock_A(m_mutex);
645 
646  // check that the file wasn't already opened before obtaining the lock
647  if (fileIsOpen()) {
648  return;
649  }
650 
651  {
652  // Hold the global lock
653  GlobalLock lock(g_hdf5Mutex);
654  // Open the file
655  m_fileHandle = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
656  if (m_fileHandle < 0) {
657  printf("openFile(): No file handle. Dying.\n");
658  throw NoSuchFileException(filename);
659  }
660  // Open the layer group
662  if (m_layerGroup.id() < 0) {
663  Msg::print(Msg::SevWarning, "In SparseFile::Reference::openFile: "
664  "Couldn't find layer group " + layerPath +
665  " in .f3d file ");
666  throw FileIntegrityException(filename);
667  }
668  }
669 
670  // Re-allocate reader
671  if (m_reader) {
672  delete m_reader;
673  }
676 }
Contains utility functions and classes for Hdf5 files.
Definition: Hdf5Util.h:86
hid_t m_fileHandle
Holds the Hdf5 handle to the file.
Definition: SparseFile.h:209
Namespace for Exception objects.
Definition: Exception.h:57
boost::recursive_mutex::scoped_lock GlobalLock
Definition: Hdf5Util.h:78
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:66
std::string layerPath
Definition: SparseFile.h:114
Mutex m_mutex
Mutex to prevent two threads from modifying conflicting data.
Definition: SparseFile.h:221
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition: SparseFile.h:217
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.
Hdf5Util::H5ScopedGopen m_layerGroup
Hold the group containing the data open for the duration of the Reference&#39;s existence.
Definition: SparseFile.h:213
std::string filename
Definition: SparseFile.h:113
FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
Definition: Hdf5Util.cpp:67
bool fileIsOpen()
Checks if the file used by this reference is open already.
Definition: SparseFile.h:613
void open(hid_t parentLocation, const std::string &name)
Definition: Hdf5Util.h:210
hid_t id() const
Query the hid_t value.
Definition: Hdf5Util.h:100
template<class Data_T >
void SparseFile::Reference< Data_T >::closeFile ( )

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

Definition at line 681 of file SparseFile.h.

References SparseFile::Reference< Data_T >::filename, SparseFile::Reference< Data_T >::m_fileHandle, and Msg::print().

Referenced by SparseFile::Reference< Data_T >::unloadBlock(), and SparseFile::Reference< Data_T >::~Reference().

682 {
683  if (m_fileHandle >= 0) {
684  if (H5Fclose(m_fileHandle) < 0) {
685  Msg::print("In ~Reference(): Error closing file " + filename);
686  }
687  }
688 }
hid_t m_fileHandle
Holds the Hdf5 handle to the file.
Definition: SparseFile.h:209
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:66
std::string filename
Definition: SparseFile.h:113
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 693 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockLoaded, SparseFile::Reference< Data_T >::blocks, SparseFile::Reference< Data_T >::fileBlockIndices, SparseFile::Reference< Data_T >::m_mutex, SparseFile::Reference< Data_T >::m_numActiveBlocks, SparseFile::Reference< Data_T >::m_reader, and SparseFile::Reference< Data_T >::valuesPerBlock.

Referenced by SparseFileManager::activateBlock().

694 {
695  boost::mutex::scoped_lock lock(m_mutex);
696 
697  // Allocate the block
698  blocks[blockIdx]->resize(valuesPerBlock);
699  assert(blocks[blockIdx]->data != NULL);
700  // Read the data
701  assert(m_reader);
702  m_reader->readBlock(fileBlockIndices[blockIdx], *blocks[blockIdx]->data);
703  // Mark block as loaded
704  blockLoaded[blockIdx] = 1;
705  // Track count
707 }
size_t m_numActiveBlocks
Number of currently active blocks.
Definition: SparseFile.h:224
std::vector< int > blockLoaded
Whether each block is loaded. We don&#39;t use bools since vector<bool> is weird.
Definition: SparseFile.h:122
std::vector< int > fileBlockIndices
Index in file for each block.
Definition: SparseFile.h:119
Mutex m_mutex
Mutex to prevent two threads from modifying conflicting data.
Definition: SparseFile.h:221
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition: SparseFile.h:217
BlockPtrs blocks
Pointers to each block. This is so we can go in and manipulate them as we please. ...
Definition: SparseFile.h:125
template<class Data_T >
void SparseFile::Reference< Data_T >::unloadBlock ( int  blockIdx)

Unloads the block with the given index from memory.

Definition at line 712 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockLoaded, SparseFile::Reference< Data_T >::blocks, SparseFile::Reference< Data_T >::closeFile(), and SparseFile::Reference< Data_T >::m_numActiveBlocks.

Referenced by SparseFileManager::deallocateBlock().

713 {
714  // Deallocate the block
715  blocks[blockIdx]->clear();
716  // Mark block as unloaded
717  blockLoaded[blockIdx] = 0;
718  // Track count
720 #if 0
721  // If no active blocks, close the file. De-activate for now.
722  if (m_numActiveBlocks == 0) {
723  closeFile();
724  }
725 #endif
726 }
size_t m_numActiveBlocks
Number of currently active blocks.
Definition: SparseFile.h:224
std::vector< int > blockLoaded
Whether each block is loaded. We don&#39;t use bools since vector<bool> is weird.
Definition: SparseFile.h:122
BlockPtrs blocks
Pointers to each block. This is so we can go in and manipulate them as we please. ...
Definition: SparseFile.h:125
void closeFile()
Closes the file. Will be re-opened as needed.
Definition: SparseFile.h:681
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 731 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockMutex, and SparseFile::Reference< Data_T >::refCounts.

Referenced by SparseFileManager::incBlockRef().

732 {
733  boost::mutex::scoped_lock lock(blockMutex[blockIdx]);
734  ++refCounts[blockIdx];
735 }
std::vector< int > refCounts
Per-block counts of the number of current references to the blocks. If a block&#39;s ref count is non-zer...
Definition: SparseFile.h:136
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition: SparseFile.h:140
template<class Data_T >
void SparseFile::Reference< Data_T >::decBlockRef ( int  blockIdx)

Decrement reference count on a block.

Definition at line 740 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockMutex, and SparseFile::Reference< Data_T >::refCounts.

Referenced by SparseFileManager::decBlockRef().

741 {
742  boost::mutex::scoped_lock lock(blockMutex[blockIdx]);
743  --refCounts[blockIdx];
744 }
std::vector< int > refCounts
Per-block counts of the number of current references to the blocks. If a block&#39;s ref count is non-zer...
Definition: SparseFile.h:136
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition: SparseFile.h:140
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 749 of file SparseFile.h.

References SparseFile::Reference< Data_T >::valuesPerBlock.

Referenced by SparseFileManager::activateBlock(), SparseFileManager::deallocateBlock(), and SparseFileManager::removeFieldFromCache().

750 {
751  return valuesPerBlock * sizeof(Data_T);
752 }
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 757 of file SparseFile.h.

References SparseFile::Reference< Data_T >::loadCounts.

758 {
759  std::vector<int>::const_iterator i = loadCounts.begin();
760  std::vector<int>::const_iterator end = loadCounts.end();
761  int numLoads = 0;
762  for (; i != end; ++i)
763  numLoads += *i;
764 
765  return numLoads;
766 }
std::vector< int > loadCounts
Per-block counts of the number of times each block has been loaded, for cache statistics.
Definition: SparseFile.h:132
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 771 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockLoaded.

772 {
773  std::vector<int>::const_iterator i = blockLoaded.begin();
774  std::vector<int>::const_iterator end = blockLoaded.end();
775  int numBlocks = 0;
776  for (; i != end; ++i)
777  if (*i)
778  numBlocks++;
779 
780  return numBlocks;
781 }
std::vector< int > blockLoaded
Whether each block is loaded. We don&#39;t use bools since vector<bool> is weird.
Definition: SparseFile.h:122
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 786 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockLoaded, and SparseFile::Reference< Data_T >::loadCounts.

787 {
788  std::vector<int>::const_iterator i = loadCounts.begin();
789  std::vector<int>::const_iterator li = blockLoaded.begin();
790  std::vector<int>::const_iterator end = loadCounts.end();
791  int numBlocks = 0;
792 
793  if (blockLoaded.size() == 0) {
794  for (; i != end; ++i)
795  if (*i)
796  numBlocks++;
797  } else {
798  assert(loadCounts.size() == blockLoaded.size());
799 
800  for (; i != end; ++i, ++li)
801  if (*i || *li)
802  numBlocks++;
803  }
804 
805  return numBlocks;
806 }
std::vector< int > blockLoaded
Whether each block is loaded. We don&#39;t use bools since vector<bool> is weird.
Definition: SparseFile.h:122
std::vector< int > loadCounts
Per-block counts of the number of times each block has been loaded, for cache statistics.
Definition: SparseFile.h:132
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 811 of file SparseFile.h.

References SparseFile::Reference< Data_T >::loadCounts.

812 {
813  std::vector<int>::const_iterator i = loadCounts.begin();
814  std::vector<int>::const_iterator end = loadCounts.end();
815  int numLoads = 0, numBlocks = 0;
816  for (; i != end; ++i) {
817  if (*i) {
818  numLoads += *i;
819  numBlocks++;
820  }
821  }
822 
823  return (float)numLoads / std::max(1, numBlocks);
824 }
std::vector< int > loadCounts
Per-block counts of the number of times each block has been loaded, for cache statistics.
Definition: SparseFile.h:132
template<class Data_T >
void SparseFile::Reference< Data_T >::resetCacheStatistics ( )

Resets counts of total block loads.

Definition at line 829 of file SparseFile.h.

References SparseFile::Reference< Data_T >::loadCounts.

830 {
831  std::vector<int>::iterator li = loadCounts.begin();
832  std::vector<int>::iterator lend = loadCounts.end();
833  for (; li != lend; ++li)
834  *li = 0;
835 }
std::vector< int > loadCounts
Per-block counts of the number of times each block has been loaded, for cache statistics.
Definition: SparseFile.h:132
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 558 of file SparseFile.h.

References SparseFile::Reference< Data_T >::blockLoaded, SparseFile::Reference< Data_T >::blockMutex, SparseFile::Reference< Data_T >::blocks, SparseFile::Reference< Data_T >::blockUsed, SparseFile::Reference< Data_T >::fileBlockIndices, SparseFile::Reference< Data_T >::filename, SparseFile::Reference< Data_T >::layerPath, SparseFile::Reference< Data_T >::loadCounts, SparseFile::Reference< Data_T >::m_fileHandle, SparseFile::Reference< Data_T >::m_layerGroup, SparseFile::Reference< Data_T >::m_reader, SparseFile::Reference< Data_T >::occupiedBlocks, Hdf5Util::H5ScopedGopen::open(), SparseFile::Reference< Data_T >::refCounts, and SparseFile::Reference< Data_T >::valuesPerBlock.

559 {
560  if (this == &o) {
561  return *this;
562  }
563 
564  // Copy public member variables (where appropriate)
565  filename = o.filename;
566  layerPath = o.layerPath;
571  blocks = o.blocks;
572  blockUsed = o.blockUsed;
574  refCounts = o.refCounts;
575  if (blockMutex)
576  delete[] blockMutex;
577  blockMutex = new boost::mutex[blocks.size()];
578 
579 #if 0
580  // MW: Should this be copying the file handle? Never seems to happen,
581  // but it also seems bad. Ifdef'ing out for now.
582  // Copy private member variables (where appropriate)
584  // Don't copy id, let hdf5 generate a new one.
585  if (m_fileHandle >= 0) {
587  }
588 #else
589  m_fileHandle = -1;
590 #endif
591 
592  // Re-allocate reader
593  if (m_reader)
594  delete m_reader;
595  m_reader = NULL;
596 
597  return *this;
598 }
hid_t m_fileHandle
Holds the Hdf5 handle to the file.
Definition: SparseFile.h:209
std::vector< int > blockLoaded
Whether each block is loaded. We don&#39;t use bools since vector<bool> is weird.
Definition: SparseFile.h:122
std::vector< bool > blockUsed
Flags of whether the blocks have been accessed since they were last considered for deallocation by th...
Definition: SparseFile.h:129
std::vector< int > fileBlockIndices
Index in file for each block.
Definition: SparseFile.h:119
std::string layerPath
Definition: SparseFile.h:114
std::vector< int > refCounts
Per-block counts of the number of current references to the blocks. If a block&#39;s ref count is non-zer...
Definition: SparseFile.h:136
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition: SparseFile.h:217
BlockPtrs blocks
Pointers to each block. This is so we can go in and manipulate them as we please. ...
Definition: SparseFile.h:125
Hdf5Util::H5ScopedGopen m_layerGroup
Hold the group containing the data open for the duration of the Reference&#39;s existence.
Definition: SparseFile.h:213
std::string filename
Definition: SparseFile.h:113
std::vector< int > loadCounts
Per-block counts of the number of times each block has been loaded, for cache statistics.
Definition: SparseFile.h:132
boost::mutex * blockMutex
Allocated array of mutexes, one per block, to lock each block individually, for guaranteeing thread-s...
Definition: SparseFile.h:140
void open(hid_t parentLocation, const std::string &name)
Definition: Hdf5Util.h:210

Member Data Documentation

template<class Data_T>
std::string SparseFile::Reference< Data_T >::layerPath
template<class Data_T>
int SparseFile::Reference< Data_T >::occupiedBlocks
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 129 of file SparseFile.h.

Referenced by SparseFileManager::activateBlock(), SparseFileManager::deallocateBlock(), SparseFile::Reference< Data_T >::operator=(), SparseFileManager::removeFieldFromCache(), and SparseFile::Reference< Data_T >::setNumBlocks().

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 136 of file SparseFile.h.

Referenced by SparseFileManager::deallocateBlock(), SparseFile::Reference< Data_T >::decBlockRef(), SparseFile::Reference< Data_T >::incBlockRef(), SparseFile::Reference< Data_T >::operator=(), SparseFileManager::removeFieldFromCache(), and SparseFile::Reference< Data_T >::setNumBlocks().

template<class Data_T>
hid_t SparseFile::Reference< Data_T >::m_fileHandle
private
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 213 of file SparseFile.h.

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

template<class Data_T>
SparseDataReader<Data_T>* SparseFile::Reference< Data_T >::m_reader
private
template<class Data_T>
size_t SparseFile::Reference< Data_T >::m_numActiveBlocks
private

Number of currently active blocks.

Definition at line 224 of file SparseFile.h.

Referenced by SparseFile::Reference< Data_T >::loadBlock(), and SparseFile::Reference< Data_T >::unloadBlock().


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