I've been trying to think of the guiding principle for what a "local" version of a step should do. For the range family (range, limit, and tail) and perhaps others (order), the "Scope.local" parameter applied to a List acts as shorthand for local(unfold.foo.fold). The proposal for by(local, foo) to be approximately equal to by(unfold.foo.fold) is in that spirit.
For Map input, we don't enjoy the symmetry of unfold/fold. Instead of a Map, you end up with a List of Map$Entry. So close! But it is still a good way to think about what is happening with some of the local versions of steps. For select(local), we don't have the same symmetry with select(global). In other words, select(local) is not even close to local(unfold.select.fold). In part, this is because of the problems with unfold/fold on Map. But it is also due to the duality of the "key" concept. The dual of the Map key namespace is the path+sideEffect key namespace. Thus, to be able to rewrite a Scope.local step on Map keys into a traversal involving a Scope.global step requires a step that transforms a Map into a Path. Call it "deselect", since "select" is the step that takes a Path and makes a Map. The goal would be to define foo(local) on a Map as local(deselect.foo.select). Thoughts? In short, no guiding principle, yet each of the uses of Scope.local feels about right. On Thu, Jun 4, 2015 at 2:51 PM, Marko Rodriguez <[email protected]> wrote: > Hi, > > Check out this test that Matt Frantz added today: > > g.V.as('a').out.as('a').out.as > ('a').select('a').by(unfold.name.fold) > > Lets break this bad boy down: > > gremlin> g.V().as('a').out().as('a').out().as('a').select('a') > ==>[v[1], v[4], v[5]] > ==>[v[1], v[4], v[3]] > gremlin> > g.V().as('a').out().as('a').out().as('a').select('a').by(unfold().values('name').fold()) > ==>[marko, josh, ripple] > ==>[marko, josh, lop] > > You can say, "why use select()? -- use path()." > > gremlin> g.V().as('a').out().as('a').out().as('a').path() > ==>[v[1], v[4], v[5]] > ==>[v[1], v[4], v[3]] > gremlin> g.V().as('a').out().as('a').out().as('a').path().by('name') > ==>[marko, josh, ripple] > ==>[marko, josh, lop] > > True, but two things -- you don't always want the full path (select() is > like "subpath") and second, you may have lists in your select() at other > times (not just path elements, e.g. select(local)). > > gremlin> > g.V().as('a').out().as('a').out().as('a').path().by('name').next().getClass() > ==>class > org.apache.tinkerpop.gremlin.process.traversal.step.util.MutablePath > gremlin> > g.V().as('a').out().as('a').out().as('a').select('a').by(unfold().values('name').fold()).next().getClass() > ==>class java.util.ArrayList > > So…. lets stick with thinking about select(). I don't like > by(unfold.name.fold). That is brutal looking. How do we make it not so > sucky? > > by(local,'name') ? > > ………local is starting to get deep (permeating numerous steps)…. outE(local) > eek!…. Where are we going? > > Thanks, > Marko. > > http://markorodriguez.com > >
