Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

[S2GRAPH-180] Implement missing Management API #143

Merged
merged 21 commits into from Mar 27, 2018

Conversation

daewon
Copy link
Contributor

@daewon daewon commented Mar 26, 2018

Implement missing Management API

I have modified the signatures of several APIs to create the missing Management API and to unify the consistency of some APIs.
I also added the vertex query api, and unified the query api that fetches edges and vertices into one API.

API LIST

createService

mutation {
  Management {
    createService(
      name: "kakao"
      compressionAlgorithm: gz
    ) {
      isSuccess
    }
  }
}

createServiceColumn

mutation {
  Management {
    createServiceColumn (
      serviceName: kakao
      columnName: "user"
      columnType: string
      props: {
        name: "age"
        dataType: int
        defaultValue: "0"
        storeInGlobalIndex: true
      }
    ) {
      isSuccess
      object {
        name
        props {
          name
        }
      }
    }
  }
}

addPropsToServiceColumn

mutation {
  Management {
    addPropsToServiceColumn(
      service: {
        kakao: {
          columnName: user
          props: {
            name: "gender"
            dataType: string
            defaultValue: ""
            storeInGlobalIndex: true
          }
        }
      }
    ) {
      isSuccess
    }
  }
}

fetch Service(name: serviceName)

query {
    Management {
      Service(name: kakao) {
        name
        serviceColumns {
          name
          props {
            name
            dataType
          }
        }
      }
    }
  }

createLabel

mutation {
  Management {
    createLabel(
      name: "friends"
      sourceService: {
        kakao: {
          columnName: user
        }
      }
      targetService: {
        kakao: {
          columnName: user
        }
      }
    ) {
      isSuccess
    }
  }
}

addPropsToLabel

mutation {
  Management {
    addPropsToLabel(
      labelName: friends
      props: {
        name: "score"
        dataType: double
        defaultValue: "0"
        storeInGlobalIndex: true
      }
    ) {
      isSuccess
    }
  }
}

fetch Label(name: labelName)

query {
  Management {
    Label(name: friends) {
      name
      props {
        name
        dataType
      }
    }
  }
}

AddVertex

mutation {
  addVertex(
    kakao: {
      user: [{
        id: "daewon"
        age: 20
        gender: "M"
      },
      {
        id: "shon"
        age: 19
        gender: "F"
      }]
    }) {
    isSuccess
  }
}

addEdge

mutation {
  addEdge(
    friends: {
      from: "daewon"
      to: "shon"
      score: 0.9
    }
  ) {
    isSuccess
  }
}

Unified Fetch API

query {
  kakao {
    user(id: "daewon") {
      id
      friends {
        score
        to {
          id
          age
          friends(direction: in) {
            to {
              id
              age
            }
            direction
          }
        }
      }
    }
  }
}

Delete Label, ServiceColumn

mutation {
  Management {
    deleteLabel(name: friends) {
      isSuccess
    }

    deleteServiceColumn(service: {
      kakao: {
        columnName: user
      }
    }) {
      isSuccess
    }
  }
}

I wrote a TC to explain how to use the GraphQL API.

There is a bug in the vertex property when using backend mode with rocksdb.
The TC below is based on hbase and we will link the issue separately.

[info] ScenarioTest:
[info] + Use the GraphQL API to create basic friendships.
[info] Create schema using Management API
[info]   Create and query Service, ServiceColumn, ColumnMeta(Props)
[info]   - should create service: 'kakao' (3 seconds, 646 milliseconds)
[info]   - should create serviceColumn to Service 'kakao' (89 milliseconds)
[info]   - should add props(gender) to serviceColumn 'user' (41 milliseconds)
[info]   - should fetch service: 'kakao' with serviceColumn: 'user' with props: ['age', 'gender'] (20 milliseconds)
[info]   Create and query Label, LabelMeta(Props)
[info]   - should create label: 'friends' (125 milliseconds)
[info]   - should add props to label 'friends' (35 milliseconds)
[info]   - should fetch label: 'friends' with props: ['score'] (16 milliseconds)
[info]   Add vertex to kakao.user' and fetch
[info]   - should add vertices: daewon(age: 20, gender: M), shon(age: 19), gender: F) to kakao.user (236 milliseconds)
[info]   - should fetch vertices: daewon(age: 20, gender: M), shon(age: 19), gender: F) from kakao.user (208 milliseconds)
[info] Add edge to label 'friends' and fetch
[info] - should add edges: daewon -> shon(score: 2) to friends (138 milliseconds)
[info] - should fetch edges: friends of kakao.user(daewon)  (149 milliseconds)
[info] Management: Delete label, service column
[info] - should delete label: 'friends' and serviceColumn: 'user' on kakao (54 milliseconds)
[info] - should fetch failed label: 'friends' and serviceColumn: 'user' (46 milliseconds)
[info] Run completed in 8 seconds, 427 milliseconds.
[info] Total number of tests run: 13
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 13, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.

daewon added 21 commits February 27, 2018 18:59
… S2GRAPH-180

* 'S2GRAPH-180' of github.daumkakao.com:Graph/s2graph:
  add dummy object for empty input type
* master:
  [S2GRAPH-186]: fix wrong escaping of double quotation marks
  fix json parse error
  fix wrong escaping of double quotation marks
  [S2GRAPH-184]: spark driver exit abnormally in the loader of s2jobs
  fix spark driver exit abnormally bug
  test s2jobs/loader.py on local.
  - add s2jobs subproject. - migrate bulk loader with spark 2.3.0. - add test cases for bulk loader.
  add integrate test on test case.
  remove unnecessary HConnection on HBaseContext and add generateHFile test case.
  bug fix on vertex property parsing.
  add test case for TransferHFile.
  add Vertex upsert on schemaVersion v4.
  fix null pointer error on Bulk Loader.
@SteamShon
Copy link
Contributor

@daewon LGTM.
One quick question, do we need to keep SangriaPlayJsonScalarType?(since all of the lines are commented)

@daewon
Copy link
Contributor Author

daewon commented Mar 27, 2018

@SteamShon This file is not currently used. It should not have been included in the commit.

@SteamShon
Copy link
Contributor

@daewon Thank you for the clarifying.

@asfgit asfgit merged commit ca7adee into apache:master Mar 27, 2018
asfgit pushed a commit that referenced this pull request Mar 27, 2018
JIRA:
    [S2GRAPH-180] https://issues.apache.org/jira/browse/S2GRAPH-180

Pull Request:
    Closes #143

Author
    daewon <daewon@apache.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants