阅读443 返回首页    go 阿里云


编写Graph__快速开始_大数据计算服务-阿里云

Graph作业的提交方式与 MapReduce基本相同。下面,以SSSP算法为例,说明如何提交Graph作业。使用Maven的用户可以从Maven库中搜索”odps-sdk-graph”获取不同版本的Java SDK,相关配置信息:

  1. <dependency>
  2. <groupId>com.aliyun.odps</groupId>
  3. <artifactId>odps-sdk-graph</artifactId>
  4. <version>0.20.7</version>
  5. </dependency>

下面将以运行示例程序单源最短距离(Single Source Shortest Path,简写:SSSP)为例, 帮助您快速掌握如何运行Graph作业。

1 进入console并运行odpscmd。

2 创建输入输出表。

  1. create table sssp_in (v bigint, es string);
  2. create table sssp_out (v bigint, l bigint);

备注:创建Table语句请参考 SQL Create描述

3 上传数据

本地数据内容如下:

  1. 1 2:2,3:1,4:4
  2. 2 1:2,3:2,4:1
  3. 3 1:1,2:2,5:1
  4. 4 1:4,2:1,5:1
  5. 5 3:1,4:1

以空格键做两列的分隔符,执行tunnel命令上传数据:

  1. tunnel u -fd " " sssp.txt sssp_in;

4 编写sssp示例:

根据 Graph开发插件 的介绍,本地编译、调试SSSP算法示例。本示例中假定代码被打包为odps-graph-example-sssp.jar。

备注:请注意,仅需要将SSSP代码打包即可,不需要同时将SDK打入”odps-graph-example-sssp.jar”中。

5 添加jar资源:

  1. add jar $LOCAL_JAR_PATH/odps-graph-example-sssp.jar

备注:创建资源介绍请参考 资源操作

6 运行sssp:

  1. jar -libjars odps-graph-example-sssp.jar -classpath $LOCAL_JAR_PATH/odps-graph-example-sssp.jar com.aliyun.odps.graph.examples.SSSP 1 sssp_in sssp_out;

jar命令用于运行 MaxCompute GRAPH 作业,用法与 MapReduce 作业的运行命令完全一致。

GRAPH作业执行时命令行会打印作业实例ID,执行进度,结果Summary等。

7 输出示例如下:

  1. ID = 20130730160742915gl205u3
  2. 2013-07-31 00:18:36 SUCCESS
  3. Summary:
  4. Graph Input/Output
  5. Total input bytes=211
  6. Total input records=5
  7. Total output bytes=161
  8. Total output records=5
  9. graph_input_[bsp.sssp_in]_bytes=211
  10. graph_input_[bsp.sssp_in]_records=5
  11. graph_output_[bsp.sssp_out]_bytes=161
  12. graph_output_[bsp.sssp_out]_records=5
  13. Graph Statistics
  14. Total edges=14
  15. Total halted vertices=5
  16. Total sent messages=28
  17. Total supersteps=4
  18. Total vertices=5
  19. Total workers=1
  20. Graph Timers
  21. Average superstep time (milliseconds)=7
  22. Load time (milliseconds)=8
  23. Max superstep time (milliseconds) =14
  24. Max time superstep=0
  25. Min superstep time (milliseconds)=5
  26. Min time superstep=2
  27. Setup time (milliseconds)=277
  28. Shutdown time (milliseconds)=20
  29. Total superstep time (milliseconds)=30
  30. Total time (milliseconds)=344
  31. OK

注意:如果用户需要使用Graph功能,需要在工单系统上提交申请,提供项目空间名称,简单描述使用场景。只有申请通过,开通好权限后才可以使用。

最后更新:2016-05-18 17:56:39

  上一篇:go 编写MapReduce__快速开始_大数据计算服务-阿里云
  下一篇:go 处理非结构化数据__快速开始_大数据计算服务-阿里云