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/02/09 17:01:00 UTC
[jira] [Commented] (TINKERPOP-2520) Add the ability to reverse the
stream or a collection
[ https://issues.apache.org/jira/browse/TINKERPOP-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17281883#comment-17281883 ]
Stephen Mallette commented on TINKERPOP-2520:
---------------------------------------------
Been thinking about this one a bit. I think we should simply disallow things like:
{code}
g.V().order().by('name').by(reverse)
g.V().order().by(reverse).by('name')
g.V().order().by(reverse).by(shuffle)
{code}
You can simply:
{code}
g.V().order().by(reverse)
{code}
We have similar rules around {{shuffle}} already but they don't explicitly result in error - the {{shuffle}} steps in between comparators are just removed and the mode of the order only goes to {{shuffle}} if that is the last {{Comparator}}.
This would not prevent:
{code}
// g.V().order().by('name',desc)
g.V().
order().by('name').
order().by(reverse)
{code}
I think that rather that doing magic with {{shuffle}} (and trying to do the same with {{reverse}}) perhaps we just require Gremlin to be formed where multiple {{Comparator}} instances can't be present where {{shuffle}} and {{reverse}} are in play.
> Add the ability to reverse the stream or a collection
> -----------------------------------------------------
>
> Key: TINKERPOP-2520
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2520
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.4.10
> Reporter: Kelvin R. Lawrence
> Priority: Minor
>
> I had a Gremlin user ask me yesterday if there was a way to have the results of a `path` step be reversed. Today you cannot do that using `from` and `to` steps as the `from` label must appear before the `to` label in a path. In thinking about this, perhaps adding a `reverse` option to order (on top of `asc`,`desc` and `shuffle`) would be a nice addition to Gremlin. So you could write something like:
> {code:java}
> g.V().out().out().path().order(local).by(reverse){code}
> For this specific user they were union-ing a set of paths in different directions and wanted to normalize them to all be in the same direction when presented as results.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)