[ https://issues.apache.org/jira/browse/TINKERPOP-2315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17058234#comment-17058234 ]
Cyril Scetbon commented on TINKERPOP-2315: ------------------------------------------ [~spmallette], there is something wrong cause I can't use it to refactor code. The original traversal is updated when I touch the cloned object : {noformat} In [12]: t0 = g.V().hasLabel('OID') In [13]: t0 Out[13]: [['V'], ['hasLabel', 'OID'], ['values', '_ipython_canary_method_should_not_exist_']] In [14]: t1 = t0.clone() In [15]: t1 Out[15]: [['V'], ['hasLabel', 'OID'], ['values', '_ipython_canary_method_should_not_exist_'], ['values', '_ipython_canary_method_should_not_exist_']] In [16]: t1 = t1.has('u1', 'v1') In [17]: t1 Out[17]: [['V'], ['hasLabel', 'OID'], ['values', '_ipython_canary_method_should_not_exist_'], ['values', '_ipython_canary_method_should_not_exist_'], ['has', 'u1', 'v1'], ['values', '_ipython_canary_method_should_not_exist_']] In [18]: t0 Out[18]: [['V'], ['hasLabel', 'OID'], ['values', '_ipython_canary_method_should_not_exist_'], ['values', '_ipython_canary_method_should_not_exist_'], ['has', 'u1', 'v1'], ['values', '_ipython_canary_method_should_not_exist_'], ['values', '_ipython_canary_method_should_not_exist_']] {noformat} Why is t0 updated too ? I'm trying to use clone() to use the same traversal but then do different lookups after that. Here is another example : {noformat} In [50]: graph_traversal = g.V().hasLabel('OID') In [51]: graph_traversal.clone().limit(10).count().next() Out[51]: 1 In [52]: graph_traversal.clone().limit(10).count().next() Out[52]: 1 In [53]: graph_traversal.clone().limit(10).count().next() Out[53]: 1 In [54]: graph_traversal.clone().limit(10).count() Out[54]: [['V'], ['hasLabel', 'OID'], ['limit', 10], ['count'], ['limit', 10], ['count'], ['limit', 10], ['count'], ['limit', 10], ['count'], ['values', '_ipython_canary_method_should_not_exist_']] {noformat} You see that if the traversal is cloned 4 times it has all 4 calls on it and does not do what we think it does ... > Implement some form of clone() or reset() for Traversal in GLVs > --------------------------------------------------------------- > > Key: TINKERPOP-2315 > URL: https://issues.apache.org/jira/browse/TINKERPOP-2315 > Project: TinkerPop > Issue Type: Improvement > Components: dotnet, javascript, python > Affects Versions: 3.3.9 > Reporter: Stephen Mallette > Assignee: Stephen Mallette > Priority: Major > Fix For: 3.5.0, 3.4.5, 3.3.10 > > > There doesn't seem to be a method to do what we do in Java fairly often: > {code} > attached = g.V().hasLabel('OID').out('attached') > assert attached.clone().count().next() == 4 > uids = attached.clone().dedup().toList() > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)