I'm having issues understanding how to handle the stored objects when doing long queries.
Consider the following toy example:
g.addV("foo").property("a", "1").
addV("foo").property("a", "2").
addV("bar").property("a", "1").
addV("bar").property("a", "2")
.iterate()
Now, I want to connect the foo and bar vertices if they share the same value for a, pretty simple:
g.V().hasLabel("foo").as_("foo")
.V().hasLabel("bar").as_("bar")
.where("foo", eq("bar")).by("a")
.addE("is").from_("foo").to("bar")
However, in the case of a long query in which the selection step is not as straightforward, you will likely need to store instead of using `as` (any reducing barrier step would remove them). Then one might think we can simply do this:
g.V().hasLabel("foo").store("foo")
.V().hasLabel("bar").as_("bar")
.where("foo", eq("bar")).by("a")
.addE("is").from_("foo").to("bar")
But it's not the case because store is a bit peculiar. I don't exactly understand it, but it seems like it saves the selection as a folded collection. Then one might try to unfold first, but then chaos occurs. I have tried several alternatives, but can't seem to get it right. For example:
g.V().hasLabel("foo").store("foo")
.V().hasLabel("bar").as_("bar")
.sideEffect(select("foo").unfold().as_("foo"))
.where("foo", eq("bar")).by("a")
.addE("is").from_(select("foo").unfold()).to("bar")
returns
he by("a") modulator can only be applied to a traverser that is an Element or a Map - it is being applied to a BulkSet class instead.
I would highly appreciate any help understanding this!
Best,
Ed