This topic describes the data types and parameters that GDB Writer supports and how to configure it by using the code editor.

Graph Database (GDB) is a real-time and reliable online database service that makes it easy to store and navigate the relationships between highly connected datasets. GDB supports the Property Graph model and its query language Apache TinkerPop Gremlin, allowing you to build queries that efficiently navigate highly connected datasets.
Notice
  • GDB Writer supports only exclusive resource groups for Data Integration, but not the default resource group or custom resource groups. For more information, see Use exclusive resource groups for data integration and Add a custom resource group.
  • You must configure a GDB connection before you configure GDB Writer.
  • You must configure two sync nodes to synchronize vertex data and edge data separately.

Limits

  • You must run a sync node to synchronize vertex data before you run a sync node to synchronize edge data.
  • Limits on vertices:
    • A vertex must have a vertex name that is specified by the label parameter.
    • A vertex must have a unique primary key of the STRING type. If the primary key is not a string, GDB Writer forcibly converts the primary key to a string.
    • Exercise caution when you set the idTransRule parameter. If you set this parameter to None, make sure that the primary key of each vertex is unique among global vertices.
  • Limits on edges:
    • An edge must have an edge name that is specified by the label parameter.
    • The primary key is optional for an edge.
      • If you specify a primary key for an edge, make sure that the ID is unique among global edges.
      • If no primary key is specified, GDB Writer automatically generates a universally unique identifier (UUID) of the STRING type for the edge. If the UUID is not a string, GDB Writer forcibly converts the UUID to a string.
    • Exercise caution when you set the idTransRule parameter. If you set this parameter to None, make sure that the primary key of each edge is unique among global edges.
    • The srcIdTransRule and dstIdTransRule parameters are required for an edge, and their values must be the same as the value of the idTransRule parameter of the related vertex.
  • Unless otherwise specified, field names and enumerated values in this topic are case-sensitive.
  • GDB Writer supports only the UTF-8 encoding format. Source data must be encoded in UTF-8.
  • Due to network constraints, sync nodes that are used to synchronize data to GDB databases must be run on exclusive resource groups for Data Integration. You must purchase an exclusive resource group for Data Integration and bind it to the virtual private cloud (VPC) where the GDB instance resides in advance. For more information, see Exclusive resource mode. Scheduling nodes can be run on the default resource group.

Parameters

Parameter Description Required Default value
datasource The connection name. It must be the same as the name of the added connection. You can add connections in the code editor. Yes N/A
label The label, that is, the name of the vertex or edge.

GDB Writer can obtain labels from columns in the source table. For example, if you set this parameter to ${0}, GDB Writer uses the value of the first column as the label. The column index starts from 0.

Yes N/A
labelType The type of the label. Valid values:
  • VERTEX: a vertex.
  • EDGE: an edge.
Yes N/A
srcLabel
  • The name of the start vertex in an edge when the labelType parameter is set to EDGE.

    In this case, this parameter can be left empty if srcIdTransRule is set to None. If srcIdTransRule is set to another value, this parameter is required.

  • Leave this parameter empty if the labelType parameter is set to VERTEX.
No N/A
dstLabel
  • The name of the end vertex in an edge when the labelType parameter is set to EDGE.

    In this case, this parameter can be left empty if dstIdTransRule is set to None. If dstIdTransRule is set to another value, this parameter is required.

  • Leave this parameter empty if the labelType parameter is set to VERTEX.
No N/A
writeMode The mode in which GDB Writer processes data records with duplicate primary keys. Valid values:
  • INSERT: returns an error message. The number of error data records is increased by 1.
  • MERGE: overrides the existing data record with the new one.
Yes INSERT
idTransRule The rule for converting the primary key. Valid values:
  • labelPrefix: converts the primary key to the {label}-{column in source} format.
  • None: does not convert the primary key.
Yes None
srcIdTransRule The rule for converting the primary key of the start vertex when the labelType parameter is set to EDGE. Valid values:
  • labelPrefix: converts the primary key to the {label}-{column in source} format.
  • None: does not convert the primary key. In this case, the srcLabel parameter can be left empty.
Required when the labelType parameter is set to EDGE None
dstIdTransRule The rule for converting the primary key of the end vertex when the labelType parameter is set to EDGE. Valid values:
  • labelPrefix: converts the primary key to the {label}-{column in source} format.
  • None: does not convert the primary key. In this case, the dstLabel parameter can be left empty.
