I'm trying to add a Subscription
vertex ([Org-Sends->Subscription<-Receives-User]) for each [Org-Manages->User] where one is not already present. I wrote this traversal, which appears to select the values I'm interested in:
g.V().hasLabel('Org')
.match(
__.as('oV').out('Manages').as('uV'),
not(__.as('oV').out('Sends').in('Receives').as('uV')
)
I get a set of tuples oV,uV
with the relevant vertex pairs. So far, so good.
I then appended this:
.sideEffect(
addV('Subscription').as('newV')
.select('oV').addE('Sends').to(select('newV'))
.select('uV').addE('Receives').to(select('newV'))
)
I expected, for each of the pairs oV,uV
, to get the relevant structure set up. Instead, all of the Subscription vertices are created, and all of the Receives edges are created, but only one Sends edge per Org is created.
As far as I can tell, the "input" to sideEffect
is a set of "rows" with lots of duplicated Org vertices. I also tried inserting select('oV', 'uV')
before the sideEffect
with no change in behavior. Why is the addE
, but only the addE
, short-circuiting after seeing a particular oV
?
I am executing this against Amazon Neptune, and I ran explain
in the console. This was the explanation I got, which appears to match my written traversal:
Final Traversal[
NeptuneGraphQueryStep(Vertex),
NeptuneTraverserConverterStep,
MatchStep(
AND,[
[MatchStartStep(oV), VertexStep(OUT,[Manages],vertex), MatchEndStep(uV)],
[MatchStartStep(oV), WhereTraversalStep([NotStep([WhereStartStep, VertexStep(OUT,[Sends],vertex), VertexStep(IN,[Receives],vertex), WhereEndStep(uV)])]), MatchEndStep, MatchEndStep]
]
),
TraversalSideEffectStep([
AddVertexStep({$migration=[asdf], label=[Subscription]})@[newV],
SelectOneStep(last,oV),
NoOpBarrierStep(2500),
AddEdgeStep({~to=[[SelectOneStep(last,newV)]], label=[Sends]}),
SelectOneStep(last,uV),
NoOpBarrierStep(2500),
AddEdgeStep({~to=[[SelectOneStep(last,newV)]], label=[Receives]})
])
]