Updated on 2024-05-23 GMT+08:00

Exporting Job Execution Results to Files (2.2.1)

Function

This API is used to export the execution result (result) of an asynchronous job (jobId) to a file.

URI

POST /ges/v1.0/{project_id}/graphs/{graph_name}/jobs/{job_id}/action?action_id=export-result
Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

graph_name

Yes

String

Graph name

job_id

Yes

String

ID of the job corresponding to the response

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

exportPath

Yes

String

Export path

fileName

No

String

Name of the exported file

obsParameters

Yes

String

OBS authentication parameters. For details, see Table 3.

paginate

No

Object

Pagination parameter. By default, pagination is disabled for the asynchronous task export API. For details, see Table 4.

erase

No

Boolean

Specifies whether to delete the original job after the export. The value can be true or false. The default value is true, indicating that the job is deleted and resources are released by default.

Table 3 obsParameters parameter description

Parameter

Mandatory

Type

Description

accessKey

Yes

String

AK value

secretKey

Yes

String

SK value

Table 4 Elements in paginate

Parameter

Mandatory

Type

Description

enable

No

Bool

Whether to enable pagination. The default value is false. To enable pagination, set this parameter to true.

rowCountPerFile

No

Int

Maximum number of rows in each file when execution results are exported by page. The default value is 10000000.

numThread

No

Int

Number of concurrent threads when execution results are exported by page. The default value is 8.

maxSizePerFile

No

Int

Maximum size of each file when execution results are exported by page, in bytes.

  • paginate parameter description
    1. When pagination is enabled, fileName in the request body indicates the directory name, and the directory is used to store pagination files. When pagination is disabled, fileName indicates the file name. Before the export, ensure that the path the file name points to is empty so that the existing data on OBS will not be overwritten during the export.
    2. If the value of numThread is greater than the number of vCPUs used by the GES graph instance, the parameter is set to the number of vCPUs.
    3. The rowCountPerFile value affects the number of actually used threads. That is, when the ratio of the result set size to rowCountPerFile is less than numThread, the ratio is used as the value of numThread.
    4. If the request is canceled by the user, the data uploaded to OBS will not be deleted. For details about the API for canceling jobs, see Canceling a Job (1.0.0).
  • When the pagination function is enabled, the file name is named as follows:

    If enable in the paginate parameter is set to true, fileName indicates a directory. Files in the directory are named using the combination of the thread ID and file number, and are separated by a period (.). For example, for 3.2 million data records, the examples of the first and last file names in different configurations are as follows:

    rowCountPerFile

    100,000

    100,000

    1 million

    1 million

    5 million

    numThread

    2

    48

    2

    5

    2

    Threads Actually Used

    2

    32

    2

    4

    1

    Files Generated by a Single Thread

    16

    1

    2

    1

    1

    First File Name

    00.000.txt

    00.000.txt

    00.00.txt

    00.00.txt

    00.00.txt

    Last File Name

    01.015.txt

    031.000.txt

    01.01.txt

    03.00.txt

    00.00.txt

    To export the data of a Ten-billion-vertex graph on multiple nodes at the same time, use the host ID as the prefix of the file name.

Response Parameters

Table 5 Response body parameters

Parameter

Type

Description

errorMessage

String

System prompt.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error message.

errorCode

String

System prompt code.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error code.

jobId

String

ID of an asynchronous job.

You can view the job execution status and obtain the return result by querying the job ID. For details, see Querying Job Status on the Service Plane (1.0.0).

Example Request

  • Example request 2: Export the execution results of an asynchronous job to an OBS file. The export path is demo_movie/. The name of the exported file is louvain. After the export, the original job is deleted.
    POST /ges/v1.0/{project_id}/graphs/{graph_name}/jobs/{job_id}/action?action_id=export-result
    {
        "exportPath": "demo_movie/",
        "fileName": "louvain",
        "erase":  true,
        "obsParameters": {
            "accessKey": "xxxx",
            "secretKey": "xxxx"
        }
    }
  • Example request 2: Export the execution result of an asynchronous job to an OBS file. The export path is demo_movie/. The name of the exported file is louvain. By default, pagination is disabled. When data is exported by page, the maximum number of rows in each file is 100,000.
    POST /ges/v1.0/{project_id}/graphs/{graph_name}/jobs/{job_id}/action?action_id=export-result
    {
        "exportPath": "demo_movie/",
        "fileName": "louvain",
        "paginate":{
        "enable":true,
        "numThread":2,
        "rowCountPerFile":100000,
        },
        "obsParameters": {
            "accessKey": "xxxx",
            "secretKey": "xxxx"
        }
    }

    Currently, Cypher statements can only be used to export common value types, such as attribute values, numbers, and strings, but not composite value types (such as lists and maps), vertices, or edges. Example:

    • The results of the following statements can be exported:

      match (n) return id(n) limit 10

      match (n) return n.age, n.occupation

      match (n)-[r]->(m) return n.Rating limit 10

      unwind [1,2,3] as p return p

    • The exported TXT file contains null values or blank lines because the results of the following statements contain objects or compound values:

      return [1,2,3], {a:1}

      match (n) return n limit 10

      match (n)-[r]->(m) return r limit 10

Example Response

Status code: 200

Example response (successful request)

HttpStatusCode: 200
{
    "jobId": "f99f60f1-bba6-4cde-bd1a-ff4bdd1fd500000168232"
}

Status code: 400

Example response for a failed request

HttpStatusCode: 400
{
    "errorMessage": "graph [demo] is not found",
    "errorCode": "GES.8011"
}

Status Codes

Return Value

Description

400 Bad Request

Request error.

401 Unauthorized

Authorization failed.

403 Forbidden

No operation permissions.

404 Not Found

No resources found.

500 Internal Server Error

Internal server error.

503 Service Unavailable

Service unavailable.

Error Codes

See Error Codes.

Exporting the Result in TXT File

  1. The following is an example of the algorithm execution result, for example, content of Louvain.txt:
    # modularity: 0.4269691347613425,
    #community_num: 4,
    #runtime: 0.003784,
    #data_total_size: 34
    #community:
    1,1
    2,1
    ...
  2. The following is an example Cypher query result:
    • Example 1

      Query statement:

      match (n:user)-[r]->(m:movie) return id(n),n.Name, n.Occupation, n.Age,r.Score,m.ChineseTitle

      Result:

      #data_total_size:1209
      #data_return_size:1209
      #data_offset:0
      #records:
      Vivian, artist, 25-34, 5, Lethal Weapon
      Vivian, Artist, 25-34, 4, Raising Arizona
      Mercedes, K-12 student, Under 18, 3, Lethal Weapon
      Mercedes, K-12 student, Under 18, 3, The Rock
      ...
    • Example 2

      Query statement:

      match (n)-->(m) where id(n)='Vivian' return labels(m),count(*)

      Result:

      #data_total_size:2
      #data_return_size:2
      #data_offset:0
      #records:
      user,5
      movie,2