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

Method writeToCatalog

src/Statistics/StatisticsCollector.cpp:74–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void StatisticsCollector::writeToCatalog()
75{
76 if (!catalog)
77 {
78 throw Exception("catalog is NULL", ErrorCodes::LOGICAL_ERROR);
79 }
80 StatsData data;
81 data.table_stats = table_stats.writeToCollection();
82 std::vector<String> columns;
83 for (auto & [name, stats] : columns_stats)
84 {
85 columns.emplace_back(name);
86 data.column_stats[name] = stats.writeToCollection();
87 }
88 auto proxy = createCachedStatsProxy(catalog, settings.cache_policy);
89 auto cols_desc = catalog->filterCollectableColumns(table_info, columns);
90 // drop old columns to ensure other data is deleted
91 // especially when collecting statistics_collect_histogram=0
92 proxy->dropColumns(table_info, cols_desc);
93 proxy->put(table_info, std::move(data));
94 catalog->invalidateClusterStatsCache(table_info);
95 // clear udi whenever it is to create/drop stats
96 // since after manual drop stats, users just don't want statistics,
97 // so we needn't care about udi for auto stats until next insertion
98 catalog->removeUdiCount(table_info);
99}
100
101void StatisticsCollector::readAllFromCatalog()
102{

Callers 3

collectStatsOnTargetFunction · 0.80
loadStatsMethod · 0.80
readDbStatsFunction · 0.80

Calls 9

createCachedStatsProxyFunction · 0.85
ExceptionClass · 0.50
writeToCollectionMethod · 0.45
emplace_backMethod · 0.45
dropColumnsMethod · 0.45
putMethod · 0.45
removeUdiCountMethod · 0.45

Tested by

no test coverage detected