44 : m_cell_cache_manager(cell_cache_manager) {
47 = cfg.get_i32(
"AccessGroup.GarbageThreshold.Percentage") / 100.0;
56 lock_guard<mutex> lock(
m_mutex);
60 for (
auto cf_spec : ag_spec->
columns()) {
61 if (cf_spec->get_option_max_versions() > 0)
63 if (cf_spec->get_option_ttl() > 0) {
65 m_min_ttl = (time_t)cf_spec->get_option_ttl();
66 else if (cf_spec->get_option_ttl() <
m_min_ttl)
76 bool collection_performed) {
77 lock_guard<mutex> lock(
m_mutex);
81 for (
auto csi : stores) {
88 if (collection_performed) {
95 const std::string &label) {
96 lock_guard<mutex> lock(
m_mutex);
101 out << label <<
"\tlast_collection_disk_usage\t"
105 out << label <<
"\tmin_ttl\t" <<
m_min_ttl <<
"\n";
106 out << label <<
"\thave_max_versions\t"
108 out << label <<
"\tin_memory\t" << (
m_in_memory ?
"true" :
"false") <<
"\n";
110 out << label <<
"\tmemory_accumulated\t"
116 lock_guard<mutex> lock(
m_mutex);
137 lock_guard<mutex> lock(
m_mutex);
141 double garbage_ratio = garbage / total;
147 if (gc_needed == (check_deletes||check_ttl))
152 if (have_garbage && check_deletes != gc_needed) {
153 if (garbage_ratio > 0) {
154 int64_t new_accum_data_target =
158 new_accum_data_target *= 1.15;
171 if (
m_min_ttl > 0 && check_ttl != gc_needed) {
172 if (garbage_ratio > 0) {
173 time_t new_elapsed_target =
176 new_elapsed_target *= 1.15;
197 return (accum < 0) ? 0 : accum;
227 double possible_garbage_ratio = possible_garbage / total_size;
int64_t m_accum_data_target
Amount of data to accummulate before signaling GC likely needed (adaptive)
void update_cellstore_info(std::vector< CellStoreInfo > &stores, time_t t=0, bool collection_performed=true)
Updates stored data statistics from current set of CellStores.
int64_t m_current_disk_usage
Current disk usage, updated by update_cellstore_info()
int64_t m_accum_data_target_minimum
Minimum amount of data to accummulate before signaling GC likely needed.
time_t m_min_ttl
Minimum TTL found in access group schema.
int64_t m_stored_expirable
Amount of data accumulated in cell stores that could expire due to TTL.
int64_t get_output_bytes()
bool m_have_max_versions
true if any column families have non-zero MAX_VERSIONS
bool check_needed_deletes()
Signals if GC is likely needed due to MAX_VERSIONS or deletes.
bool m_in_memory
true if access group is in memory
int64_t memory_accumulated_since_collection()
Computes the amount of in-memory data accumulated since last collection.
int64_t total_accumulated_since_collection()
Computes the total amount of data accumulated since last collection.
bool get_option_in_memory() const
Gets in memory option.
time_t m_last_collection_time
Time of last garbage collection
std::shared_ptr< Properties > PropertiesPtr
bool check_needed(time_t now)
Signals if garbage collection is likely needed.
Logging routines and macros.
Compatibility Macros for C/C++.
void update_schema(AccessGroupSpec *ag_spec)
Updates control variables from access group schema definition.
AccessGroupGarbageTracker(PropertiesPtr &props, CellCacheManagerPtr &cell_cache_manager, AccessGroupSpec *ag_spec)
Constructor.
CellCacheManagerPtr m_cell_cache_manager
Cell cache manager
int64_t compute_delete_count()
Computes number of delete records in access group.
Access group specification.
double m_garbage_threshold
Fraction of accumulated garbage that triggers collection.
Helper class to access parts of the properties.
ColumnFamilySpecs & columns()
Returns reference to column specifications.
int64_t m_last_collection_disk_usage
Disk usage at the time the last garbage collection was performed.
uint32_t m_stored_deletes
Number of delete records accumulated in cell stores.
std::mutex m_mutex
Mutex to serialize access to data members
void output_state(std::ofstream &out, const std::string &label)
Prints a human-readable representation of internal state to an output stream.
bool check_needed_ttl(time_t now)
Signals if GC is likeley needed due to TTL.
time_t m_elapsed_target_minimum
Minimum elapsed seconds required before signaling TTL GC likely needed.
time_t m_elapsed_target
Elapsed seconds required before signaling TTL GC likely needed (adaptive)
std::shared_ptr< CellCacheManager > CellCacheManagerPtr
Smart pointer to CellCacheManager.
void adjust_targets(time_t now, double total, double garbage)
Adjusts targets based on measured garbage.
Declarations for AccessGroupGarbageTracker.
int64_t get_input_bytes()
Merge scanner for access groups.