Configure GDB Writer on the DataWorks platform

Updated at:

This topic describes the parameters supported by GDB Writer, such as data types, field mapping, and data sources, and provides configuration examples.

Note

Usage notes

  • Run the synchronization task for vertices first. After the vertex task is successful, run the synchronization task for edges.
  • Constraints on vertices:
    • A vertex must have a type name, which corresponds to the label.
    • A vertex must have a primary key ID. The ID must be of the string type and unique among all vertices. If the ID is not a string, the GDB Writer plugin forcibly converts it to a string.
    • Be cautious when you set the `idTransRule` parameter for the primary key of a vertex. If you set this parameter to `None`, you must ensure that the vertex ID is unique among all global vertices.
  • Constraints on edges:
    • An edge must have a type name, which corresponds to the label.
    • The primary key ID is optional for an edge:
      • If specified, the value must be unique across the global edge.
      • If you do not specify a primary key ID, the GDB server generates a universally unique identifier (UUID) by default. The UUID must be of the string type. If the UUID is not a string, the GDB Writer plugin forcibly converts it.
    • Be cautious when you set the `idTransRule` parameter for the primary key of an edge. If you set this parameter to `None`, you must ensure that the edge ID is unique among all global vertices and edges.
    • You must specify the `srcIdTransRule` and `dstIdTransRule` parameters for an edge. The values of these parameters must match the value of the `idTransRule` parameter that you specified when you imported the vertices.
  • Unless otherwise specified, field names and enumerated values in the examples are case-sensitive.
  • The GDB server supports only the UTF-8 encoding format. Therefore, your source data must also use the UTF-8 encoding format.
  • Due to network limits, you can run data integration tasks only in exclusive resource mode.

Parameter description

ParameterDescriptionRequiredDefault value
datasourceThe name of the data source. In the code editor, you can add a data source. The value of this parameter must be the same as the name of the added data source.YesNone
labelTypeThe type of data to write. Valid values:
  • VERTEX: indicates a vertex.
  • EDGE: indicates an edge.
YesNone
writeModeThe processing mode for duplicate IDs during import. Valid values:
  • INSERT: reports an error if a duplicate ID is written. The number of error records increases by one.
  • MERGE: overwrites the old property with the new value if a duplicate ID is written. This operation is not counted as an error.
  • SKIP: skips the record if a duplicate ID is written. This operation is not counted as an error.
YesINSERT
labelThe type name, which is the name of the vertex or edge.

The label can be read from a source column. For example, #{0} uses the value of the first column as the type name. The source column index starts from 0.

YesNone
srcLabelThe name of the start vertex.
  • This parameter is not required when you write data for a vertex.
  • This parameter is not required when you write data for an edge and srcIdTransRule is set to none. Otherwise, this parameter is required.
NoNone
dstLabelThe name of the end vertex.
  • This parameter is not required when you write data for a vertex.
  • This parameter is not required when you write data for an edge and srcIdTransRule is set to none. Otherwise, this parameter is required.
NoNone
idTransRuleThe conversion rule for the primary key ID. Valid values:
  • none: does not convert the mapped value and retains the source field of the primary key.
  • labelPrefix: converts the mapped value to {label_name}{source_field}
Yesnone
srcIdTransRuleThe conversion rule for the primary key ID of the start vertex when you write data for an edge. Valid values:
  • none: does not convert the mapped value and retains the source field of the primary key. In this case, you can leave srcLabel
  • labelPrefix: converts the mapped value to {label_name}{source_field}
Required when you write data for an edge.none
dstIdTransRuleThe conversion rule for the primary key ID of the end vertex when you write data for an edge. Valid values:
  • none: does not convert the mapped value and retains the source field of the primary key. In this case, you can leave dstLabel empty.
  • labelPrefix: converts the mapped value to {label_name}{source_field}
Required when you write data for an edge.none
column::nameConfigures the name field for the field mapping of a vertex or edge.

This parameter specifies the name of the vertex or edge field. If the mapping is for a property, this is the property name.

