[
https://issues.apache.org/jira/browse/TINKERPOP-2886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17752090#comment-17752090
]
Stephen Mallette commented on TINKERPOP-2886:
---------------------------------------------
this one is tricky but expected. {{Path}} objects do equality on the objects
of the path but also their labels. in this example you can create a situation
where the label of "x" gets applied to different parts of the same path so when
you go to {{dedup()}} you could still end up with duplicates. you can see this
by analyzing the paths:
{code}
gremlin> g.V().
......1> emit(__.loops().is(gte(1))).
......2> repeat(__.bothE().otherV()).times(2).as('x').
......3> emit(__.loops().is(gte(1))).
......4> repeat(__.inE().outV()).times(2).
......5> bothE().
......6> dedup().by(__.path()).
......7> otherV().
......8> count()
==>166
gremlin> withX = g.V().
......1> emit(__.loops().is(gte(1))).
......2> repeat(__.bothE().otherV()).times(2).as('x').
......3> emit(__.loops().is(gte(1))).
......4> repeat(__.inE().outV()).times(2).
......5> bothE().path().toList();[]
gremlin> withX.unique { a,b -> a.objects().equals(b.objects()) ? 0 : 1 }.size()
==>154
gremlin> g.V().
......1> emit(__.loops().is(gte(1))).
......2> repeat(__.bothE().otherV()).times(2).
......3> emit(__.loops().is(gte(1))).
......4> repeat(__.inE().outV()).times(2).
......5> bothE().
......6> dedup().by(__.path()).
......7> otherV().
......8> count()
==>154
{code}
I think there are cases where you want the label included in the quality so we
probably don't want to change that, but it's also not immediately intuitive as
to what's happening (given how long it took me to realize what was happening)
and how would you reasonably {{dedup()}} with a labelled step if you wanted to?
i guess you would kill deconstruct the {{Path}} to get rid of the labels:
{code}
gremlin> g.V().
......1> emit(__.loops().is(gte(1))).
......2> repeat(__.bothE().otherV()).times(2).as('x').
......3> emit(__.loops().is(gte(1))).
......4> repeat(__.inE().outV()).times(2).
......5> bothE().
......6> dedup().by(__.path().unfold().fold()).
......7> otherV().
......8> count()
==>154
{code}
at minimum this one seems like it needs some additional documentation.
> Inconsistent results when executing equivalent queries
> ------------------------------------------------------
>
> Key: TINKERPOP-2886
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2886
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> 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)