Hi all,
I was trying to create vertex if not present.
One of the ways I found online was :
g.V(1000).fold().coalesce(unfold(), constant('x'))
The above works, however, wanted to see if there is a more efficient way to achieve this.
Hence, tried the following query:
g.V(1000).as('a').inject(1).coalesce(select('a'), constant('x'))
The above query works too but only in the negative case! For example the following query prints the results from both traversal in coalesce:
g.V(1).as('a').inject(1).coalesce(select('a'), constant('x'))
output:
Would someone be able to explain why this is happening? And which of the 2 would be more efficient to do?
Yours Gratefully,
Himesh Kakkar