Field3D
SparseFile::Reference< Data_T > Class Template Reference

#include <SparseFile.h>

Public Types

typedef 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...
 
long long int memSize () const
 Memory use for the Reference. 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...
 
int blockMutexSize
 Size of the mutex array. Used as modulus base. 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 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. 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 Reference &o)
 Copy constructor. 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...
 

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...
 
IArchivePtr m_ogArchive
 Ogawa archive. More...
 
OgIGroupPtr m_ogLayerGroup
 Ogawa layer group. More...
 
OgSparseDataReader< Data_T > * m_ogReader
 Pointer to the ogawa reader. NULL at construction time. Created in openFile(). More...
 
boost::shared_ptr< OgSparseDataReader< Data_T > > m_ogReaderPtr
 Shared pointer to the ogawa reader. More...
 
OgIGroupPtr m_ogRoot
 Ogawa archive root. 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 104 of file SparseFile.h.

Member Typedef Documentation

◆ Ptr

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

Definition at line 115 of file SparseFile.h.

◆ BlockPtrs

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

Definition at line 119 of file SparseFile.h.

◆ Mutex

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

Definition at line 214 of file SparseFile.h.

Constructor & Destructor Documentation

◆ ~Reference()

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

Destructor.

Definition at line 571 of file SparseFile.h.

572 {
573  closeFile();
574 
575  if (m_reader) {
576  delete m_reader;
577  }
578 
579  if (blockMutex)
580  delete [] blockMutex;
581 }

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

560  : filename(a_filename), layerPath(a_layerPath),
562  blockMutex(NULL), m_fileHandle(-1), m_reader(NULL), m_ogReader(NULL),
564 {
565  /* Empty */
566 }

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

587 {
588  m_ogReaderPtr.reset();
589  m_ogReader = NULL;
590  m_reader = NULL;
591  blockMutex = NULL;
592  *this = o;
593 }

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

661 {
662  return Ptr(new Reference(a_filename, a_layerPath));
663 }

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

669 {
670  return m_fileHandle >= 0;
671 }

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

677 {
678  boost::mutex::scoped_lock lock(m_mutex);
679 
680  // Store number of blocks in member variable
681  numBlocks = a_numBlocks;
682 
683  fileBlockIndices.resize(numBlocks);
684  blockLoaded.resize(numBlocks, 0);
685 #if !F3D_NO_BLOCKS_ARRAY
686  blocks.resize(numBlocks, 0);
687 #endif
688  blockUsed.resize(numBlocks, false);
689  loadCounts.resize(numBlocks, 0);
690  refCounts.resize(numBlocks, 0);
691  if (blockMutex)
692  delete[] blockMutex;
693 #if F3D_SHORT_MUTEX_ARRAY
694 # if F3D_NO_BLOCKS_ARRAY
696 # else
697  blockMutexSize = std::min(blocks.size(),
698  static_cast<size_t>(F3D_MUTEX_ARRAY_SIZE));
699 # endif
700  blockMutex = new boost::mutex[blockMutexSize];
701 #else
702  blockMutex = new boost::mutex[numBlocks];
703 #endif
704 }

References F3D_MUTEX_ARRAY_SIZE, and detail::min().

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

538 {
539  using namespace Exc;
540  using namespace Hdf5Util;
541 
542  boost::mutex::scoped_lock lock_A(m_mutex);
543 
544  // check that the file wasn't already opened before obtaining the lock
545  if (fileIsOpen()) {
546  return;
547  }
548 
549  // First try Ogawa ---
550 
551  m_ogArchive.reset(new Alembic::Ogawa::IArchive(filename));
552  if (m_ogArchive->isValid()) {
553  m_ogRoot.reset(new OgIGroup(*m_ogArchive));
554  m_ogLayerGroup.reset(new OgIGroup(m_ogRoot->findGroup(layerPath)));
555  if (m_ogLayerGroup->isValid()) {
556  // Allocate the reader
558  numVoxels,
560  true));
561  m_ogReader = m_ogReaderPtr.get();
562  // Done
563  return;
564  }
565  }
566 
567  // Then, try HDF5 ---
568 
569  {
570  // Hold the global lock
571  GlobalLock lock(g_hdf5Mutex);
572  // Open the file
573  m_fileHandle = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
574  if (m_fileHandle >= 0) {
575  // Open the layer group
577  if (m_layerGroup.id() < 0) {
578  Msg::print(Msg::SevWarning, "In SparseFile::Reference::openFile: "
579  "Couldn't find layer group " + layerPath +
580  " in .f3d file ");
581  throw FileIntegrityException(filename);
582  }
583  } else {
584  Msg::print(Msg::SevWarning, "In SparseFile::Reference::openFile: "
585  "Couldn't open HDF5 file ");
586  throw NoSuchFileException(filename);
587  }
588  }
589 
590  // Re-allocate reader
591  if (m_reader) {
592  delete m_reader;
593  }
597 }

