From 77f6e74b1c58fd5a22735ef512d0ca0d9a287e02 Mon Sep 17 00:00:00 2001 From: Mahmoud Khalaf Date: Mon, 6 May 2024 05:43:39 +0200 Subject: [PATCH] fixup! fixup! use after free debug --- src/engine/joinOrdering/GOO.cpp | 14 +------------- src/engine/joinOrdering/GOO.h | 1 + src/engine/joinOrdering/QueryGraph.cpp | 3 +-- test/engine/joinOrdering/IKKBZTest.cpp | 1 - 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/engine/joinOrdering/GOO.cpp b/src/engine/joinOrdering/GOO.cpp index 1dff9978c7..5f662d8f65 100644 --- a/src/engine/joinOrdering/GOO.cpp +++ b/src/engine/joinOrdering/GOO.cpp @@ -45,19 +45,7 @@ requires RelationAble g.hist[n].push_back(b); // TODO: STL chain iterators - // boost::join(g.edges_[a], g.edges_[b]) - for (auto const& [x, e] : g.edges_[a]) { - if (e.hidden || x == a || x == b) continue; - g.add_rjoin(n, x, e.weight, Direction::UNDIRECTED); - - if (!g.is_common_neighbour(a, b, x)) continue; - // when the 2 relations to be combined have common neighbours - // multiply edge weights of newly combined relation - g.edges_[x][n].weight = g.edges_[a][x].weight * g.edges_[b][x].weight; - g.edges_[n][x].weight = g.edges_[a][x].weight * g.edges_[b][x].weight; - } - - for (auto const& [x, e] : g.edges_[b]) { + for (auto const& [x, e] : boost::join(g.edges_[a], g.edges_[b])) { if (e.hidden || x == a || x == b) continue; g.add_rjoin(n, x, e.weight, Direction::UNDIRECTED); diff --git a/src/engine/joinOrdering/GOO.h b/src/engine/joinOrdering/GOO.h index 24678c8c4d..bb55cd1b38 100644 --- a/src/engine/joinOrdering/GOO.h +++ b/src/engine/joinOrdering/GOO.h @@ -6,6 +6,7 @@ #pragma once #include "QueryGraph.h" +#include "boost/range/join.hpp" namespace JoinOrdering { diff --git a/src/engine/joinOrdering/QueryGraph.cpp b/src/engine/joinOrdering/QueryGraph.cpp index 20c59f4654..fde642e33e 100644 --- a/src/engine/joinOrdering/QueryGraph.cpp +++ b/src/engine/joinOrdering/QueryGraph.cpp @@ -178,8 +178,7 @@ auto QueryGraph::get_chained_subtree(const N& n) -> N { // since this is called from IKKBZ_Normalize // we have already checked the existence of a subtree - // if (it != dxs.end()) - return *it; + if (it != dxs.end()) return *it; // AD_CONTRACT_CHECK(false); // throw std::runtime_error("how did we get here?"); diff --git a/test/engine/joinOrdering/IKKBZTest.cpp b/test/engine/joinOrdering/IKKBZTest.cpp index ca6b613d13..9161b13305 100644 --- a/test/engine/joinOrdering/IKKBZTest.cpp +++ b/test/engine/joinOrdering/IKKBZTest.cpp @@ -578,7 +578,6 @@ TEST(GOO_SANITY, SESSION04_EX) { // TODO: undeterministic // EXPECT_NO_THROW(JoinOrdering::GOO(g)); - JoinOrdering::GOO(g); // auto erg = JoinOrdering::GOO(g); // for (auto const& x : g.hist[erg]) std::cout << x.getLabel() << "\n"; }