#include #include #include #include #include #include #include namespace DB { static String typeToString(FilesystemCacheLogElement::CacheType type) { switch (type) { case FilesystemCacheLogElement::CacheType::READ_FROM_CACHE: return "READ_FROM_CACHE"; case FilesystemCacheLogElement::CacheType::READ_FROM_FS_AND_DOWNLOADED_TO_CACHE: return "READ_FROM_FS_AND_DOWNLOADED_TO_CACHE"; case FilesystemCacheLogElement::CacheType::READ_FROM_FS_BYPASSING_CACHE: return "READ_FROM_FS_BYPASSING_CACHE"; case FilesystemCacheLogElement::CacheType::WRITE_THROUGH_CACHE: return "WRITE_THROUGH_CACHE"; } __builtin_unreachable(); } NamesAndTypesList FilesystemCacheLogElement::getNamesAndTypes() { DataTypes types{ std::make_shared>(), std::make_shared>(), }; return { {"event_date", std::make_shared()}, {"event_time", std::make_shared()}, {"query_id", std::make_shared()}, {"source_file_path", std::make_shared()}, {"file_segment_range", std::make_shared(types)}, {"total_requested_range", std::make_shared(types)}, {"size", std::make_shared()}, {"read_type", std::make_shared()}, {"read_from_cache_attempted", std::make_shared()}, {"ProfileEvents", std::make_shared(std::make_shared(), std::make_shared())}, {"read_buffer_id", std::make_shared()}, }; } void FilesystemCacheLogElement::appendToBlock(MutableColumns & columns) const { size_t i = 0; columns[i++]->insert(DateLUT::instance().toDayNum(event_time).toUnderType()); columns[i++]->insert(event_time); columns[i++]->insert(query_id); columns[i++]->insert(source_file_path); columns[i++]->insert(Tuple{file_segment_range.first, file_segment_range.second}); columns[i++]->insert(Tuple{requested_range.first, requested_range.second}); columns[i++]->insert(file_segment_size); columns[i++]->insert(typeToString(cache_type)); columns[i++]->insert(read_from_cache_attempted); if (profile_counters) { auto * column = columns[i++].get(); ProfileEvents::dumpToMapColumn(*profile_counters, column, true); } else { columns[i++]->insertDefault(); } columns[i++]->insert(read_buffer_id); } }