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... | |
CellCachePtr & | active_cache () |
Returns a pointer to the active cache. More... | |
CellCachePtr & | immutable_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... | |
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.
|
inline |
Constructor.
Initializes m_active_cache with a newly allocated CellCache
Definition at line 60 of file CellCacheManager.h.
|
inlinevirtual |
Destructor.
Definition at line 63 of file CellCacheManager.h.
|
inline |
Returns a pointer to the active cache.
Definition at line 153 of file CellCacheManager.h.
|
inline |
Inserts a key/value pair to the active cache.
Adds key
and value
directly into m_active_cache.
key | key to be inserted |
value | value 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.
scanner | Scanner from which to fetch key/value pairs |
Definition at line 75 of file CellCacheManager.cc.
|
inline |
Inserts a key/value pair for a counter column into the active cache.
Adds key
and value
directly into m_active_cache.
key | key to be inserted |
value | value 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
.
mscanner | Merge scanner to which immutable cache scanner should be added |
scan_ctx | Scan 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.
scanner | Merge scanner to which immutable cache scanner should be added |
scan_context | Scan context for initializing scanners |
Definition at line 90 of file CellCacheManager.cc.
|
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.
scan_ctx | Scan context for initializing immutable cache scanner |
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.
Definition at line 122 of file CellCacheManager.cc.
|
inline |
Drops the immutable cache.
Definition at line 164 of file CellCacheManager.h.
|
inline |
Checks if active and immutable caches are empty.
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.
stats | Reference to cell cache statistics structure |
Definition at line 116 of file CellCacheManager.cc.
|
inline |
Returns a pointer to the immutable cache.
Returns a pointer to the immutable cache if it is installed, otherewise nullptr.
Definition at line 159 of file CellCacheManager.h.
|
inline |
Checks if immutable cache is not installed or is empty.
Definition at line 182 of file CellCacheManager.h.
|
inline |
Returns the number of cells in the immutable cache.
Definition at line 168 of file CellCacheManager.h.
|
inline |
Installs a new active cache.
This function replaces m_active_cache with new_cache
.
new_cache | New active cache |
Definition at line 68 of file CellCacheManager.h.
|
inline |
Installs a new immutable cache.
This function replaces m_immutable_cache with new_cache
.
new_cache | New immutable cache |
Definition at line 75 of file CellCacheManager.h.
|
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.
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.
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
.
keys | Key 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
.
split_row_data | Map of split row data. |
Definition at line 99 of file CellCacheManager.cc.
|
inline |
Unlocks the active cache.
Definition at line 149 of file CellCacheManager.h.
|
private |
Active cache.
Definition at line 224 of file CellCacheManager.h.
|
private |
Immutable cache.
Definition at line 227 of file CellCacheManager.h.