0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
Hypertable::CellCacheManager Class Reference

Manages the cell cache of an access group. More...

#include <CellCacheManager.h>

Public Member Functions

 CellCacheManager ()
 Constructor. More...
 
virtual ~CellCacheManager ()
 Destructor. More...
 
void install_new_active_cache (CellCachePtr new_cache)
 Installs a new active cache. More...
 
void install_new_immutable_cache (CellCachePtr new_cache)
 Installs a new immutable cache. More...
 
void merge_caches (SchemaPtr &schema)
 Merges immutable cache into active cache. More...
 
void add (const Key &key, const ByteString value)
 Inserts a key/value pair to the active cache. More...
 
void add_counter (const Key &key, const ByteString value)
 Inserts a key/value pair for a counter column into the active cache. More...
 
void add (CellListScannerPtr &scanner)
 Inserts key/value pairs from a scanner into the active cache. More...
 
void add_immutable_scanner (MergeScannerAccessGroup *mscanner, ScanContext *scan_ctx)
 Creates a scanner on the immutable cache and adds it to a merge scanner. More...
 
void add_scanners (MergeScannerAccessGroup *scanner, ScanContext *scan_ctx)
 Creates scanners on the active and immutable caches and adds them to a merge scanner. More...
 
void split_row_estimate_data (CellList::SplitRowDataMapT &split_row_data)
 Populates map of split row data. More...
 
CellListScannerPtr create_immutable_scanner (ScanContext *scan_ctx)
 Creates and returns a scanner on the immutable cache. More...
 
void lock ()
 Locks the active cache. More...
 
void unlock ()
 Unlocks the active cache. More...
 
CellCachePtractive_cache ()
 Returns a pointer to the active cache. More...
 
CellCachePtrimmutable_cache ()
 Returns a pointer to the immutable cache. More...
 
void drop_immutable_cache ()
 Drops the immutable cache. More...
 
size_t immutable_items ()
 Returns the number of cells in the immutable cache. More...
 
bool empty ()
 Checks if active and immutable caches are empty. More...
 
bool immutable_cache_empty ()
 Checks if immutable cache is not installed or is empty. More...
 
int64_t memory_used ()
 Returns the amount of memory used by the active and immutable caches. More...
 
int64_t logical_size ()
 Returns the logical amount of memory used by the active and immutable caches. More...
 
void get_cache_statistics (CellCache::Statistics &stats)
 Gets cache statistics. More...
 
int32_t delete_count ()
 Returns the number of deletes present in the caches. More...
 
void freeze ()
 Freezes the active cache. More...
 
void populate_key_set (KeySet &keys)
 Populates a set with all keys in the cell caches. More...
 

Private Attributes

CellCachePtr m_active_cache
 Active cache. More...
 
CellCachePtr m_immutable_cache
 Immutable cache. More...
 

Detailed Description

Manages the cell cache of an access group.

When an access group undergoes a compaction, the cell cache needs to be frozen (i.e. made immutable) before it is written out to a cell store file. This class manages this process by maintaining two caches, an active cache that receives inserts, and an immutable cache, created when the active cache is frozen in preparation for a compaction. It provides member functions for freezing the active cache to the immutable cache, dropping the immutable cache when it is no longer needed, and merging the two caches back together if a compaction was aborted.

Definition at line 54 of file CellCacheManager.h.

Constructor & Destructor Documentation

Hypertable::CellCacheManager::CellCacheManager ( )
inline

Constructor.

Initializes m_active_cache with a newly allocated CellCache

Definition at line 60 of file CellCacheManager.h.

virtual Hypertable::CellCacheManager::~CellCacheManager ( )
inlinevirtual

Destructor.

Definition at line 63 of file CellCacheManager.h.

Member Function Documentation

CellCachePtr& Hypertable::CellCacheManager::active_cache ( )
inline

Returns a pointer to the active cache.

Returns
Pointer to the active cache.

Definition at line 153 of file CellCacheManager.h.

void Hypertable::CellCacheManager::add ( const Key key,
const ByteString  value 
)
inline

Inserts a key/value pair to the active cache.

Adds key and value directly into m_active_cache.

Note
lock() must be called before calling this function.
Parameters
keykey to be inserted
valuevalue to inserted

Definition at line 88 of file CellCacheManager.h.

void CellCacheManager::add ( CellListScannerPtr scanner)

Inserts key/value pairs from a scanner into the active cache.

This method retrieves all key/value pairs from scanner and inserts them into the active cache.

Parameters
scannerScanner from which to fetch key/value pairs

Definition at line 75 of file CellCacheManager.cc.

void Hypertable::CellCacheManager::add_counter ( const Key key,
const ByteString  value 
)
inline

Inserts a key/value pair for a counter column into the active cache.

Adds key and value directly into m_active_cache.

Note
lock() must be called before calling this function.
Parameters
keykey to be inserted
valuevalue to inserted

Definition at line 98 of file CellCacheManager.h.

void CellCacheManager::add_immutable_scanner ( MergeScannerAccessGroup mscanner,
ScanContext scan_ctx 
)

Creates a scanner on the immutable cache and adds it to a merge scanner.

If an immutable cache is installed, a scanner is created on it and added to mscanner.

Parameters
mscannerMerge scanner to which immutable cache scanner should be added
scan_ctxScan context for initializing immutable cache scanner

Definition at line 84 of file CellCacheManager.cc.

