[ 
https://issues.apache.org/jira/browse/TINKERPOP3-781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14652164#comment-14652164
 ] 

Matt Frantz commented on TINKERPOP3-781:
----------------------------------------

The path history should include the common portion of the path, i.e. the part 
leading up to the {{local}} step.  That is how {{map(Traversal)}} works, for 
example.  Even though {{map}}'s argument is a traversal containing a 
{{ReducingBarrierStep}}, it preserves the path prefix.

Aggregating the paths for the reduced portion of the traversal is another issue 
to consider.  How would you express that this additional computation was 
desired?  Here's a case where you do NOT need the path:
{noformat}
g.V(1).as('a').local(out().as('b').count()).as('c')
  .select('a','c')
==>[a:v[1], c:3]
{noformat}

What if you asked for the "b" vertex, too?  You would expect the same 
cardinality result.  That means "b" should be reduced with a default function, 
e.g. make a list.
{noformat}
g.V(1).as('a').local(out().as('b').count()).as('c')
  .select('a','b','c')
==>[a:v[1], b:[v[3],v[2],v[4]], c:3]
{noformat}

You could use {{by}} to modulate the value that is reduced.
{noformat}
g.V(1).as('a').local(out().as('b').count()).as('c')
  .select('a','b','c')
  .by('name').by('name').by()
==>[a:'marko', b:['lop','vadas','josh'], c:3]
{noformat}

Perhaps a second {{by}} argument could provide the reducing function?  
Complicated.
{noformat}
g.V(1).as('a').local(out().as('b').count()).as('c')
  .select('a','b','c')
  .by('name').by('name', { acc, it -> acc += it.get().length() }).by()
==>[a:'marko', b:12, c:3]
{noformat}

Does this all become sugar for {{group}} of {{path}}?
{noformat}
g.V(1).as('a').out().as('b').path()
  .group()
  .by()
  .by('name')
  .by(/* Path reducing logic goes here */))
{noformat}


> Local aggregation should not destroy path
> -----------------------------------------
>
>                 Key: TINKERPOP3-781
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-781
>             Project: TinkerPop 3
>          Issue Type: Improvement
>          Components: process
>            Reporter: Matt Frantz
>
> Currently, if we do an aggregating step (e.g. {{fold}}, {{groupCount}}, etc.) 
> within the {{local}} step, we lose the path information.
> {noformat}
> gremlin> g.V(1).local(both().fold()).path()
> ==>[[v[3], v[2], v[4]]]
> {noformat}
> It would be better if the preceding portion of the path were still retained 
> like so:
> {noformat}
> gremlin> g.V(1).local(both().fold()).path()
> ==>[v[1], [v[3], v[2], v[4]]]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to