Required when the labelType parameter is set to EDGE. None
column The mappings between the columns in the source and the vertices or edges to be synchronized.
  • name: the name of the vertex or edge property.
  • value: the value of the vertex or edge property. You can customize a value only in the code editor.
    • ${N}: uses the value of the Nth column in the source as the value of the vertex or edge property. N indicates the column index, which starts from 0.
    • ${0}: uses the value of the first column in the source as the value of the vertex or edge property.
    • test-${0}: appends a fixed string such as test- to the beginning or end of ${0}.
    • ${0}-${1}: combines the values of multiple columns in the source as the value of vertex or edge property. You can also add fixed strings at any positions, for example, test-${0}-test1-${1}-test2.
  • type: the data type of the vertex or edge property.

    The primary key must be of the STRING type. If the value obtained from the source is not a string, GDB Writer forcibly converts the value to a string. Make sure that the value can be converted to a string.

    Other properties can be of the INT, LONG, FLOAT, DOUBLE, BOOLEAN, or STRING type.

  • columnType: the category of the vertex or edge property.
    • For both the vertex and edge

      primaryKey: the primary key.

    • For the vertex
      • vertexProperty: a common property of the vertex.
      • vertexJsonProperty: a JSON property of the vertex. For more information about the value structure, see the sample of properties.
    • For the edge
      • srcPrimaryKey: the primary key of the start vertex.
      • dstPrimaryKey: the primary key of the end vertex.
      • edgeProperty: a common property of the edge.
      • edgeJsonProperty: a JSON property of the edge. For more information about the value structure, see the sample of properties.

Sample of properties

{"properties":[
    {"k":"name","t":"string","v":"tom"},
    {"k":"age","t":"int","v":"20"},
    {"k":"sex","t":"string","v":"male"}
]}
Yes N/A

Configure GDB Writer by using the codeless UI

The codeless user interface (UI) is not supported for GDB Writer.

Configure GDB Writer by using the code editor

