| 73 | } |
| 74 | |
| 75 | PlannerTableStats buildPlannerTableStats(StorageManager& storageManager, const Catalog& catalog, |
| 76 | const Transaction* transaction, const TableCatalogEntry& tableEntry, table_id_t physicalTableID, |
| 77 | PlannerStatsMode mode) { |
| 78 | auto tableID = physicalTableID == INVALID_TABLE_ID ? tableEntry.getTableID() : physicalTableID; |
| 79 | auto* table = storageManager.getTable(tableID); |
| 80 | auto plannerStats = PlannerTableStats{}; |
| 81 | plannerStats.tableID = tableID; |
| 82 | plannerStats.tableType = tableEntry.getTableType(); |
| 83 | plannerStats.tableChangeEpoch = table->getChangeEpoch(); |
| 84 | switch (tableEntry.getTableType()) { |
| 85 | case TableType::NODE: { |
| 86 | plannerStats.storageStats = table->cast<NodeTable>().getStats(transaction); |
| 87 | } break; |
| 88 | case TableType::REL: { |
| 89 | auto& relGroupEntry = tableEntry.constCast<RelGroupCatalogEntry>(); |
| 90 | auto* relTable = table->ptrCast<RelTable>(); |
| 91 | const auto& relInfo = getRelTableInfo(relGroupEntry, tableID); |
| 92 | for (const auto direction : relGroupEntry.getRelDataDirections()) { |
| 93 | const auto directionKey = RelDirectionUtils::relDirectionToKeyIdx(direction); |
| 94 | plannerStats.relDirectionStats[directionKey] = |
| 95 | mode == PlannerStatsMode::ANALYZE ? |
| 96 | computeRelDirectionStats(*relTable, transaction, direction) : |
| 97 | computeRelDirectionSchemaStats(*relTable, transaction, relInfo, direction); |
| 98 | } |
| 99 | } break; |
| 100 | default: { |
| 101 | UNREACHABLE_CODE; |
| 102 | } |
| 103 | } |
| 104 | appendIndexStats(plannerStats, catalog, transaction, tableEntry, tableID); |
| 105 | return plannerStats; |
| 106 | } |
| 107 | |
| 108 | std::vector<table_id_t> analyzePlannerStats(StorageManager& storageManager, const Catalog& catalog, |
| 109 | const Transaction* transaction, const std::optional<std::string>& tableName) { |
no test coverage detected