From c710553c81a5e5dffd172e61d12519520a2ac601 Mon Sep 17 00:00:00 2001 From: Johannes Herrmann Date: Wed, 16 Oct 2024 00:28:10 +0200 Subject: [PATCH] Replaced std::vector in Edge with row index --- src/engine/PathSearch.cpp | 26 +++++++++++++++++--------- src/engine/PathSearch.h | 8 +++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/engine/PathSearch.cpp b/src/engine/PathSearch.cpp index f3dc646aac..af80a3769a 100644 --- a/src/engine/PathSearch.cpp +++ b/src/engine/PathSearch.cpp @@ -51,15 +51,22 @@ std::vector BinSearchWrapper::getSources() const { return sources; } +// _____________________________________________________________________________ +std::vector BinSearchWrapper::getEdgeProperties(const Edge& edge) const { + std::vector edgeProperties; + for (auto edgeCol : edgeCols_) { + edgeProperties.push_back(table_(edge.edgeRow_, edgeCol)); + } + return edgeProperties; +} + // _____________________________________________________________________________ Edge BinSearchWrapper::makeEdgeFromRow(size_t row) const { Edge edge; edge.start_ = table_(row, startCol_); edge.end_ = table_(row, endCol_); + edge.edgeRow_ = row; - for (auto edgeCol : edgeCols_) { - edge.edgeProperties_.push_back(table_(row, edgeCol)); - } return edge; } @@ -246,7 +253,8 @@ Result PathSearch::computeResult([[maybe_unused]] bool requestLaziness) { timer.start(); CALL_FIXED_SIZE(std::array{getResultWidth()}, - &PathSearch::pathsToResultTable, this, idTable, paths); + &PathSearch::pathsToResultTable, this, idTable, paths, + binSearch); timer.stop(); auto fillTime = timer.msecs(); @@ -380,8 +388,8 @@ PathsLimited PathSearch::allPaths(std::span sources, // _____________________________________________________________________________ template -void PathSearch::pathsToResultTable(IdTable& tableDyn, - PathsLimited& paths) const { +void PathSearch::pathsToResultTable(IdTable& tableDyn, PathsLimited& paths, + const BinSearchWrapper& binSearch) const { IdTableStatic table = std::move(tableDyn).toStatic(); std::vector edgePropertyCols; @@ -421,11 +429,11 @@ void PathSearch::pathsToResultTable(IdTable& tableDyn, table(rowIndex, getTargetIndex().value()) = targetId.value(); } + auto edgeProperties = binSearch.getEdgeProperties(edge); for (size_t edgePropertyIndex = 0; - edgePropertyIndex < edge.edgeProperties_.size(); - edgePropertyIndex++) { + edgePropertyIndex < edgeProperties.size(); edgePropertyIndex++) { table(rowIndex, edgePropertyCols[edgePropertyIndex]) = - edge.edgeProperties_[edgePropertyIndex]; + edgeProperties[edgePropertyIndex]; } rowIndex++; diff --git a/src/engine/PathSearch.h b/src/engine/PathSearch.h index a43786e75b..9e330d1d4e 100644 --- a/src/engine/PathSearch.h +++ b/src/engine/PathSearch.h @@ -28,7 +28,7 @@ struct Edge { Id end_; - std::vector edgeProperties_; + size_t edgeRow_; }; using EdgesLimited = std::vector>; @@ -81,6 +81,8 @@ class BinSearchWrapper { */ std::vector getSources() const; + std::vector getEdgeProperties(const Edge& edge) const; + private: Edge makeEdgeFromRow(size_t row) const; }; @@ -275,6 +277,6 @@ class PathSearch : public Operation { * @param paths The vector of paths to convert. */ template - void pathsToResultTable(IdTable& tableDyn, - pathSearch::PathsLimited& paths) const; + void pathsToResultTable(IdTable& tableDyn, pathSearch::PathsLimited& paths, + const pathSearch::BinSearchWrapper& binSearch) const; };