YesNone
column::typeConfigures the type field for the field mapping of a vertex or edge.
This parameter specifies the data type of the mapped value for the vertex or edge field.
  • The primary key ID supports only the string type. You must ensure that the ID can be converted to the string type. The plugin forcibly converts non-string types to the string type.
  • Supported types for common properties: int, long, float, double, boolean, and string
YesNone
column::valueConfigures the value field for the field mapping of a vertex or edge.
This parameter specifies the mapped value for the vertex or edge field. Custom concatenation is supported only for string values.
  • #{N}: directly maps the source value. N is the source column index, which starts from 0.
  • test-#{0}: concatenates and transforms the source value. You can add a fixed string before or after the #{0} value.
  • #{0}-#{1}: concatenates multiple fields. You can also add a fixed string at any position, such as test-#{0}-test1-#{1}-test2
YesNone
column::columnTypeConfigures the columnType field for the field mapping of a vertex or edge.
This parameter specifies the category of the mapped field. The following enumerated values are supported:
  • primaryKey: indicates that this field maps to the primary key ID.
  • vertexProperty: optional when writing data for a vertex. Indicates a common property of the vertex.
  • vertexSetProperty: optional when writing data for a vertex. Indicates a SET property of the vertex. Multiple property values are separated into multiple columns. Property values must be of a basic type.
  • vertexJsonProperty: optional when writing data for a vertex. Indicates that the vertex property is in the JSON format. For the value structure, see the properties example.
  • srcPrimaryKey: required when writing data for an edge. Indicates that this field maps to the primary key ID of the start vertex.
  • dstPrimaryKey: required when writing data for an edge. Indicates that this field maps to the primary key ID of the end vertex.
  • edgeProperty: optional when writing data for an edge. Indicates a common property of the edge.
  • edgeJsonProperty: optional when writing data for an edge. Indicates that the edge property is in the JSON format. For the value structure, see the properties example.
YesNone
The following code shows an example of the properties:
{"properties":[
    {"k":"name","t":"string","v":"tom"},
    {"k":"age","t":"int","v":"20"},
    {"k":"sex","t":"string","v":"male"}
]}

Introduction to wizard development

Codeless UI development is not currently supported.

Script development

