MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / computeRelDirectionStats

Function computeRelDirectionStats

src/storage/stats/planner_stats.cpp:20–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace storage {
19
20static PlannerRelDirectionStats computeRelDirectionStats(RelTable& relTable,
21 const Transaction* transaction, RelDataDirection direction) {
22 auto degreeEntries = relTable.getDegreeEntries(transaction, direction);
23 cardinality_t totalDegree = 0;
24 cardinality_t maxDegree = 0;
25 for (const auto& [_, degree] : degreeEntries) {
26 totalDegree += degree;
27 maxDegree = std::max<cardinality_t>(maxDegree, degree);
28 }
29 auto stats = PlannerRelDirectionStats{};
30 stats.numRows = relTable.getNumTotalRows(transaction);
31 stats.numActiveBoundNodes = degreeEntries.size();
32 stats.maxDegree = maxDegree;
33 stats.avgDegree =
34 degreeEntries.empty() ? 0 : static_cast<double>(totalDegree) / degreeEntries.size();
35 stats.boundKeysUnique = maxDegree <= 1;
36 return stats;
37}
38
39static const RelTableCatalogInfo& getRelTableInfo(const RelGroupCatalogEntry& relGroupEntry,
40 table_id_t tableID) {

Callers 1

buildPlannerTableStatsFunction · 0.85

Calls 4

getDegreeEntriesMethod · 0.45
getNumTotalRowsMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected