Merge pull request #635 from memgraph/MG-expand-fixes

This commit is contained in:
János Benjamin Antal 2022-11-02 15:55:49 +01:00 committed by GitHub
commit 9f71ce0f78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 9 deletions

View File

@ -2458,13 +2458,13 @@ class DistributedCreateExpandCursor : public Cursor {
std::invoke([&]() {
switch (edge_info.direction) {
case EdgeAtom::Direction::IN: {
set_vertex(v1, request.src_vertex);
set_vertex(v2, request.dest_vertex);
set_vertex(v2, request.src_vertex);
set_vertex(v1, request.dest_vertex);
break;
}
case EdgeAtom::Direction::OUT: {
set_vertex(v1, request.dest_vertex);
set_vertex(v2, request.src_vertex);
set_vertex(v1, request.src_vertex);
set_vertex(v2, request.dest_vertex);
break;
}
case EdgeAtom::Direction::BOTH:
@ -2513,7 +2513,8 @@ class DistributedExpandCursor : public Cursor {
}
MG_ASSERT(direction != EdgeAtom::Direction::BOTH);
const auto &edge = frame[self_.common_.edge_symbol].ValueEdge();
static auto get_dst_vertex = [&edge](const EdgeAtom::Direction direction) {
static constexpr auto get_dst_vertex = [](const EdgeAccessor &edge,
const EdgeAtom::Direction direction) -> msgs::VertexId {
switch (direction) {
case EdgeAtom::Direction::IN:
return edge.From().Id();
@ -2526,7 +2527,7 @@ class DistributedExpandCursor : public Cursor {
msgs::ExpandOneRequest request;
// to not fetch any properties of the edges
request.edge_properties.emplace();
request.src_vertices.push_back(get_dst_vertex(direction));
request.src_vertices.push_back(get_dst_vertex(edge, direction));
request.direction = (direction == EdgeAtom::Direction::IN) ? msgs::EdgeDirection::OUT : msgs::EdgeDirection::IN;
msgs::ExecutionState<msgs::ExpandOneRequest> request_state;
auto result_rows = context.shard_request_manager->Request(request_state, std::move(request));

View File

@ -29,6 +29,7 @@ struct ProfilingStats {
static constexpr std::string_view kNumCycles{"num_cycles"};
static constexpr std::string_view kRelativeTime{"relative_time"};
static constexpr std::string_view kAbsoluteTime{"absolute_time"};
static constexpr std::string_view kActualHits{"actual_hits"};
int64_t actual_hits{0};
uint64_t num_cycles{0};

View File

@ -42,13 +42,18 @@ class ScopedCustomProfile {
custom_data = nlohmann::json::object();
}
const auto elapsed = utils::ReadTSC() - start_time_;
auto &num_cycles_json = custom_data[ProfilingStats::kNumCycles];
const auto num_cycles = num_cycles_json.is_null() ? 0 : num_cycles_json.get<uint64_t>();
num_cycles_json = num_cycles + elapsed;
IncreaseCustomData(custom_data, ProfilingStats::kNumCycles, elapsed);
IncreaseCustomData(custom_data, ProfilingStats::kActualHits, 1);
}
}
private:
static void IncreaseCustomData(nlohmann::json &custom_data, const std::string_view key, const uint64_t increment) {
auto &json_data = custom_data[key];
const auto numerical_data = json_data.is_null() ? 0 : json_data.get<uint64_t>();
json_data = numerical_data + increment;
}
std::string_view custom_data_name_;
uint64_t start_time_;
ExecutionContext *context_;