[ 
https://issues.apache.org/jira/browse/TINKERPOP-2886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17694444#comment-17694444
 ] 

Yuancheng commented on TINKERPOP-2886:
--------------------------------------

Dataset:
{code:java}
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import 
DriverRemoteConnection
from gremlin_python.process.traversal import T
from gremlin_python.process.traversal import Cardinality


class GremlinSchemaInit:
    id = T.id
    single = Cardinality.single
    graph = Graph()
    g = 
graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
    
    def init_dataset(self):
        self.g.V().drop().iterate()
        n1 = self.g.addV('A').property('id', 1).property('p', "node01").next()
        n2 = self.g.addV('A').property('id', 2).property('p', 'node02').next()
        n3 = self.g.addV('A').property('id', 3).property('p', 'node03').next()
        n4 = self.g.addV('A').property('id', 4).property('p', 'node04').next()
        n5 = self.g.addV('A').property('id', 5).property('p', 'node05').next()
        n6 = self.g.addV('B').property('id', 6).property('p', 'node06').next()
        n7 = self.g.addV('B').property('id', 7).property('p', 'node07').next()
        n8 = self.g.addV('B').property('id', 8).property('p', 'node08').next()
        n9 = self.g.addV('B').property('id', 9).property('p', 'node09').next()
        n10 = self.g.addV('B').property('id', 10).property('p', 'node10').next()
        self.g.addE('X').property('id', 11).from_(n1).to(n2).iterate()
        self.g.addE('X').property('id', 12).from_(n2).to(n3).iterate()
        self.g.addE('X').property('id', 13).from_(n3).to(n4).iterate()
        self.g.addE('X').property('id', 14).from_(n4).to(n5).iterate()
        self.g.addE('X').property('id', 15).from_(n5).to(n6).iterate()
        self.g.addE('X').property('id', 16).from_(n6).to(n7).iterate()
        self.g.addE('X').property('id', 17).from_(n7).to(n8).iterate()
        self.g.addE('X').property('id', 18).from_(n8).to(n9).iterate()
        self.g.addE('X').property('id', 19).from_(n9).to(n10).iterate()
        self.g.addE('X').property('id', 20).from_(n10).to(n1).iterate()
        self.g.addE('Y').property('id', 21).from_(n2).to(n1).iterate()
        self.g.addE('Y').property('id', 22).from_(n3).to(n2).iterate()
        self.g.addE('Y').property('id', 23).from_(n4).to(n3).iterate()
        self.g.addE('Y').property('id', 24).from_(n5).to(n4).iterate()
        self.g.addE('Y').property('id', 25).from_(n6).to(n5).iterate()
        self.g.addE('Y').property('id', 26).from_(n7).to(n6).iterate()
        self.g.addE('Y').property('id', 27).from_(n8).to(n7).iterate()
        self.g.addE('Y').property('id', 28).from_(n9).to(n8).iterate()
        self.g.addE('Y').property('id', 29).from_(n10).to(n9).iterate()
        self.g.addE('Y').property('id', 30).from_(n1).to(n10).iterate()
        self.g.addE('X').property('id', 31).from_(n3).to(n9).iterate()
        self.g.addE('Y').property('id', 32).from_(n6).to(n3).iterate()
        self.g.addE('Y').property('id', 33).from_(n1).to(n8).iterate()
        self.g.addE('X').property('id', 34).from_(n2).to(n8).iterate()
        self.g.addE('Y').property('id', 35).from_(n5).to(n8).iterate()
        self.g.addE('X').property('id', 36).from_(n7).to(n3).iterate()
        self.g.addE('Y').property('id', 37).from_(n9).to(n2).iterate()
        self.g.addE('Y').property('id', 38).from_(n9).to(n6).iterate()
        self.g.addE('X').property('id', 39).from_(n1).to(n6).iterate()
        self.g.addE('Y').property('id', 40).from_(n2).to(n1).iterate()
        self.g.addE('X').property('id', 41).from_(n1).to(n5).iterate()
        self.g.addE('X').property('id', 42).from_(n2).to(n1).iterate()
        self.g.addE('X').property('id', 43).from_(n3).to(n5).iterate()
        self.g.addE('X').property('id', 44).from_(n4).to(n7).iterate()
        self.g.addE('X').property('id', 45).from_(n5).to(n6).iterate()
        self.g.addE('X').property('id', 46).from_(n6).to(n5).iterate()
        self.g.addE('X').property('id', 47).from_(n7).to(n6).iterate()
        self.g.addE('X').property('id', 48).from_(n8).to(n2).iterate()
        self.g.addE('X').property('id', 49).from_(n9).to(n7).iterate()
        self.g.addE('X').property('id', 50).from_(n10).to(n3).iterate()
        self.g.addE('Y').property('id', 51).from_(n2).to(n1).iterate()
        self.g.addE('Y').property('id', 52).from_(n8).to(n2).iterate()
        self.g.addE('Y').property('id', 53).from_(n9).to(n3).iterate()
        self.g.addE('Y').property('id', 54).from_(n9).to(n4).iterate()
        self.g.addE('Y').property('id', 55).from_(n2).to(n5).iterate()
        self.g.addE('Y').property('id', 56).from_(n7).to(n6).iterate()
        self.g.addE('Y').property('id', 57).from_(n6).to(n7).iterate()
        self.g.addE('Y').property('id', 58).from_(n3).to(n8).iterate()
        self.g.addE('Y').property('id', 59).from_(n1).to(n9).iterate()
        self.g.addE('Y').property('id', 60).from_(n7).to(n10).iterate()


