0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CellCacheManager.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Hypertable_RangeServer_CellCacheManager_h
28 #define Hypertable_RangeServer_CellCacheManager_h
29 
35 
36 #include <Hypertable/Lib/Schema.h>
37 
38 #include <memory>
39 
40 namespace Hypertable {
41 
44 
55 
56  public:
57 
61 
63  virtual ~CellCacheManager() { }
64 
69  m_active_cache = new_cache;
70  }
71 
76  m_immutable_cache = new_cache;
77  }
78 
80  void merge_caches(SchemaPtr &schema);
81 
88  void add(const Key &key, const ByteString value) {
89  m_active_cache->add(key, value);
90  }
91 
98  void add_counter(const Key &key, const ByteString value) {
99  m_active_cache->add_counter(key, value);
100  }
101 
106  void add(CellListScannerPtr &scanner);
107 
115  ScanContext *scan_ctx);
116 
126  ScanContext *scan_ctx);
127 
133 
141  return m_immutable_cache ?
142  m_immutable_cache->create_scanner(scan_ctx) : CellListScannerPtr();
143  }
144 
146  void lock() { m_active_cache->lock(); }
147 
149  void unlock() { m_active_cache->unlock(); }
150 
154 
160  return m_immutable_cache;
161  }
162 
165 
168  size_t immutable_items() {
169  return m_immutable_cache ? m_immutable_cache->size() : 0;
170  }
171 
175  bool empty() {
176  return m_active_cache->empty() && immutable_cache_empty();
177  }
178 
183  return !m_immutable_cache || m_immutable_cache->empty();
184  }
185 
190  int64_t memory_used();
191 
196  int64_t logical_size();
197 
203 
208  int32_t delete_count();
209 
213  void freeze();
214 
219  void populate_key_set(KeySet &keys);
220 
221  private:
222 
225 
228  };
229 
231  typedef std::shared_ptr<CellCacheManager> CellCacheManagerPtr;
232 
234 
235 }
236 
237 #endif // Hypertable_RangeServer_CellCacheManager_h
void install_new_active_cache(CellCachePtr new_cache)
Installs a new active cache.
Represents a sorted list of key/value pairs in memory.
Definition: CellCache.h:52
void add_counter(const Key &key, const ByteString value)
Inserts a key/value pair for a counter column into the active cache.
Holds cache statistics.
Definition: CellCache.h:57
int64_t logical_size()
Returns the logical amount of memory used by the active and immutable caches.
CellCachePtr m_active_cache
Active cache.
Manages the cell cache of an access group.
void populate_key_set(KeySet &keys)
Populates a set with all keys in the cell caches.
Declarations for MergeScannerAccessGroup.
void add_immutable_scanner(MergeScannerAccessGroup *mscanner, ScanContext *scan_ctx)
Creates a scanner on the immutable cache and adds it to a merge scanner.
void drop_immutable_cache()
Drops the immutable cache.
size_t immutable_items()
Returns the number of cells in the immutable cache.
int64_t memory_used()
Returns the amount of memory used by the active and immutable caches.
int32_t delete_count()
Returns the number of deletes present in the caches.
Scan context information.
Definition: ScanContext.h:52
virtual ~CellCacheManager()
Destructor.
CellCachePtr & immutable_cache()
Returns a pointer to the immutable cache.
void split_row_estimate_data(CellList::SplitRowDataMapT &split_row_data)
Populates map of split row data.
Declarations for Schema.
A class managing one or more serializable ByteStrings.
Definition: ByteString.h:47
std::set< Key, key_revision_lt > KeySet
Definition: CellCache.h:44
void add_scanners(MergeScannerAccessGroup *scanner, ScanContext *scan_ctx)
Creates scanners on the active and immutable caches and adds them to a merge scanner.
void unlock()
Unlocks the active cache.
std::map< const char *, int64_t, LtCstr, SplitRowDataAlloc > SplitRowDataMapT
Definition: CellList.h:66
bool empty()
Checks if active and immutable caches are empty.
Declarations for ScanContext.
Hypertable definitions
Provides access to internal components of opaque key.
Definition: Key.h:40
CellListScannerPtr create_immutable_scanner(ScanContext *scan_ctx)
Creates and returns a scanner on the immutable cache.
void get_cache_statistics(CellCache::Statistics &stats)
Gets cache statistics.
CellCachePtr & active_cache()
Returns a pointer to the active cache.
CellCachePtr m_immutable_cache
Immutable cache.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
std::shared_ptr< CellListScanner > CellListScannerPtr
Definition: CellList.h:35
bool immutable_cache_empty()
Checks if immutable cache is not installed or is empty.
void freeze()
Freezes the active cache.
std::shared_ptr< CellCacheManager > CellCacheManagerPtr
Smart pointer to CellCacheManager.
void lock()
Locks the active cache.
void merge_caches(SchemaPtr &schema)
Merges immutable cache into active cache.
std::shared_ptr< CellCache > CellCachePtr
Shared smart pointer to CellCache.
Definition: CellCache.h:163
void add(const Key &key, const ByteString value)
Inserts a key/value pair to the active cache.
Merge scanner for access groups.
void install_new_immutable_cache(CellCachePtr new_cache)
Installs a new immutable cache.