2013-01-23 82 views
4

我使用Gremlin來遍歷OrientDB,但我不太明白這裏的演示代碼OrientDB Gremlin Wiki
這是我的代碼,這段代碼有什麼問題?使用Gremlin與Java API的OrientDB

  // create sample node and edge 
     graph = new OrientGraph("local:C:/temp/graph/db"); 
     Vertex v1 = graph.addVertex(null); 
     v1.setProperty("name", "A"); 
     Vertex v2 = graph.addVertex(null); 
     v2.setProperty("name", "B"); 
     Vertex v3 = graph.addVertex(null); 
     v3.setProperty("name", "C"); 
     graph.addEdge(null, v1, v2, "KNOWS"); 
     graph.addEdge(null, v1, v3, "KNOWS"); 

     OGremlinHelper.global().create(); 
     OCommandGremlin command = new OCommandGremlin("g.v('#8:0').out('KNOWS').aggregate(x).has('name',name)"); 
     Map<String, Object> params = new HashMap<String, Object>(); 
     List agg = new ArrayList(); 
     params.put("x", agg); 
     params.put("name", "B");    
     Vertex vertex = graph.getRawGraph().command(command).execute(params); 
     System.out.println(vertex); 
     System.out.println(agg); 

我可以得到腳本的最終結果,但爲什麼我不能得到「聚合」結果?我怎麼才能得到它?

我真的很陌生。提前致謝!

回答