MCPcopy Create free account
hub / github.com/ByConity/ByConity / get

Method get

src/Statistics/StatisticsCache.cpp:26–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26std::shared_ptr<StatsCollection> StatisticsCache::get(const UUID & table, const std::optional<String> & column)
27{
28 auto now = chrono::steady_clock::now();
29 std::shared_lock lck(mutex);
30 if (auto iter = impl.find(table); iter != impl.end())
31 {
32 auto key = column.value_or("");
33 if (auto iter2 = iter->second.find(key); iter2 != iter->second.end())
34 {
35 auto entry = iter2->second;
36 if (now > entry.expire_time_point)
37 {
38 // we don't delete expired cache entry here since we are holding a shared mutex
39 // expired entry will be cleaned only when invalidate and update
40 // since normally a missed cache will usually be followed with a update request
41 // this design won't have any performance issues comparing to Poco::ExpiredCache
42 return nullptr;
43 }
44 return entry.data;
45 }
46 }
47 return nullptr;
48}
49
50void StatisticsCache::update(const UUID & table, const std::optional<String> column, std::shared_ptr<StatsCollection> data)
51{

Callers 13

readFromCatalogImplMethod · 0.45
tryGetInstanceMethod · 0.45
fromJsonStrMethod · 0.45
getTablesFromScopeFunction · 0.45
getUUIDFunction · 0.45
getVectorStringFunction · 0.45
submitAsyncTasksFunction · 0.45
decayDataTypeVerboseFunction · 0.45
getTableOptionsMethod · 0.45
queryRowCountMethod · 0.45
getTableStatisticsFunction · 0.45

Calls 4

nowFunction · 0.85
value_orMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.36