DanGuge opened a new pull request, #2295:
URL: https://github.com/apache/incubator-hugegraph/pull/2295

   <!-- 
     Thank you very much for contributing to Apache HugeGraph, we are happy 
that you want to help us improve it!
   
     Here are some tips for you:
       1. If this is your first time, please read the [contributing 
guidelines](https://github.com/apache/hugegraph/blob/master/CONTRIBUTING.md)
   
       2. If a PR fix/close an issue, type the message "close xxx" (xxx is the 
link of related 
   issue) in the content, GitHub will auto link it (Required)
   
       3. Name the PR title in "Google Commit Format", start with "feat | fix | 
perf | refactor | doc | chore", 
         such like: "feat(core): support the PageRank algorithm" or "fix: wrong 
break in the compute loop" (module is optional)
         skip it if you are unsure about which is the best component.
   
       4. One PR address one issue, better not to mix up multiple issues.
   
       5. Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]` (or click 
it directly after 
   published)
   -->
   
   ## Purpose of the PR
   
   - Support label & property filtering for both edge and vertex and the 
filtering is implemented in Kout Post and Kneighbor Post Apis, reducing 
unnecessary graph searches through pruning
   - Support Kout dfs mode in Kout Post Api
   - related issue #2276
   
   <!--
   Please explain more context in this section, clarify why the changes are 
needed. 
   e.g:
   - If you propose a new API, clarify the use case for a new API.
   - If you fix a bug, you can clarify why it is a bug, and should be 
associated with an issue.
   -->
   
   ## Main Changes
   
   ### Label & property filtering for edge and vertex
   
   > The filtering is supported in Kout Post and Kneighbor Post Apis, and is 
there a need for other apis?
   
   Originally only edge label filtering was supported, now label and property 
filtering for edge and vertex is supported.
   
   - add classes VEStepEntity and VEStep to support serialization in request
   - add class Steps to support filtering of edge and vertex in runtime(core)
   - add new method edgesOfVertex(Id source, Steps steps) to support label and 
property filtering for both edge and vertex in HugeTraverser.java
   - [design 
document](https://hugegraph.feishu.cn/wiki/ZYjSw3PJji5cvxkfJbVcP5MrnJl)
   
   
![项目架构-顶点和边过滤](https://github.com/apache/incubator-hugegraph/assets/77946882/b175bb56-57dc-43a4-9227-0a44a6d13510)
   
   
   ### Kout dfs mode
   
   Add DFS-based Kout mode in Kout Post Api and users can select the algorithm 
throught request parameters.
   
   * add dfs kout in KoutTraverser.java
   * add class NestedIterator to support dfs traversal which can remember the 
vertices and layers you traversed in the past
   * [design 
document](https://hugegraph.feishu.cn/wiki/EOOMwn0pUiqo8TkqQobcqzYknNb)
   
   
   <!-- Please clarify what changes you are proposing. The purpose of this 
section is to outline the changes and how this PR fixes the issue. These change 
logs are helpful for better ant faster reviews.)
   
   For example:
   
   - If you introduce a new feature, please show detailed design here or add 
the link of design documentation.
   - If you refactor some codes with changing classes, showing the class 
hierarchy will help reviewers.
   - If there is a discussion in the mailing list, please add the link. -->
   
   ## Verifying these changes
   
   <!-- Please pick the proper options below -->
   
   - [ ] Trivial rework / code cleanup without any test coverage. (No Need)
   - [ ] Already covered by existing tests, such as *(please modify tests 
here)*.
   - [x] Need tests and can be verified as follows:
       - Postman Test: the tests of `Kout Post` are shown below
   
   ### Initialize the Graph
   
   * Initialze the graph according to the 
[link](https://hugegraph.apache.org/docs/clients/restful-api/traverser/#32-detailed-explanation-of-traverser-api-1)
   
   ### Label & property filtering for edge and vertex in Kout Post
   
   - Method & Url
   
   ```
   POST http://localhost:8080/graphs/{graph}/traversers/kout
   ```
   
   - Request Body
   
   ```json
   {
     "source": "1:marko",
       "steps": {
       "direction": "BOTH",
       "edge_steps": [
           {
               "label": "knows",
               "properties": {
                   "weight": "P.gt(1.2)"
               }
           },
           {
               "label": "created",
               "properties": {
                   "weight": "P.gt(0.39)"
               }
           }
       ],
       "vertex_steps": [
           {
               "label": "person",
               "properties": {
                   "age": "P.lt(33)"
               }
           },
           {
               "label": "software",
               "properties": {}
           }
       ],
       "max_degree": 10000,
       "skip_degree": 100000
       },
     "max_depth": 3,
     "nearest": false,
     "limit": 10000,
     "with_vertex": false,
     "with_path": true,
     "with_edge": false
   }
   ```
   
   - Response Body
   
   ```json
   {
       "kout": [
           "2:ripple",
           "2:lop"
       ],
       "size": 2,
       "paths": [
           {
               "objects": [
                   "1:marko",
                   "2:lop",
                   "1:josh",
                   "2:lop"
               ]
           },
           {
               "objects": [
                   "1:marko",
                   "2:lop",
                   "1:josh",
                   "2:ripple"
               ]
           }
       ],
       "vertices": [
           "2:ripple",
           "1:marko",
           "1:josh",
           "2:lop"
       ],
       "edges": [
           "S1:josh>2>>S2:ripple",
           "S1:josh>2>>S2:lop",
           "S1:marko>2>>S2:lop"
       ],
       "measure": {
           "edge_iterations": 5,
           "vertice_iterations": 3,
           "cost(ns)": 175009500
       }
   }
   ```
   
   ### Kout Post dfs mode
   
   - Method & Url
   
   ```
   POST http://localhost:8080/graphs/{graph}/traversers/kout
   ```
   
   - Request Body
   
   ```json
   {
     "source": "1:marko",
       "steps": {
       "direction": "BOTH",
       "edge_steps": [
           {
               "label": "knows",
               "properties": {
                   "weight": "P.gt(1.2)"
               }
           },
           {
               "label": "created",
               "properties": {
                   "weight": "P.gt(0.39)"
               }
           }
       ],
       "vertex_steps": [
           {
               "label": "person",
               "properties": {
                   "age": "P.lt(33)"
               }
           },
           {
               "label": "software",
               "properties": {}
           }
       ],
       "max_degree": 10000,
       "skip_degree": 100000
       },
     "max_depth": 3,
     "nearest": false,
     "limit": 10000,
     "with_vertex": false,
     "with_path": true,
     "with_edge": false,
     "algorithm": "depth_first_search"
   }
   ```
   
   - Response Body
   
   ```json
   {
       "kout": [
           "2:ripple",
           "2:lop"
       ],
       "size": 2,
       "paths": [
           {
               "objects": [
                   "1:marko",
                   "2:lop",
                   "1:josh",
                   "2:lop"
               ]
           },
           {
               "objects": [
                   "1:marko",
                   "2:lop",
                   "1:josh",
                   "2:ripple"
               ]
           }
       ],
       "vertices": [
           "2:ripple",
           "1:marko",
           "1:josh",
           "2:lop"
       ],
       "edges": [
           "S1:josh>2>>S2:ripple",
           "S1:josh>2>>S2:lop",
           "S1:marko>2>>S2:lop"
       ],
       "measure": {
           "edge_iterations": 6,
           "vertice_iterations": 3,
           "cost(ns)": 60305791
       }
   }
   ```
   
   <img width="853" alt="image" 
src="https://github.com/apache/incubator-hugegraph/assets/77946882/5190bea0-ca00-4ab2-acfc-48416b73d724";>
   
   
   ## Does this PR potentially affect the following parts?
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ]  Nope
   - [ ]  Dependencies (add/update license info) <!-- Don't forget to 
add/update the info in "LICENSE" & "NOTICE" files (both in root & dist module) 
-->
   - [ ]  Modify configurations
   - [x]  The public API
   - [ ]  Other affects (typed here)
   
   ## Documentation Status
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [x]  `Doc - TODO` <!-- Your PR changes impact docs and you will update 
later -->
   - [ ]  `Doc - Done` <!-- Related docs have been already added or updated -->
   - [ ]  `Doc - No Need` <!-- Your PR changes don't impact/need docs -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to