Skip to content

Commit

Permalink
Replaced std::vector<Id> in Edge with row index
Browse files Browse the repository at this point in the history
  • Loading branch information
JoBuRo committed Oct 15, 2024
1 parent 79a8bcd commit c710553
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
26 changes: 17 additions & 9 deletions src/engine/PathSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ std::vector<Id> BinSearchWrapper::getSources() const {
return sources;
}

// _____________________________________________________________________________
std::vector<Id> BinSearchWrapper::getEdgeProperties(const Edge& edge) const {
std::vector<Id> 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;
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -380,8 +388,8 @@ PathsLimited PathSearch::allPaths(std::span<const Id> sources,

// _____________________________________________________________________________
template <size_t WIDTH>
void PathSearch::pathsToResultTable(IdTable& tableDyn,
PathsLimited& paths) const {
void PathSearch::pathsToResultTable(IdTable& tableDyn, PathsLimited& paths,
const BinSearchWrapper& binSearch) const {
IdTableStatic<WIDTH> table = std::move(tableDyn).toStatic<WIDTH>();

std::vector<size_t> edgePropertyCols;
Expand Down Expand Up @@ -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++;
Expand Down
8 changes: 5 additions & 3 deletions src/engine/PathSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Edge {

Id end_;

std::vector<Id> edgeProperties_;
size_t edgeRow_;
};

using EdgesLimited = std::vector<Edge, ad_utility::AllocatorWithLimit<Edge>>;
Expand Down Expand Up @@ -81,6 +81,8 @@ class BinSearchWrapper {
*/
std::vector<Id> getSources() const;

std::vector<Id> getEdgeProperties(const Edge& edge) const;

private:
Edge makeEdgeFromRow(size_t row) const;
};
Expand Down Expand Up @@ -275,6 +277,6 @@ class PathSearch : public Operation {
* @param paths The vector of paths to convert.
*/
template <size_t WIDTH>
void pathsToResultTable(IdTable& tableDyn,
pathSearch::PathsLimited& paths) const;
void pathsToResultTable(IdTable& tableDyn, pathSearch::PathsLimited& paths,
const pathSearch::BinSearchWrapper& binSearch) const;
};

0 comments on commit c710553

Please sign in to comment.