gatb.core-API-0.0.0
PartitionCache< Type > Class Template Reference

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 ()
 

Detailed Description

template<typename Type>
class gatb::core::tools::storage::impl::PartitionCache< Type >

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

Constructor & Destructor Documentation

PartitionCache ( Partition< Type > &  ref,
size_t  nbItemsCache,
system::ISynchronizer synchro = 0 
)

Constructor

PartitionCache ( const PartitionCache< Type > &  p)

Copy constructor.

Destructor.

Member Function Documentation

void flush ( )

Flush the whole partition (ie flush each collection).

collections::impl::CollectionCache<Type>& operator[] ( size_t  idx)

Get the ith collection

Parameters
[in]idx: index of the collection to be retrieved
Returns
the wanted collection.
void remove ( )

Remove physically the partition (ie. remove each collection).

size_t size ( ) const

Return the number of collections for this partition.

Returns
the number of collections.

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