The following examples show how to configure a sync node to write vertex data and a sync node to write edge data to a GDB database in the code editor. For more information, see Create a sync node by using the code editor.
  • Configure a sync node to write vertex data to a GDB database
    {
        "order":{
            "hops":[
                {
                    "from":"Reader",
                    "to":"Writer"
                }
            ]
        },
        "setting":{
            "errorLimit":{
                "record":"100" // The maximum number of dirty data records allowed.
            },
            "jvmOption":"",
            "speed":{
                "concurrent":3,
                "throttle":false
            }
        },
        "steps":[
            {
                "category":"reader",
                "name":"Reader",
                "parameter":{
                    "column":[
                        "*"
                    ],
                    "datasource":"_ODPS",
                    "emptyAsNull":true,
                    "guid":"",
                    "isCompress":false,
                    "partition":[],
                    "table":""
                },
                "stepType":"odps"
            },
            {
                "category":"writer",
                "name":"Writer",
                "parameter": {
                    "datasource": "testGDB", // The connection name.
                    "label": "person", // The label, that is, the name of the vertex.
                    "srcLabel": "", // Use the default setting.
                    "dstLabel": "", // Use the default setting.
                    "labelType": "VERTEX", // The type of the label. A value of VERTEX indicates a vertex.
                    "writeMode": "INSERT", // The mode in which GDB Writer processes data records with duplicate primary keys.
                    "idTransRule": "labelPrefix", // The rule for converting the primary key of the vertex.
                    "srcIdTransRule": "none", // Use the default setting.
                    "dstIdTransRule": "none", // Use the default setting.
                    "column": [
                        {
                            "name": "id", // The name of the vertex property.
                            "value": "${0}", // The value of the first column in the source is used as the value of the vertex property. If multiple columns are specified, they can be concatenated. In this example, 0 is the column index.
                            "type": "string", // The data type of the vertex property.
                            "columnType": "primaryKey" // The category of the vertex property. A value of primaryKey indicates the primary key.
                        }, // The primary key of the vertex. The value must be an ID of the STRING type, and the record must exist.
                        {
                            "name": "person_age",
                            "value": "${1}", // The value of the second column in the source is used as the value of the vertex property. If multiple columns are specified, they can be concatenated.
                            "type": "int",
                            "columnType": "vertexProperty" // The category of the vertex property. A value of vertexProperty indicates a common vertex property.
                        }, // A common property of the vertex. The value can be of the INT, LONG, FLOAT, DOUBLE, BOOLEAN, or STRING type.
                        {
                            "name": "person_credit",
                            "value": "${2}", // The value of the third column in the source is used as the value of the vertex property. If multiple columns are specified, they can be concatenated.
                            "type": "string",
                            "columnType": "vertexProperty"
                        }, // A common property of the vertex.
                    ]
                }
                "stepType":"gdb"
            }
        ],
        "type":"job",
        "version":"2.0"
    }
  • Configure a sync node to write edge data to a GDB database
    {
        "order":{
            "hops":[
                {
                    "from":"Reader",
                    "to":"Writer"
                }
            ]
        },
        "setting":{
            "errorLimit":{
                "record":"100"// The maximum number of dirty data records allowed.
            },
            "jvmOption":"",
            "speed":{
                "concurrent":3,
                "throttle":false
            }
        },
        "steps":[
            {
                "category":"reader",
                "name":"Reader",
                "parameter":{
                    "column":[
                        "*"
                    ],
                    "datasource":"_ODPS",
                    "emptyAsNull":true,
                    "guid":"",
                    "isCompress":false,
                    "partition":[],
                    "table":""
                },
                "stepType":"odps"
            },
            {
                "category":"writer",
                "name":"Writer",
                "parameter": {
                    "datasource": "testGDB", // The connection name.
                    "label": "use", // The label, that is, the name of the edge.
                    "labelType": "EDGE", // The type of the label. A value of EDGE indicates an edge.
                    "srcLabel": "person", // The name of the start vertex in the edge.
                    "dstLabel": "software", // The name of the end vertex in the edge.
                    "writeMode": "INSERT", // The mode in which GDB Writer processes data records with duplicate primary keys.
                    "idTransRule": "labelPrefix", // The rule for converting the primary key of the edge.
                    "srcIdTransRule": "labelPrefix", // The rule for converting the primary key of the start vertex.
                    "dstIdTransRule": "labelPrefix", // The rule for converting the primary key of the end vertex.
                    "column": [
                        {
                            "name": "id", // The name of the edge property.
                            "value": "${0}", // The value of the first column in the source is used as the value of the edge property. If multiple columns are specified, they can be concatenated.
                            "type": "string", // The data type of the edge property.
                            "columnType": "primaryKey" // The category of the edge property. A value of primaryKey indicates the primary key.
                        }, // The primary key of the edge. The value must be an ID of the STRING type, and the record must exist.
                        {
                            "name": "id",
                            "value": "${1}", // The value of the second column in the source is used as the value of the edge property. If multiple columns are specified, they can be concatenated. The mapping rule must be the same as that configured when you import the vertex.
                            "type": "string",
                            "columnType": "srcPrimaryKey" // The category of the edge property. The value of srcPrimaryKey indicates the primary key of the start vertex.
                        }, // The primary key of the start vertex. The value must be an ID of the STRING type, and the record must exist.
                        {
                            "name": "id",
                            "value": "${2}", // The value of the third column in the source is used as the value of the edge property. If multiple columns are specified, they can be concatenated. The mapping rule must be the same as that configured when you import the vertex.
                            "type": "string",
                            "columnType": "dstPrimaryKey" // The category of the edge property. A value of dstPrimaryKey indicates the primary key of the end vertex.
                        }, // The primary key of the end vertex. The value must be an ID of the STRING type, and the record must exist.
                        {
                            "name": "person_use_software_time",
                            "value": "${3}", // The value of the fourth column in the source is used as the value of the edge property. If multiple columns are specified, they can be concatenated.
                            "type": "long",
                            "columnType": "edgeProperty" // The category of the edge property. A value of edgeProperty indicates a common edge property.
                        }, // A common property of the edge. The value can be of the INT, LONG, FLOAT, DOUBLE, BOOLEAN, or STRING type.
                        {
                            "name": "person_regist_software_name",
                            "value": "${4}", // The value of the fifth column in the source is used as the value of the edge property. If multiple columns are specified, they can be concatenated.
                            "type": "string",
                            "columnType": "edgeProperty"
                        }, // A common property of the edge.
                        {
                            "name": "id",
                            "value": "${5}", // The value of the sixth column in the source is used as the value of the edge property. If multiple columns are specified, they can be concatenated.
                            "type": "long",
                            "columnType": "edgeProperty"
                        }, // A common property of the edge. The value is an ID. Different from the primary key, this property is optional.
                    ]
                }
                "stepType":"gdb"
            }
        ],
        "type":"job",
        "version":"2.0"
    }