請講一個簡單的解決方案,將作爲我有幾百萬個節點較少的時間:在DSE-5.0.5一氣呵成添加多發的頂點和多發邊緣通過Java驅動程序
for(int i=1100000; i<=1200000;i++){
GraphStatement q1 = new SimpleGraphStatement("g.addV(label, 'Asset','name','Asset"+i+"','type','"+1+"').as('a')").setGraphName("lookingglass");
System.out.println("Added node----"+i);
}
for(int i=1100000;i<=1200000;i++){
//int j=i+1;
Vertex v1 = dseSession.executeGraph("g.V().has('name','Org"+1000+"')").one().asVertex();
Vertex v2 = dseSession.executeGraph("g.V().has('name','Asset"+i+"')").one().asVertex();
SimpleGraphStatement s = new SimpleGraphStatement(
"def v1 = g.V(id1).next()\n" +
"def v2 = g.V(id2).next()\n" +
"v1.addEdge('HAS', v2)")
.set("id1", v1)
.set("id2", v2);
dseSession.executeGraph(s);
System.out.println("Added Edge "+i);
}
System.out.println("Done");
正如我在做一個整體圖搜索這需要更長的時間。 我們可以有一個簡單的單個查詢,可以添加一個vartex,並將一個邊添加到涉及較少延遲的現有頂點?
注意我曾嘗試用以下方法也不過下面的方法depricated看來,從而使錯誤(頂點不支持用戶提供的標識符:您指定爲「過時」
g.addV().property(id, "A").as("a").
addV().property(id, "B").property("value", 100).as("b").
addV().property(id, "C").property("value", 200).as("c").
addV().property(id, "D").property("value", 500).as("d").
addV().property(id, "E").property("value", 1000).as("e").
addV().property(id, "Z").property("value", 900).as("z").
addE("link").from("a").to("b").property("weight", 80).
addE("link").from("a").to("c").property("weight", 20).
addE("link").from("b").to("d").property("weight", 50).
addE("link").from("b").to("e").property("weight", 40).
addE("link").from("z").to("d").property("weight", 10).iterate()