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

Method execute

src/Interpreters/InterpreterAlterDiskCacheQuery.cpp:19–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19BlockIO InterpreterAlterDiskCacheQuery::execute()
20{
21 const auto & query = query_ptr->as<ASTAlterDiskCacheQuery &>();
22 /// apply settings
23 if (query.settings_ast)
24 {
25 InterpreterSetQuery(query.settings_ast, getContext()).executeForCurrentContext();
26 }
27
28 StoragePtr table = DatabaseCatalog::instance().getTable({query.database, query.table}, getContext());
29 auto * storage = dynamic_cast<StorageCnchMergeTree *>(table.get());
30 if (!storage)
31 throw Exception("Preload only support CnchMergeTree engine", ErrorCodes::LOGICAL_ERROR);
32
33 ServerDataPartsVector parts;
34 if (query.partition)
35 {
36 String partition_id = storage->getPartitionIDFromQuery(query.partition, getContext());
37 parts = getContext()->getCnchCatalog()->getServerDataPartsInPartitions(table, {partition_id}, getContext()->getTimestamp(), nullptr);
38 }
39 else
40 {
41 parts = storage->getAllPartsWithDBM(getContext()).first;
42 }
43 parts = CnchPartsHelper::calcVisibleParts(parts, false);
44
45 if (query.type == ASTAlterDiskCacheQuery::Type::PRELOAD)
46 {
47 storage->sendPreloadTasks(getContext(), std::move(parts), query.sync, getContext()->getSettings().parts_preload_level, time(nullptr));
48 }
49 else if (query.type == ASTAlterDiskCacheQuery::Type::DROP)
50 {
51 storage->sendDropDiskCacheTasks(getContext(), std::move(parts), query.sync, getContext()->getSettings().drop_vw_disk_cache);
52 }
53 else
54 {
55 throw Exception("Unknown alter disk cache query type", ErrorCodes::NOT_IMPLEMENTED);
56 }
57
58 return {};
59}
60}

Callers

nothing calls this directly

Calls 14

InterpreterSetQueryClass · 0.85
calcVisiblePartsFunction · 0.85
sendPreloadTasksMethod · 0.80
ExceptionClass · 0.70
getTableMethod · 0.45
getMethod · 0.45
getCnchCatalogMethod · 0.45
getTimestampMethod · 0.45

Tested by

no test coverage detected