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

Conversation

peter-rich
Copy link

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Description:

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

@peter-rich peter-rich requested a review from wenhaocs September 29, 2022 05:47
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
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.

what are v and v2. Please use meaningful names.

Copy link
Author

Choose a reason for hiding this comment

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

I change it to the new version in the code, v is the content of the vertex id while v2 is the content of the label id.


ResultBuilder builder;
builder.value(iter->valuePtr());
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 src = iterDE->getEdgeProp("*", kSrc).getInt();
unsigned int dst = iterDE->getEdgeProp("*", kDst).getInt();

neighbors[offset[src + 1]] = dst;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not understand this. Please explain via comment.

Copy link
Author

Choose a reason for hiding this comment

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

(1) src and dst is the source and destination information.
(2) offset[src + 1] will be the position of the array.

Copy link
Author

Choose a reason for hiding this comment

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

I can change it and comment it in the new version

ResultBuilder builder;
builder.value(iter->valuePtr());
unsigned int *offset = new unsigned int[v_count + 2];
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

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.

iterDE->next();
}
for (unsigned int i = 0; i < v_count; i++) {
offset[i + 1] = offset[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this wrong?

@@ -90,4 +93,4 @@ nebula_add_library(
mutate/UpdateExecutor.cpp
)

nebula_add_subdirectory(test)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this line deleted

iterDE->next();
}

// caldulate the start position of each vertex in the neighborhood array
for (unsigned int i = 0; i < v_count; i++) {
offset[i + 1] += offset[i];
offset[i + 1] += degree[i] + offset[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

+=?

@wenhaocs wenhaocs merged commit 64082e8 into vesoft-inc:release-3.2-subgraphmatch Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants