Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Not A Bug
-
3.6.0, 3.6.2
-
None
-
None
Description
While looking into a question on Stack Overflow about selectively adding a vertex based on a set of values in a list, I think I may have run into an odd issue. Note that this can also be solved using mergeV, but that notwithstanding, the behavior below seems odd. It can be reproduced just using TinkerGraph and the Gremlin Console. Everything works as expected until the RHS of the coalesce() step is an addV() step.
gremlin> g.addV('Person').property('name','Sam') ==>v[16]gremlin> g ==>graphtraversalsource[tinkergraph[vertices:1 edges:0], standard]gremlin> g.inject(['Sam','Peter','Frank']). ......1> unfold().as('find'). ......2> V().as('p'). ......3> coalesce( ......4> where(eq('p')). ......5> by(select('find')). ......6> by('name'),constant(1)) ==>v[16] ==>1 ==>1gremlin> g.inject(['Sam','Peter','Frank']). ......1> unfold().as('find'). ......2> V().as('p'). ......3> coalesce( ......4> where(eq('p')). ......5> by(select('find')). ......6> by('name'),select('find')) ==>v[16] ==>Peter ==>Frankgremlin> g.inject(['Sam','Peter','Frank']). ......1> unfold().as('find'). ......2> V().as('p'). ......3> coalesce( ......4> where(eq('p')). ......5> by(select('find')). ......6> by('name'),addV('Person').property('name',select('find')) ......7> ) ==>v[16] ==>v[18] ==>v[20] ==>v[22]gremlin> g.V().valueMap(true) ==>[id:16,label:Person,name:[Sam]] ==>[id:18,label:Person,name:[Peter]] ==>[id:20,label:Person,name:[Frank]] ==>[id:22,label:Person,name:[Frank]] gremlin> g.V().drop()gremlin> g.addV('Person').property('name','Sam') ==>v[24]gremlin> g.inject(['Sam','Peter','Frank']). ......1> unfold().as('find'). ......2> V().as('p'). ......3> coalesce( ......4> where(eq('p')). ......5> by(select('find')). ......6> by('name'), ......7> addV('Person').property('name',select('find'))).profile() ==>Traversal Metrics Step Count Traversers Time (ms) % Dur ============================================================================================================= InjectStep([[Sam, Peter, Frank]]) 1 1 0.043 4.19 UnfoldStep@[find] 3 3 0.083 8.00 TinkerGraphStep(vertex,[])@[p] 4 4 0.155 14.91 CoalesceStep([[WherePredicateStep(null,eq(p),[[... 4 4 0.761 72.89 WherePredicateStep(null,eq(p),[[SelectOneStep... 1 1 0.181 SelectOneStep(last,find,null) 4 4 0.057 AddVertexStep({name=[[SelectOneStep(last,find... 3 3 0.246 SelectOneStep(last,find,null) 3 3 0.025 >TOTAL - - 1.044 - gremlin> g.inject(['Sam','Peter','Frank']). ......1> unfold().as('find').V().profile() ==>Traversal Metrics Step Count Traversers Time (ms) % Dur ============================================================================================================= InjectStep([[Sam, Peter, Frank]]) 1 1 0.028 8.93 UnfoldStep@[find] 3 3 0.043 13.97 TinkerGraphStep(vertex,[]) 3 3 0.241 77.10 >TOTAL - - 0.313 -