[
https://issues.apache.org/jira/browse/TINKERPOP-1367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15372072#comment-15372072
]
Marko A. Rodriguez commented on TINKERPOP-1367:
-----------------------------------------------
I was thinking more on this during my evening walk and thought -- if there are
"ties" in {{max()}} and {{min()}}, which path survives?
Then I was thinking that this can be done with a {{FoldStep}} which is a
{{ReducingBarrierStep}}.
{code}
gremlin> g.V().outE().values('weight').path().fold(0){ a,b -> a == 0 ? b :
a.get(2) > b.get(2) ? a : b}
==>[v[4], e[10][4-created->5], 1.0]
{code}
Of course, {{fold(0)}} sucks and we don't really need that assuming that the
first result is simply the first traverser through. Thus, we could do something
like this:
{code}
gremlin> g.V().outE().values('weight').path().fold{ a,b -> a.get(2) > b.get(2)
? a : b}
==>[v[4], e[10][4-created->5], 1.0]
{code}
For min():
{code}
gremlin> g.V().outE().values('weight').path().fold{ a,b -> a.get(2) < b.get(2)
? a : b}
==>[v[6], e[12][6-created->3], 0.2]
{code}
Sorta ghetto as it maintains a lambda, but it serves the same purpose and
doesn't introduce to the Gremlin language the notion of a tie breaker.
> Preserve path history for min() and max()
> -----------------------------------------
>
> Key: TINKERPOP-1367
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1367
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.2.0-incubating
> Reporter: Jason Plurad
>
> Via https://groups.google.com/d/msg/gremlin-users/qZwsvRjw7L4/YyT-s1foBAAJ
> {noformat}
> gremlin> g.V().outE().as('e').values('weight').path()
> ==>[v[1], e[9][1-created->3], 0.4]
> ==>[v[1], e[7][1-knows->2], 0.5]
> ==>[v[1], e[8][1-knows->4], 1.0]
> ==>[v[4], e[10][4-created->5], 1.0]
> ==>[v[4], e[11][4-created->3], 0.4]
> ==>[v[6], e[12][6-created->3], 0.2]
> gremlin> g.V().outE().as('e').values('weight').max().path()
> ==>[1.0]
> {noformat}
> Currently all reducing barriers are treated the same (min, max, mean, etc.).
> But they are indeed different when it comes to path computations. Some of
> them could preserve the path history, others could not.
> For max() and min(), we could preserve the path history. In fact, in this
> respect, max() and min() would NOT be ReducingBarrierSteps, but in fact be
> some sort of "barrier" FilterStep.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)