#include #include #include #include #include #include #include #include #include #include #include namespace DB { static Block getSampleBlock() { ColumnsWithTypeAndName columns{ ColumnWithTypeAndName{std::make_shared(), "max_size"}, ColumnWithTypeAndName{std::make_shared(), "max_elements"}, ColumnWithTypeAndName{std::make_shared(), "max_file_segment_size"}, ColumnWithTypeAndName{std::make_shared>(), "cache_on_write_operations"}, ColumnWithTypeAndName{std::make_shared>(), "enable_cache_hits_threshold"}, ColumnWithTypeAndName{std::make_shared(), "current_size"}, ColumnWithTypeAndName{std::make_shared(), "current_elements"}, ColumnWithTypeAndName{std::make_shared(), "path"}, ColumnWithTypeAndName{std::make_shared>(), "do_not_evict_index_and_mark_files"}, }; return Block(columns); } BlockIO InterpreterDescribeCacheQuery::execute() { getContext()->checkAccess(AccessType::SHOW_FILESYSTEM_CACHES); const auto & ast = query_ptr->as(); Block sample_block = getSampleBlock(); MutableColumns res_columns = sample_block.cloneEmptyColumns(); auto cache_data = FileCacheFactory::instance().getByName(ast.cache_name); const auto & settings = cache_data.settings; const auto & cache = cache_data.cache; res_columns[0]->insert(settings.max_size); res_columns[1]->insert(settings.max_elements); res_columns[2]->insert(settings.max_file_segment_size); res_columns[3]->insert(settings.cache_on_write_operations); res_columns[4]->insert(settings.enable_cache_hits_threshold); res_columns[5]->insert(cache->getUsedCacheSize()); res_columns[6]->insert(cache->getFileSegmentsNum()); res_columns[7]->insert(cache->getBasePath()); res_columns[8]->insert(settings.do_not_evict_index_and_mark_files); BlockIO res; size_t num_rows = res_columns[0]->size(); auto source = std::make_shared(sample_block, Chunk(std::move(res_columns), num_rows)); res.pipeline = QueryPipeline(std::move(source)); return res; } }