Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dedup for GetDstBySrc #4582

Merged
merged 3 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
replace std::unordered_map with robin_hood in find path executor
  • Loading branch information
jievince committed Aug 25, 2022
commit f3adcbb495dbccae5b6f29608a360cf27894eccd
2 changes: 1 addition & 1 deletion src/graph/executor/algo/BatchShortestPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ folly::Future<bool> BatchShortestPath::conjunctPath(size_t rowNum, bool oddStep)
if (vertices.empty()) {
return false;
}
std::unordered_map<Value, Value> verticesMap;
robin_hood::unordered_flat_map<Value, Value, std::hash<Value>> verticesMap;
for (auto& vertex : vertices) {
verticesMap[vertex.getVertex().vid] = std::move(vertex);
}
Expand Down
5 changes: 4 additions & 1 deletion src/graph/executor/algo/BatchShortestPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class BatchShortestPath final : public ShortestPathBase {
DataSet* result) override;

using CustomPath = Row;
using PathMap = std::unordered_map<DstVid, std::unordered_map<StartVid, std::vector<CustomPath>>>;
using PathMap = robin_hood::unordered_flat_map<
DstVid,
robin_hood::unordered_flat_map<StartVid, std::vector<CustomPath>, std::hash<StartVid>>,
std::hash<DstVid>>;

private:
size_t splitTask(const HashSet& startVids, const HashSet& endVids);
Expand Down
8 changes: 7 additions & 1 deletion src/graph/executor/algo/MultiShortestPathExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#ifndef GRAPH_EXECUTOR_ALGO_MULTISHORTESTPATHEXECUTOR_H_
#define GRAPH_EXECUTOR_ALGO_MULTISHORTESTPATHEXECUTOR_H_

#include <robin_hood.h>

#include "graph/executor/Executor.h"

// MultiShortestPath has two inputs. GetNeighbors(From) & GetNeighbors(To)
// There are two Main functions
// First : Get the next vid for GetNeighbors to expand
Expand Down Expand Up @@ -58,7 +61,10 @@ class MultiShortestPathExecutor final : public Executor {

private:
// key: dst, value: {key : src, value: paths}
using Interims = std::unordered_map<Value, std::unordered_map<Value, std::vector<Path>>>;
using Interims = robin_hood::unordered_flat_map<
Value,
robin_hood::unordered_flat_map<Value, std::vector<Path>, std::hash<Value>>,
std::hash<Value>>;

void init();
std::vector<Path> createPaths(const std::vector<Path>& paths, const Edge& edge);
Expand Down
4 changes: 3 additions & 1 deletion src/graph/executor/algo/ProduceAllPathsExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef GRAPH_EXECUTOR_ALGO_PRODUCEALLPATHSEXECUTOR_H_
#define GRAPH_EXECUTOR_ALGO_PRODUCEALLPATHSEXECUTOR_H_

#include <robin_hood.h>

#include "graph/executor/Executor.h"

// ProduceAllPath has two inputs. GetNeighbors(From) & GetNeighbors(To)
Expand Down Expand Up @@ -52,7 +54,7 @@ class ProduceAllPathsExecutor final : public Executor {

private:
// k: dst, v: paths to dst
using Interims = std::unordered_map<Value, std::vector<Path>>;
using Interims = robin_hood::unordered_flat_map<Value, std::vector<Path>, std::hash<Value>>;

Status buildPath(bool reverse);
folly::Future<Status> conjunctPath();
Expand Down
2 changes: 1 addition & 1 deletion src/graph/executor/algo/SingleShortestPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void SingleShortestPath::init(const HashSet& startVids, const HashSet& endVids,
resultDs_.resize(rowSize);
for (const auto& startVid : startVids) {
for (const auto& endVid : endVids) {
std::unordered_map<Value, std::vector<Row>> steps;
robin_hood::unordered_flat_map<Value, std::vector<Row>, std::hash<Value>> steps;
std::vector<Row> dummy;
steps.emplace(endVid, std::move(dummy));
HalfPath originRightPath({std::move(steps)});
Expand Down
3 changes: 2 additions & 1 deletion src/graph/executor/algo/SingleShortestPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class SingleShortestPath final : public ShortestPathBase {
const HashSet& endVids,
DataSet* result) override;

using HalfPath = std::vector<std::unordered_map<DstVid, std::vector<CustomStep>>>;
using HalfPath = std::vector<
robin_hood::unordered_flat_map<DstVid, std::vector<CustomStep>, std::hash<Value>>>;

private:
void init(const HashSet& startVids, const HashSet& endVids, size_t rowSize);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/executor/algo/SubgraphExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ folly::Future<Status> SubgraphExecutor::execute() {
ResultBuilder builder;
builder.value(iter->valuePtr());

std::unordered_map<Value, int64_t> currentVids;
robin_hood::unordered_flat_map<Value, int64_t, std::hash<Value>> currentVids;
currentVids.reserve(gnSize);
historyVids_.reserve(historyVids_.size() + gnSize);
if (currentStep == 1) {
Expand Down
4 changes: 3 additions & 1 deletion src/graph/executor/algo/SubgraphExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef GRAPH_EXECUTOR_ALGO_SUBGRAPHEXECUTOR_H_
#define GRAPH_EXECUTOR_ALGO_SUBGRAPHEXECUTOR_H_

#include <robin_hood.h>

#include "graph/executor/Executor.h"

// Subgraph receive result from GetNeighbors
Expand Down Expand Up @@ -45,7 +47,7 @@ class SubgraphExecutor : public Executor {
folly::Future<Status> execute() override;

private:
std::unordered_map<Value, int64_t> historyVids_;
robin_hood::unordered_flat_map<Value, int64_t, std::hash<Value>> historyVids_;
};

} // namespace graph
Expand Down