You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Robert Dale (JIRA)" <ji...@apache.org> on 2017/02/23 13:37:44 UTC
[jira] [Created] (TINKERPOP-1638) count() is optimized away in
where()
Robert Dale created TINKERPOP-1638:
--------------------------------------
Summary: 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
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)