ASF GitHub Bot commented on S2GRAPH-229:

GitHub user daewon opened a pull request:


    [S2GRAPH-229] 'Step' abstraction for combinable queries

    # Step interface abstraction for combinable queries.
    I have created an interface for each step to enable query 
combinations(using Observable[T])
    trait RxStep[-A, +B] extends (A => Observable[B])
    RxStep simply inherits the function interface (A => B)
    This makes it possible to naturally connect with the transform functions 
provided by Observable (map, flatMap ..)
    I have implemented a simple query in the `GraphTest.scala` file for the 
step utilization test.
    Here is the example code.
    'VertexFetchStep' and 'EdgeFetchStep' each implement RxStep trait.
    In addition, since GraphElement => Boolean is implemented in 'Where', it 
naturally integrates with Observable interface.
    val v1 = VertexFetchStep(graph)
    val qpIn = QueryParam(labelName = testLabelName, direction = "in")
    val qpOut = QueryParam(labelName = testLabelName, direction = "out")
    val e1 = EdgeFetchStep(graph, qpIn) 
    val e2 = EdgeFetchStep(graph, qpOut)
    val where = Where("_to = 20").get
    val q =
        .flatMap(v => e1.apply(v) ++ e2.apply(v)) 
    val res = q.toBlocking.toList

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/daewon/incubator-s2graph S2GRAPH-229

Alternatively you can review and apply these changes as the patch at:


To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #178
commit 6b088944b877b25775ac424658ad9b6472203082
Author: daewon <daewon@...>
Date:   2018-07-02T06:28:17Z

    make step works


> 'Step' abstraction for combinable queries
> -----------------------------------------
>                 Key: S2GRAPH-229
>                 URL: https://issues.apache.org/jira/browse/S2GRAPH-229
>             Project: S2Graph
>          Issue Type: Task
>          Components: s2core
>            Reporter: Daewon Jeong
>            Priority: Minor
> Graph Query is a combination of queries of each step.
> For example, 
>   1. you can take a vertex, 
>    2. then bring the edge back with that vertex, 
>    3. get the vertex from the edge, 
>    4. and bring the edge from that vertex.
> The query that is being provided now is not tied to each of the above steps, 
> but is tightly coupled throughout the query.
> Since functions such as filter, transform(group_by, merge), and 
> postprocess(conversion to json/xml) are tightly coupled to the entire query 
> function, 
>  it is difficult to test each function separately. 
> To solve this problem, 
>    1. each step is created as an independent function and 
>    2. the function of assembling each step is separated separately.
> Each step is separated as above, the following functions can be implemented 
> without additional code.
>   ex) In the case of deleteAll, fetch each edge and make delete request 
> again. 
> Implement Prototyping
>     1. For query efficiency, each step implements the function to return 
> Observable.
>     2. Use Observable(RxScala)'s flatMap to connect each step.
> Below is the pseudocode.
> 1. Bringing the edges from the vertex, collect only edges whose score is 0.5 
> and serialize them to Json
> {code:java}
>  val vs: Step[Int, S2VertexLike] = VertexStep()
>  val es: Step[S2VertexLike, S2EdgeLike] = EdgeStep(dir = "OUT")
>  val js: Step[S2EdgeLike, Json] = JsonSerializeStep(limit: 10)
> val q: Observable[Json] = 
>  vs.apply(1) 
>  .flatMap(es)
>  .filter(_.property("score") > 0.5)
>  .flatMap(js)
> {code}
> What to think about.
>     1. The ability to link each step is subject to Observable.
>  - This makes it impossible to draw the connection graph of the Step instead 
> of making the function easier to implement.

This message was sent by Atlassian JIRA

Reply via email to