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

Zhanfu/csr Framework for the CSR structure #4688

Merged
merged 9 commits into from
Oct 27, 2022
Merged
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
25 changes: 11 additions & 14 deletions src/graph/executor/algo/IsomorExecutor.cpp
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
// Copyright (c) 2020 vesoft inc. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

#include "graph/executor/algo/IsomorExecutor.h"

#include "graph/planner/plan/Algo.h"

namespace nebula {
namespace graph {

folly::Future<Status> IsomorExecutor::execute() {
// TODO: Replace the following codes with subgraph matching. Return type.
SCOPED_TIMER(&execTime_);
auto* isomor = asNode<Isomor>(node());
DataSet ds;
ds.colNames = isomor->colNames();

auto iterDV = ectx_->getResult(isomor->getdScanVOut()).iter();
auto iterQV = ectx_->getResult(isomor->getqScanVOut()).iter();
auto iterDE = ectx_->getResult(isomor->getdScanEOut()).iter();
auto iterQE = ectx_->getResult(isomor->getqScanEOut()).iter();

unsigned int v_count = iterDV->size();
unsigned int l_count = iterDV->size();
unsigned int e_count = iterDE->size();

unsigned int *offset = new unsigned int[v_count + 2];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) Please explain via comments why the size is +2
(2) Please use vector. Don't use new.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) as the offset is recording the starting position of the node 0 which suppose to be 0, and offset[1] should be the end of position node 0 and start of position node 1. The size of the offset should be at least v_count + 1;
(2) Ok

unsigned int *neighbors = new unsigned int[e_count * 2];
Copy link
Contributor

@wenhaocs wenhaocs Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember that for every edge A-B, we actually store 2 copies, A->B and B->A. You need to take this into consideration. They can be distinguished by edge type signs. Positive and Negative represent them respectively. Please think about it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

unsigned int *labels = new unsigned int[l_count];
// load data vertices id and tags
while (iterDV->valid()) {
const auto v = iterDV->getColumn(nebula::kVid); // check if v is a vertex
auto v_id = v.getInt();
const auto v2 = iterDV->getColumn(1); // get label
auto l_id = v2.getInt();
const auto vertex = iterDV->getColumn(nebula::kVid); // check if v is a vertex
auto v_id = vertex.getInt();
const auto label = iterDV->getColumn(1); // get label by index
auto l_id = label.getInt();
// unsigned int v_id = (unsigned int)v.getInt(0);
labels[v_id] = l_id; // Tag Id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can vID used as the index of the labels array? There is no restriction on what vID will look like, e.g., may be from 1000 to 100000.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Therefore, it's better to use map here.

iterDV->next();
}

// load edges degree
while (iterDE->valid()) {
auto s = iterDE->getEdgeProp("*", kSrc);
unsigned int src = s.getInt();
offset[src]++;
iterDE->next();
}
for (int i = 0; i < v_count; i++) {
offset[i + 1] = offset[i];
}

// load data edges
offset[0] = 0;
Expand All @@ -58,11 +53,13 @@ folly::Future<Status> IsomorExecutor::execute() {
offset[src + 1]++;
iterDE->next();
}

for (int i = 0; i < v_count; i++) {
offset[i + 1] = offset[i];
}
offset[0] = 0;
delete offset;
delete neighbors;
delete labels;

ResultBuilder builder;

// Set result in the ds and set the new column name for the (isomor matching 's) result.
Expand Down