diff --git a/src/engine/PathSearch.cpp b/src/engine/PathSearch.cpp index 1214b28bfd..e6308edd83 100644 --- a/src/engine/PathSearch.cpp +++ b/src/engine/PathSearch.cpp @@ -244,7 +244,7 @@ Result PathSearch::computeResult([[maybe_unused]] bool requestLaziness) { auto sideTime = timer.msecs(); timer.start(); - std::vector paths; + PathsLimited paths{allocator()}; if (sources.empty()) { paths = allPaths(binSearch.getSources(), targets, binSearch, config_.cartesian_); } else { @@ -313,13 +313,13 @@ PathSearch::handleSearchSides() const { } // _____________________________________________________________________________ -std::vector PathSearch::findPaths( +PathsLimited PathSearch::findPaths( const Id& source, const std::unordered_set& targets, const BinSearchWrapper& binSearch) const { std::vector edgeStack; - Path currentPath; + Path currentPath{EdgesLimited(allocator())}; std::unordered_map> pathCache; - std::vector result; + PathsLimited result{allocator()}; std::unordered_set visited; visited.insert(source.getBits()); @@ -355,12 +355,12 @@ std::vector PathSearch::findPaths( } // _____________________________________________________________________________ -std::vector PathSearch::allPaths(std::span sources, +PathsLimited PathSearch::allPaths(std::span sources, std::span targets, const BinSearchWrapper& binSearch, bool cartesian) const { - std::vector paths; - Path path; + PathsLimited paths{allocator()}; + Path path{EdgesLimited(allocator())}; if (cartesian || sources.size() != targets.size()) { std::unordered_set targetSet; @@ -386,7 +386,7 @@ std::vector PathSearch::allPaths(std::span sources, // _____________________________________________________________________________ template void PathSearch::pathsToResultTable(IdTable& tableDyn, - std::vector& paths) const { + PathsLimited& paths) const { IdTableStatic table = std::move(tableDyn).toStatic(); std::vector edgePropertyCols; diff --git a/src/engine/PathSearch.h b/src/engine/PathSearch.h index b949698d52..fef63faa09 100644 --- a/src/engine/PathSearch.h +++ b/src/engine/PathSearch.h @@ -12,6 +12,7 @@ #include "engine/Operation.h" #include "global/Id.h" +#include "util/AllocatorWithLimit.h" enum class PathSearchAlgorithm { ALL_PATHS }; @@ -30,8 +31,10 @@ struct Edge { std::vector edgeProperties_; }; +using EdgesLimited = std::vector>; + struct Path { - std::vector edges_; + EdgesLimited edges_; bool empty() const { return edges_.empty(); } @@ -44,6 +47,8 @@ struct Path { const Id& end() { return edges_.back().end_; } }; +using PathsLimited = std::vector>; + /** * @class BinSearchWrapper * @brief Encapsulates logic for binary search of edges in @@ -251,7 +256,7 @@ class PathSearch : public Operation { * @brief Finds paths based on the configured algorithm. * @return A vector of paths. */ - std::vector findPaths(const Id& source, + pathSearch::PathsLimited findPaths(const Id& source, const std::unordered_set& targets, const pathSearch::BinSearchWrapper& binSearch) const; @@ -259,7 +264,7 @@ class PathSearch : public Operation { * @brief Finds all paths in the graph. * @return A vector of all paths. */ - std::vector allPaths(std::span sources, + pathSearch::PathsLimited allPaths(std::span sources, std::span targets, const pathSearch::BinSearchWrapper& binSearch, bool cartesian) const; @@ -270,5 +275,5 @@ class PathSearch : public Operation { * @param paths The vector of paths to convert. */ template - void pathsToResultTable(IdTable& tableDyn, std::vector& paths) const; + void pathsToResultTable(IdTable& tableDyn, pathSearch::PathsLimited& paths) const; };