test = GremlinSchemaInit()
test.init_dataset() {code}

> Inconsistent results when executing equivalent queries
> ------------------------------------------------------
>
>                 Key: TINKERPOP-2886
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2886
>             Project: TinkerPop
>          Issue Type: Bug
>    Affects Versions: 3.6.2
>            Reporter: Yuancheng
>            Priority: Major
>
>  
> {code:java}
> g.V().as('s1').hasLabel('A').emit(__.loops().is(gte(1))).repeat(__.bothE().dedup().by(__.path()).otherV()).times(2).simplePath().from('s1').as('s2').hasLabel('B').emit(__.loops().is(gte(1))).repeat(__.inE().outV()).times(2).hasLabel('B').bothE().dedup().by(__.path()).otherV().hasLabel('A').select('s1').count()
> // Result: 19100{code}
>  
> {code:java}
> g.V().as('s1').hasLabel('A').emit(__.loops().is(gte(1))).repeat(__.bothE().dedup().by(__.path()).otherV()).times(2).simplePath().from('s1').hasLabel('B').emit(__.loops().is(gte(1))).repeat(__.inE().outV()).times(2).hasLabel('B').bothE().dedup().by(__.path()).otherV().hasLabel('A').select('s1').count()
>  
> // Result: 18198{code}
> The only difference is `as('s2')`. I would not expect it to change the 
> result. However, they output differently. 
> Profiles:
> {code:java}
> {'dur': 113.635007, 'metrics': [{'dur': 0.099535, 'counts': 
> {'traverserCount': 5, 'elementCount': 5}, 'name': 
> 'TinkerGraphStep(vertex,[~label.eq(A)])@[s1]', 'annotations': {'percentDur': 
> 0.08759184570649078}, 'id': '15.0.0()'}, {'dur': 1.518938, 'counts': 
> {'traverserCount': 568, 'elementCount': 568}, 'name': 
> 'RepeatStep(emit([LoopsStep, IsStep(gte(1))]),[VertexStep(BOTH,edge), 
> DedupGlobalStep(null,[PathStep]), EdgeOtherVertexStep, 
> RepeatEndStep],until(loops(2)))', 'annotations': {'percentDur': 
> 1.3366813978371999}, 'id': '2.0.0()', 'metrics': [{'dur': 0.012455, 'counts': 
> {'traverserCount': 55, 'elementCount': 55}, 'name': 'LoopsStep', 'id': 
> '0.1.2(2.0.0())'}, {'dur': 0.02038, 'counts': {}, 'name': 'IsStep(gte(1))', 
> 'id': '2.1.2(2.0.0())'}, {'dur': 0.175709, 'counts': {'traverserCount': 568, 
> 'elementCount': 568}, 'name': 'VertexStep(BOTH,edge)', 'id': 
> '0.1.0(2.0.0())'}, {'dur': 0.631128, 'counts': {'traverserCount': 568, 
> 'elementCount': 568}, 'name': 'DedupGlobalStep(null,[PathStep])', 'id': 
> '2.1.0(2.0.0())', 'metrics': [{'dur': 0.08288, 'counts': {'traverserCount': 
> 568, 'elementCount': 568}, 'name': 'PathStep', 'id': 
> '0.2.0(2.1.0(2.0.0()))'}]}, {'dur': 0.22524, 'counts': {'traverserCount': 
> 568, 'elementCount': 568}, 'name': 'EdgeOtherVertexStep', 'id': 
> '4.1.0(2.0.0())'}, {'dur': 0.265068, 'counts': {'traverserCount': 518, 
> 'elementCount': 518}, 'name': 'RepeatEndStep', 'id': '6.1.0(2.0.0())'}]}, 
> {'dur': 1.200035, 'counts': {'traverserCount': 444, 'elementCount': 444}, 
> 'name': 'PathFilterStep(simple,s1,null)', 'annotations': {'percentDur': 
> 1.0560434074686158}, 'id': '3.0.0()'}, {'dur': 0.214619, 'counts': 
> {'traverserCount': 264, 'elementCount': 264}, 'name': 
> 'HasStep([~label.eq(B)])@[s2]', 'annotations': {'percentDur': 
> 0.18886697476949157}, 'id': '4.0.0()'}, {'dur': 14.506215, 'counts': 
> {'traverserCount': 8368, 'elementCount': 8368}, 'name': 
> 'RepeatStep(emit([LoopsStep, IsStep(gte(1))]),[VertexStep(IN,edge), 
> EdgeVertexStep(OUT), RepeatEndStep],until(loops(2)))', 'annotations': 
> {'percentDur': 12.765621601096923}, 'id': '5.0.0()', 'metrics': [{'dur': 
> 0.352544, 'counts': {'traverserCount': 1625, 'elementCount': 1625}, 'name': 
> 'LoopsStep', 'id': '0.1.2(5.0.0())'}, {'dur': 0.515114, 'counts': {}, 'name': 
> 'IsStep(gte(1))', 'id': '2.1.2(5.0.0())'}, {'dur': 3.109686, 'counts': 
> {'traverserCount': 8368, 'elementCount': 8368}, 'name': 
> 'VertexStep(IN,edge)', 'id': '0.1.0(5.0.0())'}, {'dur': 3.077571, 'counts': 
> {'traverserCount': 8368, 'elementCount': 8368}, 'name': 
> 'EdgeVertexStep(OUT)', 'id': '2.1.0(5.0.0())'}, {'dur': 4.250924, 'counts': 
> {'traverserCount': 7007, 'elementCount': 7007}, 'name': 'RepeatEndStep', 
> 'id': '4.1.0(5.0.0())'}]}, {'dur': 2.603431, 'counts': {'traverserCount': 
> 4250, 'elementCount': 4250}, 'name': 'HasStep([~label.eq(B)])', 
> 'annotations': {'percentDur': 2.291046631431105}, 'id': '6.0.0()'}, {'dur': 
> 8.140922, 'counts': {'traverserCount': 44192, 'elementCount': 44192}, 'name': 
> 'VertexStep(BOTH,edge)', 'annotations': {'percentDur': 7.164096887854286}, 
> 'id': '7.0.0()'}, {'dur': 45.69575, 'counts': {'traverserCount': 44192, 
> 'elementCount': 44192}, 'name': 'DedupGlobalStep(null,[PathStep])', 
> 'annotations': {'percentDur': 40.21274007577612}, 'id': '8.0.0()', 'metrics': 
> [{'dur': 6.111861, 'counts': {'traverserCount': 44192, 'elementCount': 
> 44192}, 'name': 'PathStep', 'id': '0.1.0(8.0.0())'}]}, {'dur': 15.48812, 
> 'counts': {'traverserCount': 44192, 'elementCount': 44192}, 'name': 
> 'EdgeOtherVertexStep', 'annotations': {'percentDur': 13.62970831690977}, 
> 'id': '9.0.0()'}, {'dur': 12.234278, 'counts': {'traverserCount': 19100, 
> 'elementCount': 19100}, 'name': 'HasStep([~label.eq(A)])', 'annotations': 
> {'percentDur': 10.766293172314409}, 'id': '10.0.0()'}, {'dur': 9.183057, 
> 'counts': {'traverserCount': 19100, 'elementCount': 19100}, 'name': 
> 'SelectOneStep(last,s1,null)', 'annotations': {'percentDur': 
> 8.08118663643854}, 'id': '11.0.0()'}, {'dur': 2.750107, 'counts': 
> {'traverserCount': 1, 'elementCount': 1}, 'name': 'CountGlobalStep', 
> 'annotations': {'percentDur': 2.4201230523970487}, 'id': '12.0.0()'}]} {code}
> {code:java}
> {'dur': 109.860501, 'metrics': [{'dur': 0.093296, 'counts': 
> {'traverserCount': 5, 'elementCount': 5}, 'name': 
> 'TinkerGraphStep(vertex,[~label.eq(A)])@[s1]', 'annotations': {'percentDur': 
> 0.08492224152518657}, 'id': '15.0.0()'}, {'dur': 1.494234, 'counts': 
> {'traverserCount': 568, 'elementCount': 568}, 'name': 
> 'RepeatStep(emit([LoopsStep, IsStep(gte(1))]),[VertexStep(BOTH,edge), 
> DedupGlobalStep(null,[PathStep]), EdgeOtherVertexStep, 
> RepeatEndStep],until(loops(2)))', 'annotations': {'percentDur': 
> 1.3601194117984223}, 'id': '2.0.0()', 'metrics': [{'dur': 0.027009, 'counts': 
> {'traverserCount': 55, 'elementCount': 55}, 'name': 'LoopsStep', 'id': 
> '0.1.2(2.0.0())'}, {'dur': 0.019714, 'counts': {}, 'name': 'IsStep(gte(1))', 
> 'id': '2.1.2(2.0.0())'}, {'dur': 0.160825, 'counts': {'traverserCount': 568, 
> 'elementCount': 568}, 'name': 'VertexStep(BOTH,edge)', 'id': 
> '0.1.0(2.0.0())'}, {'dur': 0.622997, 'counts': {'traverserCount': 568, 
> 'elementCount': 568}, 'name': 'DedupGlobalStep(null,[PathStep])', 'id': 
> '2.1.0(2.0.0())', 'metrics': [{'dur': 0.079921, 'counts': {'traverserCount': 
> 568, 'elementCount': 568}, 'name': 'PathStep', 'id': 
> '0.2.0(2.1.0(2.0.0()))'}]}, {'dur': 0.215635, 'counts': {'traverserCount': 
> 568, 'elementCount': 568}, 'name': 'EdgeOtherVertexStep', 'id': 
> '4.1.0(2.0.0())'}, {'dur': 0.259263, 'counts': {'traverserCount': 518, 
> 'elementCount': 518}, 'name': 'RepeatEndStep', 'id': '6.1.0(2.0.0())'}]}, 
> {'dur': 1.143306, 'counts': {'traverserCount': 444, 'elementCount': 444}, 
> 'name': 'PathFilterStep(simple,s1,null)', 'annotations': {'percentDur': 
> 1.040688864144175}, 'id': '3.0.0()'}, {'dur': 0.169786, 'counts': 
> {'traverserCount': 264, 'elementCount': 264}, 'name': 
> 'HasStep([~label.eq(B)])', 'annotations': {'percentDur': 
> 0.15454690125616669}, 'id': '4.0.0()'}, {'dur': 14.164336, 'counts': 
> {'traverserCount': 8368, 'elementCount': 8368}, 'name': 
> 'RepeatStep(emit([LoopsStep, IsStep(gte(1))]),[VertexStep(IN,edge), 
> EdgeVertexStep(OUT), RepeatEndStep],until(loops(2)))', 'annotations': 
> {'percentDur': 12.893019666822747}, 'id': '5.0.0()', 'metrics': [{'dur': 
> 0.340473, 'counts': {'traverserCount': 1625, 'elementCount': 1625}, 'name': 
> 'LoopsStep', 'id': '0.1.2(5.0.0())'}, {'dur': 0.497164, 'counts': {}, 'name': 
> 'IsStep(gte(1))', 'id': '2.1.2(5.0.0())'}, {'dur': 2.920372, 'counts': 
> {'traverserCount': 8368, 'elementCount': 8368}, 'name': 
> 'VertexStep(IN,edge)', 'id': '0.1.0(5.0.0())'}, {'dur': 3.054795, 'counts': 
> {'traverserCount': 8368, 'elementCount': 8368}, 'name': 
> 'EdgeVertexStep(OUT)', 'id': '2.1.0(5.0.0())'}, {'dur': 4.27663, 'counts': 
> {'traverserCount': 7007, 'elementCount': 7007}, 'name': 'RepeatEndStep', 
> 'id': '4.1.0(5.0.0())'}]}, {'dur': 2.664804, 'counts': {'traverserCount': 
> 4250, 'elementCount': 4250}, 'name': 'HasStep([~label.eq(B)])', 
> 'annotations': {'percentDur': 2.4256252026376615}, 'id': '6.0.0()'}, {'dur': 
> 8.060513, 'counts': {'traverserCount': 44192, 'elementCount': 44192}, 'name': 
> 'VertexStep(BOTH,edge)', 'annotations': {'percentDur': 7.337043729665861}, 
> 'id': '7.0.0()'}, {'dur': 44.41532, 'counts': {'traverserCount': 42265, 
> 'elementCount': 42265}, 'name': 'DedupGlobalStep(null,[PathStep])', 
> 'annotations': {'percentDur': 40.42883438152171}, 'id': '8.0.0()', 'metrics': 
> [{'dur': 6.06568, 'counts': {'traverserCount': 44192, 'elementCount': 44192}, 
> 'name': 'PathStep', 'id': '0.1.0(8.0.0())'}]}, {'dur': 14.927731, 'counts': 
> {'traverserCount': 42265, 'elementCount': 42265}, 'name': 
> 'EdgeOtherVertexStep', 'annotations': {'percentDur': 13.58789634502031}, 
> 'id': '9.0.0()'}, {'dur': 11.377835, 'counts': {'traverserCount': 18198, 
> 'elementCount': 18198}, 'name': 'HasStep([~label.eq(A)])', 'annotations': 
> {'percentDur': 10.356620347107283}, 'id': '10.0.0()'}, {'dur': 8.696222, 
> 'counts': {'traverserCount': 18198, 'elementCount': 18198}, 'name': 
> 'SelectOneStep(last,s1,null)', 'annotations': {'percentDur': 
> 7.915694831939643}, 'id': '11.0.0()'}, {'dur': 2.653118, 'counts': 
> {'traverserCount': 1, 'elementCount': 1}, 'name': 'CountGlobalStep', 
> 'annotations': {'percentDur': 2.414988076560838}, 'id': '12.0.0()'}]}
> {code}
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to