You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Stephen Mallette (Jira)" <ji...@apache.org> on 2021/11/18 11:39:00 UTC
[jira] [Commented] (TINKERPOP-2627) Use of union() in second by() to group()
[ https://issues.apache.org/jira/browse/TINKERPOP-2627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17445870#comment-17445870 ]
Stephen Mallette commented on TINKERPOP-2627:
---------------------------------------------
This is also an issue with {{coalesce()}}:
{code}
gremlin> g.V().group().by(T.label).by(coalesce(fold(),constant(null)))
==>[software:[v[5]],person:[v[6]]]
{code}
The issue seems to be related to the fact that {{GroupStep}} looks for the first non-local {{Barrier}} in the traversal and if one is found processes it up to that point before doing a final reduction on the remainder of the traversal. Since situations like {{coalesce()}} and {{union()}} have the {{Barrier}} as child traversals the {{Barrier}} is never found and that important bit of code never executes.
The workaround for {{coalesce()}} is similar to {{union()}}:
{code}
gremlin> g.V().group().by(T.label).by(values('age').fold().local(coalesce(unfold(),constant(null)).fold()))
==>[software:[null],person:[29,27,32,35]]
{code}
> Use of union() in second by() to group()
> ----------------------------------------
>
> Key: TINKERPOP-2627
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2627
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.4.12
> Reporter: Stephen Mallette
> Priority: Minor
>
> Using air routes dataset, you get some odd output if you `union(...).fold()` in the second `by()` and if the children to `union()` are reducing steps:
> {code}
> gremlin> g.V().hasLabel('airport').has('country','TZ').
> ......1> group().
> ......2> by('country').
> ......3> by(union(values('elev').min(), values('elev').max()).fold()).
> ......4> unfold()
> ==>TZ=[3745, 3745, 2932, 2932, 3763, 3763, 371, 371, 5600, 5600, 4550, 4550, 182, 182, 54, 54]
> {code}
> I was able to workaround it with:
> {code}
> gremlin> g.V().hasLabel('airport').has('country','TZ').
> ......1> group().
> ......2> by('country').
> ......3> by(values('elev').fold().local(union(min(local),max(local))).fold()).
> ......4> unfold()
> ==>TZ=[54, 5600]
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)