-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Changes from 1 commit
d1f5588
f65e863
c66c8fa
d60470b
f890de8
6abc99b
a8d21ad
d1b7544
654d489
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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]; | ||
unsigned int *neighbors = new unsigned int[e_count * 2]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can vID used as the index of the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
@@ -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. | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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