更新时间:2019-11-04 15:59
在完成前述一系列操作,包括SDK引用、Client创建、Schema构建和数据导入以后,即可开始对图数据进行简单的查询或应用具体的图算法。示例如下:
GraphCompute对于图数据的查询只要在client的submit函数中提交相应的查询语句。
ResultSet results = client.submit("g.V()");
for (Result result : results) {
Vertex vertex = result.getVertex();
CompositeId id = (CompositeId) vertex.id();
Iterator<VertexProperty<Object>> propIter = vertex.properties();
System.out.println("vertex id " + id.toString());
while (propIter.hasNext()) {
VertexProperty<Object> prop = propIter.next();
System.out.println("property key=" + prop.key() + " value=" + prop.value());
}
}
目前图算法执行方式与查询类似,只要准备好相应的gremlin语句,即可提交给sumbit函数运行。
String cc = "g.timeoutSec(600).E().hasLabel('cname_to').subgraph('s').cap('s')"
+ " .program(Program.graphCC().output('cid')"
+ " .iteration(30))"
+ " .map(Prop.fill('domain_name', 'cid'))"
+ " .map(Output.writeOdps()"
+ " .endpoint('http://service.odpsstg.aliyun-inc.com/stgnew')"
+ " .accessId(\"${ODPS_KEY}\")"
+ " .accessKey(\"${ODPS_KEY_SECRET}\")"
+ " .project(\"biggraph_dev\").table(\"cc_output_tmp\")"
+ " .write('domain_name', 'cid'))";
client.submit(cc);
在文档使用中是否遇到以下问题
更多建议
匿名提交