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

add vertex filter for GetNeighbors #4671

Merged
merged 5 commits into from
Sep 26, 2022

Conversation

nevermore3
Copy link
Contributor

@nevermore3 nevermore3 commented Sep 22, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

close #4649

Description:

Add vertexFilter to getNeighbor interface, when the filter condition of the vertex is not satisfied, do not return the data for this vertex and corresponding edge

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 .....

@nevermore3 nevermore3 requested a review from a team as a code owner September 22, 2022 06:38
@nevermore3 nevermore3 force-pushed the fix_getNeighbor_src_filter branch 3 times, most recently from d8c44e9 to 2b7221f Compare September 22, 2022 12:52
@nevermore3 nevermore3 added ready-for-testing PR: ready for the CI test ready for review labels Sep 22, 2022
@codesigner
Copy link
Contributor

Please add some description of what this pr for, from code it seems pushdown vertex filter to storage, while graph side logic seems not changed, only pass nullptr to the new added vertex_filte.

@nevermore3
Copy link
Contributor Author

Please add some description of what this pr for, from code it seems pushdown vertex filter to storage, while graph side logic seems not changed, only pass nullptr to the new added vertex_filte.

Yes, the getNeightbor interface of the graph side behaves the same as before, it is only used for subgraphs

@@ -152,6 +152,13 @@ nebula::cpp2::ErrorCode QueryBaseProcessor<REQ, RESP>::buildFilter(
if (filter_ == nullptr) {
return nebula::cpp2::ErrorCode::E_INVALID_FILTER;
}
const auto* vertexFilterStr = getFilter(req, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Be careful here, if the filter is vertex-only, both filter_ and vertexFilter_ will be set, the Filter will eval more than once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it will be executed twice if vertexFilter_ and filter_ are the same And the result is true

Copy link
Contributor

Choose a reason for hiding this comment

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

Is filter and vertex-filter mutually exclusive? (can't set them both at the same request)? If is, we only need to eval once I think~

BTW, where do we extract vertex filter? I didn't see the code to set it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vertexFilter_ is a subset of filter_, and this feature is not universal (
because we can't handle logicalOR expressions with mixed vertex and edges. like $^.player.age > 30 OR like.likeness > 100), it is only used for subgraphs, there will be code extracted by vertexfilter in #4357

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see~

Copy link
Contributor

@critical27 critical27 left a comment

Choose a reason for hiding this comment

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

Is it a temporary solution for #4649?

@nevermore3 nevermore3 force-pushed the fix_getNeighbor_src_filter branch from 7ff60a1 to 2bd9307 Compare September 26, 2022 02:42
@nevermore3
Copy link
Contributor Author

Is it a temporary solution for #4649?

After discussing with Peng Wei, this is the final solution

src/clients/storage/StorageClient.cpp Outdated Show resolved Hide resolved
src/storage/exec/FilterNode.h Outdated Show resolved Hide resolved
src/storage/exec/GetNeighborsNode.h Show resolved Hide resolved
@@ -93,6 +99,13 @@ class FilterNode : public IterateNode<T> {
// return true when the value iter points to a value which can filter
bool checkTagAndEdge() {
expCtx_->reset(this->reader(), this->key().str());
if (vertexFilterExp_ != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be also evaluated in checkTagOnly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will not be used in this scenario

src/storage/query/GetNeighborsProcessor.cpp Outdated Show resolved Hide resolved
@@ -152,6 +152,13 @@ nebula::cpp2::ErrorCode QueryBaseProcessor<REQ, RESP>::buildFilter(
if (filter_ == nullptr) {
return nebula::cpp2::ErrorCode::E_INVALID_FILTER;
}
const auto* vertexFilterStr = getFilter(req, true);
if (vertexFilterStr != nullptr && !vertexFilterStr->empty()) {
vertexFilter_ = Expression::decode(pool, *vertexFilterStr);
Copy link
Contributor

Choose a reason for hiding this comment

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

should vertexFilter_ be check in checkExp?

Copy link
Contributor Author

@nevermore3 nevermore3 Sep 26, 2022

Choose a reason for hiding this comment

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

vertexfilter is a subset of filter_, so does not need to be checked repeatedly

@nevermore3 nevermore3 force-pushed the fix_getNeighbor_src_filter branch from 2bd9307 to 31aec11 Compare September 26, 2022 06:38
@@ -152,6 +152,13 @@ nebula::cpp2::ErrorCode QueryBaseProcessor<REQ, RESP>::buildFilter(
if (filter_ == nullptr) {
return nebula::cpp2::ErrorCode::E_INVALID_FILTER;
}
const auto* vertexFilterStr = getFilter(req, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see~

Copy link
Contributor

@pengweisong pengweisong left a comment

Choose a reason for hiding this comment

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

Good job

@Sophie-Xie Sophie-Xie merged commit 80c0d09 into vesoft-inc:master Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getNeighbors return error
5 participants