AliceVision
Photogrammetric Computer Vision Framework
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
aliceVision::image::CacheManager Class Referenceabstract
Inheritance diagram for aliceVision::image::CacheManager:
aliceVision::image::TileCacheManager

Classes

struct  MemoryItem
 
struct  MRUItem
 

Public Types

using IndexedStoragePaths = std::unordered_map< size_t, std::string >
 
using IndexedFreeBlocks = std::unordered_map< size_t, std::list< size_t > >
 
using MemoryMap = std::map< size_t, MemoryItem >
 
using MRUType = boost::multi_index::multi_index_container< MRUItem, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_unique< boost::multi_index::member< MRUItem, size_t, &MRUItem::objectId > >> >
 

Public Member Functions

 CacheManager (const std::string &pathStorage, size_t blockSize, size_t maxBlocksPerIndex)
 
void setMaxMemory (size_t maxMemorySize)
 
void setInCoreMaxObjectCount (size_t max)
 
bool createObject (size_t &objectId, size_t blockCount)
 
bool acquireObject (std::unique_ptr< unsigned char > &data, size_t objectId)
 
size_t getActiveBlocks () const
 

Protected Member Functions

std::string getPathForIndex (size_t indexId)
 
void deleteIndexFiles ()
 
void wipe ()
 
bool prepareBlockGroup (size_t startBlockId, size_t blocksCount)
 
std::unique_ptr< unsigned char > load (size_t startBlockId, size_t blocksCount)
 
bool save (std::unique_ptr< unsigned char > &&data, size_t startBlockId, size_t blockCount)
 
bool saveObject (std::unique_ptr< unsigned char > &&data, size_t objectId)
 
virtual void onRemovedFromMRU (size_t objectId)=0
 
void addFreeBlock (size_t blockId, size_t blockCount)
 
size_t getFreeBlockId (size_t blockCount)
 

Protected Attributes

size_t _blockSize {0}
 
size_t _incoreBlockUsageCount {0}
 
size_t _incoreBlockUsageMax {0}
 
size_t _blockCountPerIndex {0}
 
size_t _nextStartBlockId {0}
 
size_t _nextObjectId {0}
 
std::string _basePathStorage
 
IndexedStoragePaths _indexPaths
 
IndexedFreeBlocks _freeBlocks
 
MRUType _mru
 
MemoryMap _memoryMap
 

Member Typedef Documentation

◆ MRUType

using aliceVision::image::CacheManager::MRUType = boost::multi_index::multi_index_container< MRUItem, boost::multi_index::indexed_by<boost::multi_index::sequenced<>, boost::multi_index::hashed_unique<boost::multi_index::member<MRUItem, size_t, &MRUItem::objectId> >> >

Most recently used object container Used to know which objects have not been used for some time

Constructor & Destructor Documentation

◆ CacheManager()

aliceVision::image::CacheManager::CacheManager ( const std::string &  pathStorage,
size_t  blockSize,
size_t  maxBlocksPerIndex 
)

Create a cache manager Each created object is associated to this manager.

Parameters
pathStoragethe path to the directory where the file will be stored
blockSizethe base size of an object
maxTilesPerIndexthe maximal number of blocks for a given file (give a maximal size for a cache file)

Member Function Documentation

◆ acquireObject()

bool aliceVision::image::CacheManager::acquireObject ( std::unique_ptr< unsigned char > &  data,
size_t  objectId 
)

Acquire a given object

Parameters
datathe result data acquired
objectIdthe object index to acquire
Returns
true if the object was acquired

◆ createObject()

bool aliceVision::image::CacheManager::createObject ( size_t &  objectId,
size_t  blockCount 
)

Create a new object of size block count

Parameters
objectIdthe created object index
blockCountthe required size for this object (In number of blocks)
Returns
true if the object was created

◆ getActiveBlocks()

size_t aliceVision::image::CacheManager::getActiveBlocks ( ) const

Get the number of managed blocks

Returns
a block count

◆ setInCoreMaxObjectCount()

void aliceVision::image::CacheManager::setInCoreMaxObjectCount ( size_t  max)

Set the maximal number number of items simultaneously in core

Parameters
maxthe maximal number of items

◆ setMaxMemory()

void aliceVision::image::CacheManager::setMaxMemory ( size_t  maxMemorySize)

Set the maximal memory size

Parameters
maxthe maximal memory size

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