2016-12-24 47 views
0

我有这样的代码基本上更新属性,删除所有旧IsOfType边缘,并增加了新的IsOfType边缘(如果我删除所有的方法/类的抽象,并使其内嵌):为什么AddEdgeStep在使用Gremlin的同一遍历中的边缘DropStep后不起作用?

traversal = g.V("Entity:633471488:519").as("entity"); 

//update properties 
traversal.property("text", "new text"); 
traversal.property("description", "new description"); 

//drop typeEdges 
traversal.select("entity").outE("IsOfType").drop(); 
//even that causes the same issue(!): traversal.select("entity").outE("HasInner").drop(); 
System.out.println("traversal after type edges deletion: " +traversal); 

//make new typeEdges 
traversal.V("Entity:996942848:518").as("type-0").addE("IsOfType").from("entity").to("type-0"); 

System.out.println("traversal after type edges addition: " +traversal); 

//storage 
traversal.select("entity").forEachRemaining({}) 

一切正常(即使是现有的IsOfType边缘)。但是创建新的边缘并不会在图形上产生新的边缘。如果我注释掉,那么创建工作正常(!)就好像在addEdgeStep之前的DropStep正在发生。我甚至试图放弃其他类型的边缘,并导致相同的问题(!)。当drop()next(),iterate()forEachRemaining()一起发生时,可能是隐式事务处理决定提交?如果是这种情况,则使用Fluent API在相同的事务中不会发生丢弃和创建,这使得它在实际应用中不太有用:(

这是删除后在我逃亡二IsOfType边缘(我想Java和Datastax Studio控制台):

traversal after type edges deletion: 
[ 
    GraphStep(vertex,[Entity:633471488:519])@[entity], 
    AddPropertyStep({value=[Entity], key=[atClass]}), 
    AddPropertyStep({value=[FilmWithSuperCategories aaa], key=[text]}), 
    AddPropertyStep({value=[dffsdfsd f2313], key=[description]}), 
    SelectOneStep(entity)@[entity], 
    VertexStep(OUT,[IsOfType],edge), 
    DropStep 
] 

traversal after type edges addition: 
[ 
    GraphStep(vertex,[Entity:633471488:519])@[entity], 
    AddPropertyStep({value=[Entity], key=[atClass]}), 
    AddPropertyStep({value=[FilmWithSuperCategories aaa], key=[text]}), 
    AddPropertyStep({value=[dffsdfsd f2313], key=[description]}), 
    SelectOneStep(entity)@[entity], 
    VertexStep(OUT,[IsOfType],edge), 
    DropStep, 
    GraphStep(vertex,[Entity:996942848:518])@[type-0], 
    AddEdgeStep({~from=[[SelectOneStep(entity)]], ~to=[[SelectOneStep(type-0)]], label=[IsOfType]}), 
    GraphStep(vertex,[Entity:1489781376:516])@[type-1], 
    AddEdgeStep({~from=[[SelectOneStep(entity)]], ~to=[[SelectOneStep(type-1)]], label=[IsOfType]}) 
] 

编辑

从我读到这里(http://tinkerpop.apache.org/docs/current/reference/#drop-step

drop() - step(filter/sideEffect)用于从图中移除元素和属性(即,去掉)。这是一个过滤步骤,因为遍历不会产生传出对象。

有没有对象被返回,所以发生掉落后不可能做任何事情!所以我很好奇如何使用DSE Graph Fluent API在一次交易中完成多次滴加/添加操作。

谢谢!

回答

1

你可以用你的dropsideEffect步骤,例如:

g.V(entity1).as("a").sideEffect(outE().filter(inV().is(entity2)).drop()). 
    V(entity2).addE("link").from("a") 
+0

哇你真棒!为什么我找不到有关我的用例的任何文档:(我猜这是因为gremlin api刚刚被标准化 –

相关问题