You can configure a data synchronization job to write data to GDB. For more information about how to configure the job in the code editor, see Configure a task in the code editor.

  • Vertex configuration example
    {
        "order":{
            "hops":[
                {
                    "from":"Reader",
                    "to":"Writer"
                }
            ]
        },
        "setting":{
            "errorLimit":{
                "record":"100"             // The maximum number of dirty data records allowed.
            },
            "jvmOption":"",
            "speed":{
                "concurrent":8,            // The number of concurrent threads.
                "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 data source name.
                    "label": "person",               // The label name, which is the vertex name.
                    "srcLabel": "",                  // This field can be ignored for the vertex type.
                    "dstLabel": "",                  // This field can be ignored for the vertex type.
                    "labelType": "VERTEX",           // The label type. "VERTEX" indicates a vertex.
                    "writeMode": "INSERT",           // The processing mode for duplicate IDs during import.
                    "idTransRule": "labelPrefix",    // The conversion rule for the primary key of the vertex.
                    "srcIdTransRule": "none",        // This field can be ignored for the vertex type.
                    "dstIdTransRule": "none",        // This field can be ignored for the vertex type.
                    "maxConnectionPoolSize":8,      // Set this value to be greater than or equal to `concurrent`. Valid values are 8, 16, 32, and so on.
                    "column": [
                        {
                            "name": "id",            // The field name.
                            "value": "#{0}",         // #{0} indicates the value of the first field from the source. Concatenation is supported. 0 is the column index of the source.
                            "type": "string",        // The field type.
                            "columnType": "primaryKey"    // The field category. primaryKey indicates the primary key.
                        },                           // The primary key of the vertex. The field name must be id and the type must be string. This record must exist.
                        {
                            "name": "person_age", 
                            "value": "#{1}",         // #{1} indicates the value of the second field from the source. Concatenation is supported.
                            "type": "int",
                            "columnType": "vertexProperty"   // The field category. vertexProperty indicates a vertex property.
                        },                           // A vertex property. Supported types: int, long, float, double, boolean, and string.
                        {
                            "name": "person_credit",
                            "value": "#{2}",         // #{2} indicates the value of the third field from the source. Concatenation is supported.
                            "type": "string",
                            "columnType": "vertexProperty"
                        },                           // A vertex property.
                    ]
                }
                "stepType":"gdb"
            }
        ],
        "type":"job",
        "version":"2.0"
    }
  • Edge configuration example
    {
        "order":{
            "hops":[
                {
                    "from":"Reader",
                    "to":"Writer"
                }
            ]
        },
        "setting":{
            "errorLimit":{
                "record":"100"            // The maximum number of dirty data records allowed.
            },
            "jvmOption":"",
            "speed":{
                "concurrent":8,
                "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 data source name.
                    "label": "use",                       // The label name, which is the edge name.
                    "labelType": "EDGE",                  // The label type. EDGE indicates an edge.
                    "srcLabel": "person",                 // The name of the start vertex.
                    "dstLabel": "software",               // The name of the end vertex.
                    "writeMode": "INSERT",                // The processing mode for duplicate IDs during import.
                    "idTransRule": "labelPrefix",         // The conversion rule for the primary key of the edge.
                    "srcIdTransRule": "labelPrefix",      // The conversion rule for the primary key of the start vertex.
                    "dstIdTransRule": "labelPrefix",      // The conversion rule for the primary key of the end vertex.
                    "maxConnectionPoolSize":8,          // Set this value to be greater than or equal to `concurrent`. Valid values are 8, 16, 32, and so on.
                    "column": [
                        {
                            "name": "id",                 // The field name.
                            "value": "#{0}",              // #{0} indicates the value of the first field from the source. Concatenation is supported.
                            "type": "string",             // The field type.
                            "columnType": "primaryKey"    // The field category. primaryKey indicates the primary key.
                        },                                // The primary key of the edge. The field name must be id and the type must be string. This record is optional.
                        {
                            "name": "id",
                            "value": "#{1}",              // Concatenation is supported. Make sure that the mapping rule is consistent with the rule used when you imported the vertex.
                            "type": "string",
                            "columnType": "srcPrimaryKey" // The field category. srcPrimaryKey indicates the primary key of the start vertex.
                        },                                // The primary key of the start vertex. The field name must be id and the type must be string. This record must exist.
                        {
                            "name": "id",
                            "value": "#{2}",              // Concatenation is supported. Make sure that the mapping rule is consistent with the rule used when you imported the vertex.
                            "type": "string",
                            "columnType": "dstPrimaryKey" // The field category. dstPrimaryKey indicates the primary key of the end vertex.
                        },                                // The primary key of the end vertex. The field name must be id and the type must be string. This record must exist.
                        {
                            "name": "person_use_software_time",
                            "value": "#{3}",              // Concatenation is supported.
                            "type": "long",
                            "columnType": "edgeProperty"  // The field category. edgeProperty indicates an edge property.
                        },                                // An edge property. Supported types: int, long, float, double, boolean, and string.
                        {
                            "name": "person_regist_software_name",
                            "value": "#{4}",              // Concatenation is supported.
                            "type": "string",
                            "columnType": "edgeProperty"
                        },                                // An edge property.
                        {
                            "name": "id",
                            "value": "#{5}",              // Concatenation is supported.
                            "type": "long",
                            "columnType": "edgeProperty"
                        },                                // An edge property whose field name is id. Unlike the primary key ID, this field is a common property and is optional.
                    ]
                }
                "stepType":"gdb"
            }
        ],
        "type":"job",
        "version":"2.0"
    }
Note

To use SET properties, you must upgrade your GDB instance to V1.0.20 or later. Confirm your instance version before you use SET properties.