[
https://issues.apache.org/jira/browse/TINKERPOP-2220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16842317#comment-16842317
]
Daniel Kuppitz edited comment on TINKERPOP-2220 at 5/17/19 5:10 PM:
--------------------------------------------------------------------
The meaning of {{dedup()}} inside {{repeat()}} is a little different. Just like
{{simplePath}} ensures that no element appears twice on the current path,
{{repeat(dedup())}} ensures that no element is visited twice within the
repetition.
{code}
gremlin> g.V(1).repeat(both().simplePath()).emit().path()
==>[v[1],v[3]]
==>[v[1],v[2]]
==>[v[1],v[4]]
==>[v[1],v[3],v[4]]
==>[v[1],v[3],v[6]]
==>[v[1],v[4],v[5]]
==>[v[1],v[4],v[3]]
==>[v[1],v[3],v[4],v[5]]
==>[v[1],v[4],v[3],v[6]]
{code}
Note, how the two longest paths visit {{v[5]}} and {{v[6]}} in the end
(although these 2 vertices were already seen in shorter paths. Now watch this:
{code}
gremlin> g.V(1).repeat(both().simplePath().dedup()).emit().path()
==>[v[1],v[3]]
==>[v[1],v[2]]
==>[v[1],v[4]]
==>[v[1],v[3],v[6]]
==>[v[1],v[4],v[5]]
{code}
{{dedup()}} inside {{repeat()}} makes sure that this doesn't happen. In other
cases, you don't really need to worry about deduplication; if two traversers
hit the same element, they will merge. Thus, from a performance and memory
perspective, it makes no difference if an element appears once or a thousand
times within {{repeat()}}.
was (Author: dkuppitz):
The meaning of {{dedup()}} inside {{repeat()}} is a little different. Just like
{{simplePath}} ensures that no element appears twice on the current path,
{{repeat(dedup())}} ensures that no element is visited twice within the
repetition.
> Dedup inside Repeat Produces 0 results
> --------------------------------------
>
> Key: TINKERPOP-2220
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2220
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.3.0
> Reporter: Rahul Chander
> Priority: Major
>
> Testing against the Tinkerpop Modern graph dataset, I ran this query:
> {code:java}
> g.V().repeat(__.dedup()).times(2).count()
> {code}
> which should essentially be the same as running dedup twice. It produced 0
> results, while dedup twice produced the correct 6.
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)