From 96f6a15b120958334399d7d6ab08d92e2630c542 Mon Sep 17 00:00:00 2001 From: Fritz Mueller Date: Thu, 28 Jul 2022 04:25:57 +0000 Subject: [PATCH 1/2] Additional logging in RelationGraph --- src/qana/RelationGraph.cc | 47 ++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/qana/RelationGraph.cc b/src/qana/RelationGraph.cc index 232a455c85..0136b7c118 100644 --- a/src/qana/RelationGraph.cc +++ b/src/qana/RelationGraph.cc @@ -834,6 +834,7 @@ void computeMinimumOverlap(Vertex& vtx) { // The required overlap for the initial vertex is 0. vtx.overlap = 0; for (Vertex* v = &vtx; v != nullptr; v = q.dequeue()) { + LOGS(_log, LOG_LVL_TRACE, "Node " << v->info->table << " current=" << v->overlap); // Loop over edges incident to v. for (Iter e = v->edges.begin(), end = v->edges.end(); e != end; ++e) { Vertex* u = e->vertex; @@ -859,6 +860,9 @@ void computeMinimumOverlap(Vertex& vtx) { if (e->isSpatial()) { requiredOverlap += e->angSep; } + LOGS(_log, LOG_LVL_TRACE, + " to " << u->info->table << " available=" << availableOverlap + << " required=" << requiredOverlap); // If requiredOverlap is greater than or equal to the previously // computed required overlap for u, then there is no need to visit // u again. This is because the current path between the initial @@ -878,6 +882,27 @@ void computeMinimumOverlap(Vertex& vtx) { // vertex visitation queue. u->overlap = requiredOverlap; q.enqueue(u); + LOGS(_log, LOG_LVL_TRACE, " (updated and queued)"); + } + } + } +} + +/// dump graph +void dumpGraph(std::list const& vertices) { + if (LOG_CHECK_LVL(_log, LOG_LVL_TRACE)) { + LOGS(_log, LOG_LVL_TRACE, "RelationGraph:"); + std::map vtxId; + for (auto&& vtx : vertices) { + int id = vtxId.size(); + vtxId[&vtx] = id; + LOGS(_log, LOG_LVL_TRACE, + " vertex " << id << " info=" << *vtx.info << " overlap=" << vtx.overlap); + } + for (auto&& vtx : vertices) { + for (auto&& edge : vtx.edges) { + LOGS(_log, LOG_LVL_TRACE, + " edge " << vtxId[&vtx] << " <-> " << vtxId[edge.vertex] << " angSep=" << edge.angSep); } } } @@ -886,12 +911,15 @@ void computeMinimumOverlap(Vertex& vtx) { /// `isEvaluable` returns `true` if no graph vertex requires infinite overlap. bool isEvaluable(std::list const& vertices) { LOGS(_log, LOG_LVL_TRACE, __FUNCTION__); + dumpGraph(vertices); typedef std::list::const_iterator Iter; for (Iter v = vertices.begin(), e = vertices.end(); v != e; ++v) { if ((boost::math::isinf)(v->overlap)) { + LOGS(_log, LOG_LVL_TRACE, "Evaluable: FALSE vertex=" << v->info->table); return false; } } + LOGS(_log, LOG_LVL_TRACE, "Evaluable: TRUE"); return true; } @@ -979,24 +1007,7 @@ RelationGraph::RelationGraph(SelectStmt& stmt, TableInfoPool& pool) : _query(&st swap(g); } -void RelationGraph::_dumpGraph() const { - // dump graph - if (LOG_CHECK_LVL(_log, LOG_LVL_TRACE)) { - LOGS(_log, LOG_LVL_TRACE, "RelationGraph:"); - std::map vtxId; - for (auto&& vtx : _vertices) { - int id = vtxId.size(); - vtxId[&vtx] = id; - LOGS(_log, LOG_LVL_TRACE, " vertex " << id << " info=" << *vtx.info); - } - for (auto&& vtx : _vertices) { - for (auto&& edge : vtx.edges) { - LOGS(_log, LOG_LVL_TRACE, - " edge " << vtxId[&vtx] << " <-> " << vtxId[edge.vertex] << " angSep=" << edge.angSep); - } - } - } -} +void RelationGraph::_dumpGraph() const { dumpGraph(_vertices); } void RelationGraph::rewrite(SelectStmtPtrVector& outputs, QueryMapping& mapping) { LOGS(_log, LOG_LVL_TRACE, __FUNCTION__); From 13cd7ce42fc52efb7acf31e4e0bd63d24d2a73c9 Mon Sep 17 00:00:00 2001 From: Fritz Mueller Date: Thu, 28 Jul 2022 05:03:45 +0000 Subject: [PATCH 2/2] Move dumpGraph helper func to anon. namespace --- src/qana/RelationGraph.cc | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/qana/RelationGraph.cc b/src/qana/RelationGraph.cc index 0136b7c118..773a190b78 100644 --- a/src/qana/RelationGraph.cc +++ b/src/qana/RelationGraph.cc @@ -824,6 +824,26 @@ struct VertexQueue { } }; +/// dump graph +void dumpGraph(std::list const& vertices) { + if (LOG_CHECK_LVL(_log, LOG_LVL_TRACE)) { + LOGS(_log, LOG_LVL_TRACE, "RelationGraph:"); + std::map vtxId; + for (auto&& vtx : vertices) { + int id = vtxId.size(); + vtxId[&vtx] = id; + LOGS(_log, LOG_LVL_TRACE, + " vertex " << id << " info=" << *vtx.info << " overlap=" << vtx.overlap); + } + for (auto&& vtx : vertices) { + for (auto&& edge : vtx.edges) { + LOGS(_log, LOG_LVL_TRACE, + " edge " << vtxId[&vtx] << " <-> " << vtxId[edge.vertex] << " angSep=" << edge.angSep); + } + } + } +} + /// `computeMinimumOverlap` visits every vertex linked to `v` via one or more /// paths and computes its minimum required overlap. void computeMinimumOverlap(Vertex& vtx) { @@ -888,26 +908,6 @@ void computeMinimumOverlap(Vertex& vtx) { } } -/// dump graph -void dumpGraph(std::list const& vertices) { - if (LOG_CHECK_LVL(_log, LOG_LVL_TRACE)) { - LOGS(_log, LOG_LVL_TRACE, "RelationGraph:"); - std::map vtxId; - for (auto&& vtx : vertices) { - int id = vtxId.size(); - vtxId[&vtx] = id; - LOGS(_log, LOG_LVL_TRACE, - " vertex " << id << " info=" << *vtx.info << " overlap=" << vtx.overlap); - } - for (auto&& vtx : vertices) { - for (auto&& edge : vtx.edges) { - LOGS(_log, LOG_LVL_TRACE, - " edge " << vtxId[&vtx] << " <-> " << vtxId[edge.vertex] << " angSep=" << edge.angSep); - } - } - } -} - /// `isEvaluable` returns `true` if no graph vertex requires infinite overlap. bool isEvaluable(std::list const& vertices) { LOGS(_log, LOG_LVL_TRACE, __FUNCTION__);