References g_hdf5Mutex, Msg::print(), and Msg::SevWarning.

◆ closeFile()

template<class Data_T >
void SparseFile::Reference< Data_T >::closeFile ( )

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

Definition at line 709 of file SparseFile.h.

710 {
711  if (m_fileHandle >= 0) {
712  if (H5Fclose(m_fileHandle) < 0) {
713  Msg::print("In ~Reference(): Error closing file " + filename);
714  }
715  }
716 }

References Msg::print().

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

499 {
500  boost::mutex::scoped_lock lock(m_mutex);
501 
502  // Allocate the block
503 #if F3D_NO_BLOCKS_ARRAY
504  blocks[blockIdx].resize(numVoxels);
505  assert(blocks[blockIdx].data != NULL);
506  // Read the data
507  assert(m_reader || m_ogReader);
508  if (m_reader) {
509  m_reader->readBlock(fileBlockIndices[blockIdx], *blocks[blockIdx].data);
510  } else {
511  m_ogReader->readBlock(fileBlockIndices[blockIdx], blocks[blockIdx].data);
512  }
513  // Mark block as loaded
514  blockLoaded[blockIdx] = 1;
515  // Track count
517 #else
518  blocks[blockIdx]->resize(numVoxels);
519  assert(blocks[blockIdx]->data != NULL);
520  // Read the data
521  assert(m_reader || m_ogReader);
522  if (m_reader) {
523  m_reader->readBlock(fileBlockIndices[blockIdx], *blocks[blockIdx]->data);
524  } else {
525  m_ogReader->readBlock(fileBlockIndices[blockIdx], blocks[blockIdx]->data);
526  }
527  // Mark block as loaded
528  blockLoaded[blockIdx] = 1;
529  // Track count
531 #endif
532 }

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

722 {
723  // Deallocate the block
724 #if F3D_NO_BLOCKS_ARRAY
725  blocks[blockIdx].clear();
726 #else
727  blocks[blockIdx]->clear();
728 #endif
729  // Mark block as unloaded
730  blockLoaded[blockIdx] = 0;
731  // Track count
733 #if 0
734  // If no active blocks, close the file. De-activate for now.
735  if (m_numActiveBlocks == 0) {
736  closeFile();
737  }
738 #endif
739 }

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

745 {
746 #if F3D_SHORT_MUTEX_ARRAY
747  boost::mutex::scoped_lock lock(blockMutex[blockIdx % blockMutexSize]);
748 #else
749  boost::mutex::scoped_lock lock(blockMutex[blockIdx]);
750 #endif
751  ++refCounts[blockIdx];
752 }

◆ decBlockRef()

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

Decrement reference count on a block.

Definition at line 757 of file SparseFile.h.

758 {
759 #if F3D_SHORT_MUTEX_ARRAY
760  boost::mutex::scoped_lock lock(blockMutex[blockIdx % blockMutexSize]);
761 #else
762  boost::mutex::scoped_lock lock(blockMutex[blockIdx]);
763 #endif
764  --refCounts[blockIdx];
765 }

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

771 {
772  return numVoxels * sizeof(Data_T);
773 }

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

779 {
780  std::vector<int>::const_iterator i = loadCounts.begin();
781  std::vector<int>::const_iterator end = loadCounts.end();
782  int numLoads = 0;
783  for (; i != end; ++i)
784  numLoads += *i;
785 
786  return numLoads;
787 }

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

793 {
794  std::vector<int>::const_iterator i = blockLoaded.begin();
795  std::vector<int>::const_iterator end = blockLoaded.end();
796  int numBlockCounter = 0;
797  for (; i != end; ++i)
798  if (*i)
799  numBlockCounter++;
800 
801  return numBlockCounter;
802 }

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

808 {
809  std::vector<int>::const_iterator i = loadCounts.begin();
810  std::vector<int>::const_iterator li = blockLoaded.begin();
811  std::vector<int>::const_iterator end = loadCounts.end();
812  int numBlockCounter = 0;
813 
814  if (blockLoaded.size() == 0) {
815  for (; i != end; ++i)
816  if (*i)
817  numBlockCounter++;
818  } else {
819  assert(loadCounts.size() == blockLoaded.size());
820 
821  for (; i != end; ++i, ++li)
822  if (*i || *li)
823  numBlockCounter++;
824  }
825 
826  return numBlockCounter;
827 }

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

833 {
834  std::vector<int>::const_iterator i = loadCounts.begin();
835  std::vector<int>::const_iterator end = loadCounts.end();
836  int numLoads = 0, numBlockCounter = 0;
837  for (; i != end; ++i) {
838  if (*i) {
839  numLoads += *i;
840  numBlockCounter++;
841  }
842  }
843 
844  return (float)numLoads / std::max(1, numBlockCounter);
845 }

