gatb.core-API-0.0.0
|
Cache (with potential synchronization) of a Partition. More...
#include <Storage.hpp>
Public Member Functions | |
PartitionCache (Partition< Type > &ref, size_t nbItemsCache, system::ISynchronizer *synchro=0) | |
PartitionCache (const PartitionCache< Type > &p) | |
~PartitionCache () | |
size_t | size () const |
collections::impl::CollectionCache< Type > & | operator[] (size_t idx) |
void | flush () |
void | remove () |
Cache (with potential synchronization) of a Partition.
This class implements a cache for a Partition instance: -> an 'insert' is first cached in memory; when the cache is full, all the items are inserted in the real partition -> flushing the cache in the real partition is protected with a synchronizer
A typical use case is to create several PartitionCache referring the same Partition, and use them independently in different threads => in each thread, we will work on the local (cached) partition like a normal partition (ie. use 'insert'), but without taking care to the concurrent accesses to the referred partition (it is checked by the PartitionCache class).
PartitionCache | ( | Partition< Type > & | ref, |
size_t | nbItemsCache, | ||
system::ISynchronizer * | synchro = 0 |
||
) |
Constructor
PartitionCache | ( | const PartitionCache< Type > & | p | ) |
Copy constructor.
~PartitionCache | ( | ) |
Destructor.
void flush | ( | ) |
Flush the whole partition (ie flush each collection).
collections::impl::CollectionCache<Type>& operator[] | ( | size_t | idx | ) |
Get the ith collection
[in] | idx | : index of the collection to be retrieved |
void remove | ( | ) |
Remove physically the partition (ie. remove each collection).
size_t size | ( | ) | const |
Return the number of collections for this partition.