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

ASF GitHub Bot commented on TINKERPOP-1638:
-------------------------------------------

GitHub user dkuppitz opened a pull request:

    https://github.com/apache/tinkerpop/pull/563

    TINKERPOP-1638 count() is optimized away in where()

    https://issues.apache.org/jira/browse/TINKERPOP-1638
    
    Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner 
traversals.
    
    VOTE: +1

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/tinkerpop TINKERPOP-1638

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tinkerpop/pull/563.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #563
    
----
commit fe905dda7aaf7262a2e074c2b185a4248bc7f479
Author: Daniel Kuppitz <[email protected]>
Date:   2017-02-23T14:33:28Z

    Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner 
traversals.

----


> count() is optimized away in where()
> ------------------------------------
>
>                 Key: TINKERPOP-1638
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1638
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.2.1
>            Reporter: Robert Dale
>            Assignee: Daniel Kuppitz
>
> See also [gremlin-users 
> discussion|https://groups.google.com/d/msg/gremlin-users/GCh2M9PVd7g/iLZE4L9wBgAJ]
> This produces no results:
> {noformat}
> gremlin> graph = TinkerFactory.createModern()
> ==>tinkergraph[vertices:6 edges:6]
> gremlin> g = graph.traversal()
> ==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
> gremlin> g.V().where( __.in('A').in('B').count().is(eq(0)) )
> gremlin> 
> {noformat}
> In 3.2.0-incubating, it correctly (or atleast expectedly) produces:
> {noformat}
> ==>v[1]
> ==>v[2]
> ==>v[3]
> ==>v[4]
> ==>v[5]
> ==>v[6]
> {noformat}
> Outside of the where() clause, it produces the expected result:
> {noformat}
> gremlin> g.V().in('A').in('B').count()
> ==>0
> {noformat}
> Thus, one could expect it to work inside the where() clause.  It appears that 
> some optimization occurs that removes the count step and converts it into a 
> NotStep.
> 3.2.0-incubating:
> {noformat}
> gremlin> g.V().where( __.in('A').in('B').count().is(eq(0)) ).explain()
> ==>Traversal Explanation
> ================================================================================================================================================================================================
> Original Traversal                 [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> ConnectiveStrategy           [D]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> IdentityRemovalStrategy      [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> IncidentToAdjacentStrategy   [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> AdjacentToIncidentStrategy   [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> CountGlobalStep, IsStep(eq(0))])]
> FilterRankingStrategy        [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> CountGlobalStep, IsStep(eq(0))])]
> MatchPredicateStrategy       [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> CountGlobalStep, IsStep(eq(0))])]
> RangeByIsCountStrategy       [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> RangeGlobalStep(0,1), CountGlobalStep, IsStep(eq(0))])]
> TinkerGraphStepStrategy      [P]   [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> RangeGlobalStep(0,1), CountGlobalStep, IsStep(eq(0))])]
> ProfileStrategy              [F]   [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> RangeGlobalStep(0,1), CountGlobalStep, IsStep(eq(0))])]
> StandardVerificationStrategy [V]   [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> RangeGlobalStep(0,1), CountGlobalStep, IsStep(eq(0))])]
> Final Traversal                    [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],edge), 
> RangeGlobalStep(0,1), CountGlobalStep, IsStep(eq(0))])]
> {noformat}
> 3.2.4:
> {noformat}
> gremlin> g.V().where( __.in('A').in('B').count().is(eq(0)) ).explain()
> ==>Traversal Explanation
> ======================================================================================================================================================================
> Original Traversal                 [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> ConnectiveStrategy           [D]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> MatchPredicateStrategy       [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> FilterRankingStrategy        [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> InlineFilterStrategy         [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> RepeatUnrollStrategy         [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> PathRetractionStrategy       [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), VertexStep(IN,[B],vertex), 
> CountGlobalStep, IsStep(eq(0))])]
> RangeByIsCountStrategy       [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],vertex)])])]
> IncidentToAdjacentStrategy   [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],vertex)])])]
> AdjacentToIncidentStrategy   [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],edge)])])]
> LazyBarrierStrategy          [O]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],edge)])])]
> TinkerGraphCountStrategy     [P]   [GraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],edge)])])]
> TinkerGraphStepStrategy      [P]   [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],edge)])])]
> ProfileStrategy              [F]   [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],edge)])])]
> StandardVerificationStrategy [V]   [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],edge)])])]
> Final Traversal                    [TinkerGraphStep(vertex,[]), 
> TraversalFilterStep([VertexStep(IN,[A],vertex), 
> NotStep([VertexStep(IN,[B],edge)])])]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to