References detail::max().

◆ resetCacheStatistics()

template<class Data_T >
void SparseFile::Reference< Data_T >::resetCacheStatistics ( )

Resets counts of total block loads.

Definition at line 850 of file SparseFile.h.

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

◆ memSize()

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

Memory use for the Reference.

Definition at line 862 of file SparseFile.h.

863 {
864  boost::mutex::scoped_lock lock(m_mutex);
865 
866  return sizeof(*this) +
867  fileBlockIndices.capacity() * sizeof(int) +
868  blockLoaded.capacity() * sizeof(int) +
870  blocks.capacity() * sizeof(Sparse::SparseBlock<Data_T>*) +
871 #endif
872  blockUsed.capacity() * sizeof(bool) +
873  loadCounts.capacity() * sizeof(int) +
874  refCounts.capacity() * sizeof(int) +
876  blockMutexSize * sizeof(boost::mutex) +
877 #else
878  numBlocks * sizeof(boost::mutex) +
879 #endif
880  sizeof(SparseDataReader<Data_T>);
881 }

References F3D_NO_BLOCKS_ARRAY, and F3D_SHORT_MUTEX_ARRAY.

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

600 {
601  if (this == &o) {
602  return *this;
603  }
604 
605  // Copy public member variables (where appropriate)
606  filename = o.filename;
607  layerPath = o.layerPath;
609  numVoxels = o.numVoxels;
613  blocks = o.blocks;
614  blockUsed = o.blockUsed;
616  refCounts = o.refCounts;
617  if (blockMutex)
618  delete[] blockMutex;
619 #if F3D_SHORT_MUTEX_ARRAY
620 # if F3D_NO_BLOCKS_ARRAY
622 # else
623  blockMutexSize = std::min(static_cast<int>(blocks.size()),
625 # endif
626  blockMutex = new boost::mutex[blockMutexSize];
627 #else
628  blockMutex = new boost::mutex[blocks.size()];
629 #endif
630 
631 #if 0
632  // MW: Should this be copying the file handle? Never seems to happen,
633  // but it also seems bad. Ifdef'ing out for now.
634  // Copy private member variables (where appropriate)
636  // Don't copy id, let hdf5 generate a new one.
637  if (m_fileHandle >= 0) {
639  }
640 #else
641  m_fileHandle = -1;
642 #endif
643 
644  // Re-allocate reader
645  if (m_reader)
646  delete m_reader;
647  m_reader = NULL;
648 
649  m_ogReaderPtr.reset();
650  m_ogReader = NULL;
651 
652  return *this;
653 }

References SparseFile::Reference< Data_T >::blockLoaded, SparseFile::Reference< Data_T >::blocks, SparseFile::Reference< Data_T >::blockUsed, F3D_MUTEX_ARRAY_SIZE, 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, detail::min(), SparseFile::Reference< Data_T >::numVoxels, SparseFile::Reference< Data_T >::occupiedBlocks, SparseFile::Reference< Data_T >::refCounts, and SparseFile::Reference< Data_T >::valuesPerBlock.

Member Data Documentation

◆ filename

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

◆ layerPath

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

◆ valuesPerBlock

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

◆ numVoxels

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

◆ numBlocks

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

Definition at line 130 of file SparseFile.h.

◆ occupiedBlocks

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

◆ fileBlockIndices

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

Index in file for each block.

Definition at line 134 of file SparseFile.h.

Referenced by SparseFile::Reference< Data_T >::operator=(), 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 137 of file SparseFile.h.

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

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

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

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

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

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

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

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

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

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

◆ blockMutexSize

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

Size of the mutex array. Used as modulus base.

Definition at line 158 of file SparseFile.h.

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

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

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

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

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

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

◆ m_ogArchive

template<class Data_T>
IArchivePtr SparseFile::Reference< Data_T >::m_ogArchive
private

Ogawa archive.

Definition at line 246 of file SparseFile.h.

◆ m_ogRoot

template<class Data_T>
OgIGroupPtr SparseFile::Reference< Data_T >::m_ogRoot
private

Ogawa archive root.

Definition at line 248 of file SparseFile.h.

◆ m_ogLayerGroup

template<class Data_T>
OgIGroupPtr SparseFile::Reference< Data_T >::m_ogLayerGroup
private

Ogawa layer group.

Definition at line 250 of file SparseFile.h.

◆ m_mutex

template<class Data_T>
Mutex SparseFile::Reference< Data_T >::m_mutex
mutableprivate

Mutex to prevent two threads from modifying conflicting data.

Definition at line 253 of file SparseFile.h.

◆ m_numActiveBlocks

template<class Data_T>
size_t SparseFile::Reference< Data_T >::m_numActiveBlocks
private

Number of currently active blocks.

Definition at line 256 of file SparseFile.h.


The documentation for this class was generated from the following files:
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:144
SparseFile::Reference::layerPath
std::string layerPath
Definition: SparseFile.h:127
OgSparseDataReader
Definition: SparseFile.h:86
SparseFile::Reference::m_mutex
Mutex m_mutex
Mutex to prevent two threads from modifying conflicting data.
Definition: SparseFile.h:253
SparseFile::Reference::closeFile
void closeFile()
Closes the file. Will be re-opened as needed.
Definition: SparseFile.h:709
Msg::SevWarning
Definition: Log.h:68
SparseFile::Reference::fileIsOpen
bool fileIsOpen()
Checks if the file used by this reference is open already.
Definition: SparseFile.h:668
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:147
Sparse::SparseBlock
Definition: SparseField.h:227
Hdf5Util::H5Base::id
hid_t id() const
Query the hid_t value.
Definition: Hdf5Util.h:100
F3D_SHORT_MUTEX_ARRAY
#define F3D_SHORT_MUTEX_ARRAY
Definition: SparseFile.h:63
SparseFile::Reference::Ptr
Reference * Ptr
Definition: SparseFile.h:115
SparseFile::Reference::m_numActiveBlocks
size_t m_numActiveBlocks
Number of currently active blocks.
Definition: SparseFile.h:256
SparseFile::Reference::m_fileHandle
hid_t m_fileHandle
Holds the Hdf5 handle to the file.
Definition: SparseFile.h:230
SparseFile::Reference::blockMutexSize
int blockMutexSize
Size of the mutex array. Used as modulus base.
Definition: SparseFile.h:158
SparseFile::Reference::m_ogRoot
OgIGroupPtr m_ogRoot
Ogawa archive root.
Definition: SparseFile.h:248
SparseFile::Reference::m_ogReaderPtr
boost::shared_ptr< OgSparseDataReader< Data_T > > m_ogReaderPtr
Shared pointer to the ogawa reader.
Definition: SparseFile.h:241
SparseFile::Reference::m_ogArchive
IArchivePtr m_ogArchive
Ogawa archive.
Definition: SparseFile.h:246
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:140
Sparse::SparseBlock::clear
void clear()
Remove data.
Definition: SparseField.h:273
detail::max
T max(const T a, const T2 b)
Max operation on mixed types.
Definition: FieldSampler.h:32
SparseFile::Reference::m_ogReader
OgSparseDataReader< Data_T > * m_ogReader
Pointer to the ogawa reader. NULL at construction time. Created in openFile().
Definition: SparseFile.h:244
SparseFile::Reference::m_reader
SparseDataReader< Data_T > * m_reader
Pointer to the reader object. NULL at construction time. Created in openFile().
Definition: SparseFile.h:238
SparseFile::Reference::fileBlockIndices
std::vector< int > fileBlockIndices
Index in file for each block.
Definition: SparseFile.h:134
Sparse::SparseBlock::resize
void resize(int n)
Alloc data.
Definition: SparseField.h:259
Hdf5Util::H5ScopedGopen::open
void open(hid_t parentLocation, const std::string &name)
Definition: Hdf5Util.h:210
SparseFile::Reference::m_ogLayerGroup
OgIGroupPtr m_ogLayerGroup
Ogawa layer group.
Definition: SparseFile.h:250
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:151
SparseDataReader
This class gets used by SparseFieldIO and SparseFileManager to read the block data....
Definition: SparseDataReader.h:70
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:558
g_hdf5Mutex
FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
Definition: Hdf5Util.cpp:67
Exc
Namespace for Exception objects.
Definition: Exception.h:57
GlobalLock
boost::recursive_mutex::scoped_lock GlobalLock
Definition: Hdf5Util.h:78
Hdf5Util
Contains utility functions and classes for Hdf5 files.
Definition: Hdf5Util.h:86
SparseFile::Reference::occupiedBlocks
int occupiedBlocks
Definition: SparseFile.h:131
SparseFile::Reference::numBlocks
int numBlocks
Definition: SparseFile.h:130
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:155
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:234
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:137
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
detail::min
T min(const T a, const T2 b)
Min operation on mixed types.
Definition: FieldSampler.h:25
F3D_MUTEX_ARRAY_SIZE
#define F3D_MUTEX_ARRAY_SIZE
Definition: SparseFile.h:64
SparseFile::Reference::numVoxels
int numVoxels
Definition: SparseFile.h:129
SparseFile::Reference::filename
std::string filename
Definition: SparseFile.h:126
SparseFile::Reference::valuesPerBlock
int valuesPerBlock
Definition: SparseFile.h:128
F3D_NO_BLOCKS_ARRAY
#define F3D_NO_BLOCKS_ARRAY
Definition: SparseFile.h:65