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

feat(api): optimize adjacent-edges query #2408

Merged
merged 13 commits into from
Feb 26, 2024

Conversation

Z-HUANT
Copy link
Contributor

@Z-HUANT Z-HUANT commented Jan 4, 2024

Purpose of the PR

Main Changes

Relevant issue:#2255

Gremlin Query: For adjacency edge queries, if a vertex does not belong to the adjacent vertices of this edge, filter out that vertex.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:

edge data
image

GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?label=test
image

Does this PR potentially affect the following parts?

  • Nope
  • Dependencies (add/update license info)
  • Modify configurations
  • The public API
  • Other affects (typed here)

org.apache.hugegraph.api.graph.EdgeAPI#list

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. api Changes of API feature New feature tests Add or improve test cases labels Jan 4, 2024
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Attention: Patch coverage is 75.43860% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 66.30%. Comparing base (bc421bb) to head (fb7f000).
Report is 2 commits behind head on master.

Files Patch % Lines
.../apache/hugegraph/backend/tx/GraphTransaction.java 85.71% 1 Missing and 4 partials ⚠️
...in/java/org/apache/hugegraph/schema/EdgeLabel.java 42.85% 3 Missing and 1 partial ⚠️
...apache/hugegraph/backend/query/ConditionQuery.java 72.72% 0 Missing and 3 partials ⚠️
.../main/java/org/apache/hugegraph/cmd/InitStore.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2408      +/-   ##
============================================
+ Coverage     66.23%   66.30%   +0.07%     
- Complexity      827      829       +2     
============================================
  Files           511      511              
  Lines         42582    42622      +40     
  Branches       5935     5947      +12     
============================================
+ Hits          28204    28261      +57     
+ Misses        11566    11552      -14     
+ Partials       2812     2809       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imbajin imbajin changed the title feat:optimize edge query feat(api): optimize edge query Jan 4, 2024
@imbajin imbajin requested review from javeme and zyxxoo January 4, 2024 09:37
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jan 23, 2024
@Z-HUANT Z-HUANT force-pushed the feat-vertex-edge-optimization branch from 03f235c to 8a0e07f Compare January 23, 2024 03:44
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jan 23, 2024
@Z-HUANT
Copy link
Contributor Author

Z-HUANT commented Jan 23, 2024

The Gremlin optimization code has been added, and related tests are as follows.

Gremlin Optimization:

  • For IN queries: Remove non-adjacent nodes from the list.
  • For EQ queries: Return an empty query if it is not an adjacent node.

The following data is available:
image

Remarks: Subsequent code has undergone partial modifications (bug fixes), but the logic remains unchanged.

In queries test:
Filter out other nodes, only retain Person nodes:
image

Filter out other nodes, only retain software nodes:
image

Eq queries test:
Non-adjacent node query:
image

Adjacent node query:
image

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 25, 2024
@Z-HUANT Z-HUANT requested a review from javeme January 26, 2024 08:52
@Z-HUANT Z-HUANT requested a review from javeme February 24, 2024 10:21
@Z-HUANT Z-HUANT requested a review from javeme February 25, 2024 01:47
@javeme javeme changed the title feat(api): optimize edge query feat(api): optimize adjacent-edges query Feb 25, 2024
javeme
javeme previously approved these changes Feb 25, 2024
Copy link
Contributor

@javeme javeme left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 25, 2024
@Z-HUANT Z-HUANT requested a review from imbajin February 25, 2024 04:49
@VGalaxies VGalaxies merged commit d0f63c8 into apache:master Feb 26, 2024
21 checks passed
VGalaxies pushed a commit that referenced this pull request Feb 26, 2024
Relevant issue: #2255

Gremlin Query: For adjacency edge queries, if a vertex does not belong to the adjacent vertices of this edge, filter out that vertex.

---------

Co-authored-by: imbajin <jin@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Changes of API feature New feature lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files. tests Add or improve test cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants