本文为您介绍Maxgraph Writer支持的数据类型、字段映射和数据源等参数及配置示例。
说明 如果您需要导入自己的MaxCompute表至Maxgraph,请先在源端MaxCompute项目中授予Maxgraph build账号读取源端MaxCompute表的权限。请联系Maxgraph管理员提供关于授权的Maxgraph
build账号。
您可以通过创建数据和上线数据等操作,导入MaxCompute表至Maxgraph。
- Maxgraph读取您的MaxCompute表,根据MaxCompute表中的列到Maxgraph中点或边的映射关系,执行一个MapReduce作业。该MapReduce作业会将数据处理为Maxgraph内部存储需要的数据格式。
- Maxgraph将上一步处理好的数据载入Maxgraph的存储。
参数说明
参数 | 描述 | 是否必选 | 默认值 |
---|---|---|---|
endpoint | Maxgraph的URL。 | 是 | 无 |
graphName | 图实例的名称。 | 是 | 无 |
accessId | 用户名。 | 是 | 无 |
accessKey | 用户密码。 | 是 | 无 |
label | 标签名,即点或边的名称。 | 是 | 无 |
labelType | 标签类型,只能选择vertex或edge其中一种类型。 | 是 | 无 |
srcLabel | 边的起点标签,仅在导入边时使用。 | 是 | 无 |
dstLabel | 边的终点标签,仅在导入边时使用。 | 是 | 无 |
splitSize | 创建数据过程中MapReduce作业的分片大小。 | 否 | 256MB |
onlineMode | 数据上线模式,包括partition和type。两者区别如下:
|
否 | type |
column | 点的属性名,仅导入点时使用。 | 是 | 无 |
name | 属性的名称。 | 仅导入边时必填 | 无 |
propertyType | 属性的类型,包括srcPrimaryKey、dstPrimaryKey和edgeProperty。 | 仅导入边时必填 | 无 |
srcPrimaryKey | 起点主键,仅导入边时使用。 | 仅导入边时必填 | 无 |
dstPrimaryKey | 终点主键,仅导入边时使用。 | 仅导入边时必填 | 无 |
edgeProperty | 边的属性,如果边没有属性,可以不填。 | 否 | 无 |
功能说明
使用脚本模式开发的详情请参见通过脚本模式配置任务。
Maxgraph中点和边的导入配置不一致,所以Maxgraph Writer需要区分点和边。
- 点配置示例
{ "job": { "setting": { "speed": { "channel": 1 //配置channel为1即可。 }, "errorLimit": { "record": 1000 } }, "content": [ { "reader": { "name": "odpsreader", "parameter": { "accessId": "*****", "accessKey": "*****", "project": "maxgraph_dev", "table": "maxgraph_demo_person", "column": [ //对应MaxCompute表的column名称,与Writer配置项中的column一一对应。 "id", "name", "age" ], "packageAuthorizedProject": "biggraph_dev", "splitMode": "record", "odpsServer": "******" } }, "writer": { "name": "maxgraphwriter", "parameter": { "endpoint": "http://graph.alibaba.net", "graphName": "xxx", "accessId": "xxx", "accessKey": "xxx", "label": "person", "labelType": "vertex", "onlineMode": "partition", "splitSize": "256", "column": [ //对应Maxgraph vertex的属性名,与reader配置项中的column一一对应。 "id", "name", "age" ] } } } ] } }
- 边配置示例
{ "job": { "setting": { "speed": { "channel": 1 //配置channel为1即可。 }, "errorLimit": { "record": 1000 } }, "content": [ { "reader": { "name": "odpsreader", "parameter": { "accessId": "*****", "accessKey": "*****", "project": "maxgraph_dev", "table": "maxgraph_demo_knows", "column": [ "person_id", "person_id2", "weight", "id" ], "packageAuthorizedProject": "biggraph_dev", "splitMode": "record", "odpsServer": "****" } }, "writer": { "name": "maxgraphwriter", "parameter": { "endpoint": "http://graph.alibaba.net", "graphName": "xxx", "accessId": "xxx", "accessKey": "xxx", "label": "knows", "labelType": "edge", "srcLabel": "person", "dstLabel": "person", "onlineMode": "partition", "splitSize": "256", "column": [ { "name": "id", //对应的在graph中的属性名。 "propertyType": "srcPrimaryKey" //对应该属性的类型,主要用来标识是起点、终点还是边的属性。 }, { "name": "id", "propertyType": "dstPrimaryKey" }, { "name": "weight", "propertyType": "edgeProperty" }, { "name": "id", "propertyType": "edgeProperty" } ] } } } ] } }