Skip to content

Commit c10721b

Browse files
committed
add more UTs
Signed-off-by: freemandealer <[email protected]>
1 parent 0efcb61 commit c10721b

File tree

3 files changed

+435
-1
lines changed

3 files changed

+435
-1
lines changed

be/src/io/cache/block_file_cache.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ void BlockFileCache::find_evict_candidates(LRUQueue& queue, size_t size, size_t
950950
DCHECK(file_block->_download_state == FileBlock::State::DOWNLOADED);
951951
to_evict.push_back(cell);
952952
removed_size += cell_size;
953+
cur_removed_size += cell_size;
953954
}
954955
}
955956
}
@@ -1990,6 +1991,36 @@ std::map<std::string, double> BlockFileCache::get_stats() {
19901991
return stats;
19911992
}
19921993

1994+
// for be UTs
1995+
std::map<std::string, double> BlockFileCache::get_stats_unsafe() {
1996+
std::map<std::string, double> stats;
1997+
stats["hits_ratio"] = (double)_hit_ratio->get_value();
1998+
stats["hits_ratio_5m"] = (double)_hit_ratio_5m->get_value();
1999+
stats["hits_ratio_1h"] = (double)_hit_ratio_1h->get_value();
2000+
2001+
stats["index_queue_max_size"] = (double)_index_queue.get_max_size();
2002+
stats["index_queue_curr_size"] = (double)_index_queue.get_capacity_unsafe();
2003+
stats["index_queue_max_elements"] = (double)_index_queue.get_max_element_size();
2004+
stats["index_queue_curr_elements"] = (double)_index_queue.get_elements_num_unsafe();
2005+
2006+
stats["ttl_queue_max_size"] = (double)_ttl_queue.get_max_size();
2007+
stats["ttl_queue_curr_size"] = (double)_ttl_queue.get_capacity_unsafe();
2008+
stats["ttl_queue_max_elements"] = (double)_ttl_queue.get_max_element_size();
2009+
stats["ttl_queue_curr_elements"] = (double)_ttl_queue.get_elements_num_unsafe();
2010+
2011+
stats["normal_queue_max_size"] = (double)_normal_queue.get_max_size();
2012+
stats["normal_queue_curr_size"] = (double)_normal_queue.get_capacity_unsafe();
2013+
stats["normal_queue_max_elements"] = (double)_normal_queue.get_max_element_size();
2014+
stats["normal_queue_curr_elements"] = (double)_normal_queue.get_elements_num_unsafe();
2015+
2016+
stats["disposable_queue_max_size"] = (double)_disposable_queue.get_max_size();
2017+
stats["disposable_queue_curr_size"] = (double)_disposable_queue.get_capacity_unsafe();
2018+
stats["disposable_queue_max_elements"] = (double)_disposable_queue.get_max_element_size();
2019+
stats["disposable_queue_curr_elements"] = (double)_disposable_queue.get_elements_num_unsafe();
2020+
2021+
return stats;
2022+
}
2023+
19932024
template void BlockFileCache::remove(FileBlockSPtr file_block,
19942025
std::lock_guard<std::mutex>& cache_lock,
19952026
std::lock_guard<std::mutex>& block_lock);

be/src/io/cache/block_file_cache.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ class BlockFileCache {
145145

146146
std::map<std::string, double> get_stats();
147147

148+
// for be UTs
149+
std::map<std::string, double> get_stats_unsafe();
150+
148151
class LRUQueue {
149152
public:
150153
LRUQueue() = default;
@@ -179,6 +182,10 @@ class BlockFileCache {
179182
return cache_size;
180183
}
181184

185+
size_t get_capacity_unsafe() const { return cache_size; }
186+
187+
size_t get_elements_num_unsafe() const { return queue.size(); }
188+
182189
size_t get_elements_num(std::lock_guard<std::mutex>& /* cache_lock */) const {
183190
return queue.size();
184191
}

0 commit comments

Comments
 (0)