void CellCacheManager::add_scanners ( MergeScannerAccessGroup scanner,
ScanContext scan_ctx 
)

Creates scanners on the active and immutable caches and adds them to a merge scanner.

If the active cache is not empty, a scanner is created on it and added to scanner. If an immutable cache is installed, a scanner is created on it and added to scanner as well.

Parameters
scannerMerge scanner to which immutable cache scanner should be added
scan_contextScan context for initializing scanners

Definition at line 90 of file CellCacheManager.cc.

CellListScannerPtr Hypertable::CellCacheManager::create_immutable_scanner ( ScanContext scan_ctx)
inline

Creates and returns a scanner on the immutable cache.

If m_immutable_cache is not empty, then a scanner is created on it and returned, otherwise, 0 is returned.

Parameters
scan_ctxScan context for initializing immutable cache scanner
Returns
Newly created scanner on the immutable cache, or 0 if an immutable cache is not installed.

Definition at line 140 of file CellCacheManager.h.

int32_t CellCacheManager::delete_count ( )

Returns the number of deletes present in the caches.

This function returns the sum of the delete counts from the active and immutable caches.

Returns
Number of deletes present in the caches.

Definition at line 122 of file CellCacheManager.cc.

void Hypertable::CellCacheManager::drop_immutable_cache ( )
inline

Drops the immutable cache.

Definition at line 164 of file CellCacheManager.h.

bool Hypertable::CellCacheManager::empty ( )
inline

Checks if active and immutable caches are empty.

Returns
true if active cache is empty and immutable cache is not installed or is empty, false otherwise.

Definition at line 175 of file CellCacheManager.h.

void CellCacheManager::freeze ( )

Freezes the active cache.

This function sets the immutable cache to the active cache and points the active cache to a newly allocated (empty) cache.

Definition at line 127 of file CellCacheManager.cc.

void CellCacheManager::get_cache_statistics ( CellCache::Statistics stats)

Gets cache statistics.

This function computes the sum of the cache statistics from the active and immutable caches.

Parameters
statsReference to cell cache statistics structure

Definition at line 116 of file CellCacheManager.cc.

CellCachePtr& Hypertable::CellCacheManager::immutable_cache ( )
inline

Returns a pointer to the immutable cache.

Returns a pointer to the immutable cache if it is installed, otherewise nullptr.

Returns
Pointer to the immutable cache.

Definition at line 159 of file CellCacheManager.h.

bool Hypertable::CellCacheManager::immutable_cache_empty ( )
inline

Checks if immutable cache is not installed or is empty.

Returns
true if immutable cache is not installed or is empty, false otherwise.

Definition at line 182 of file CellCacheManager.h.

size_t Hypertable::CellCacheManager::immutable_items ( )
inline

Returns the number of cells in the immutable cache.

Returns
Number of cells in the immutable cache.

Definition at line 168 of file CellCacheManager.h.

void Hypertable::CellCacheManager::install_new_active_cache ( CellCachePtr  new_cache)
inline

Installs a new active cache.

This function replaces m_active_cache with new_cache.

Parameters
new_cacheNew active cache

Definition at line 68 of file CellCacheManager.h.

void Hypertable::CellCacheManager::install_new_immutable_cache ( CellCachePtr  new_cache)
inline

Installs a new immutable cache.

This function replaces m_immutable_cache with new_cache.

Parameters
new_cacheNew immutable cache

Definition at line 75 of file CellCacheManager.h.

void Hypertable::CellCacheManager::lock ( )
inline

Locks the active cache.

Definition at line 146 of file CellCacheManager.h.

int64_t CellCacheManager::logical_size ( )

Returns the logical amount of memory used by the active and immutable caches.

This member function calls CellCache::logical_size() on the active and immutable caches and returns their sum.

Returns
Amount of logical memory used by the active and immutable caches

Definition at line 111 of file CellCacheManager.cc.

int64_t CellCacheManager::memory_used ( )

Returns the amount of memory used by the active and immutable caches.

This member function calls CellCache::memory_used() on the active and immutable caches and returns their sum.

Returns
Amount of memory used by the active and immutable caches.

Definition at line 106 of file CellCacheManager.cc.

void CellCacheManager::merge_caches ( SchemaPtr schema)

Merges immutable cache into active cache.

Definition at line 39 of file CellCacheManager.cc.

void CellCacheManager::populate_key_set ( KeySet keys)

Populates a set with all keys in the cell caches.

This function inserts all keys from the active cache and the immutable cache into keys.

Parameters
keysKey set

Definition at line 132 of file CellCacheManager.cc.

void CellCacheManager::split_row_estimate_data ( CellList::SplitRowDataMapT split_row_data)

Populates map of split row data.

This method calls CellCache::split_row_estimate_data() on both the active and immutable caches to add data to split_row_data.

Parameters
split_row_dataMap of split row data.

Definition at line 99 of file CellCacheManager.cc.

void Hypertable::CellCacheManager::unlock ( )
inline

Unlocks the active cache.

Definition at line 149 of file CellCacheManager.h.

Member Data Documentation

CellCachePtr Hypertable::CellCacheManager::m_active_cache
private

Active cache.

Definition at line 224 of file CellCacheManager.h.

CellCachePtr Hypertable::CellCacheManager::m_immutable_cache
private

Immutable cache.

Definition at line 227 of file CellCacheManager.h.


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