Cole Greer created TINKERPOP-3207:
-------------------------------------

             Summary: Add Barriers to GroupSideEffect, GroupCountSideEffect, 
TreeSideEffect, and Subgraph Steps
                 Key: TINKERPOP-3207
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3207
             Project: TinkerPop
          Issue Type: Improvement
          Components: process
    Affects Versions: 3.7.4
            Reporter: Cole Greer


The gremlin language is mostly agnostic as to if a traversal should be executed 
lazily (DFS), or eagerly (BFS). Our documentation does not specify a preference 
for either method, and most traversals will give the same results regardless of 
evaluation order.

There are currently 5 steps which may lead to different results if evaluated in 
different orders: AggregateLocalStep, GroupSideEffectStep, 
GroupCountSideEffectStep, TreeSideEffectStep, and SubgraphStep. 

Consider the following example:


{code:java}
// Lazy evaluation
gremlin> g.V().groupCount(“x”).select(“x”)
==>[v[1]:1]
==>[v[1]:1,v[2]:1]
==>[v[1]:1,v[2]:1,v[3]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]

//Eager evaluation
gremlin> g.V().groupCount(“x”).select(“x”)
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
{code}

This inconsistency can be resolved by pulling the solution from 
AggregateGlobalStep and making each of these steps LocalBarrier's. If there are 
ever cases where users need the old "one-at-a-time" accumulation, this will 
still be achievable by embedding the step inside local().

{code:java}
gremlin> g.V().local(groupCount("x")).select("x")
==>[v[1]:1]
==>[v[1]:1,v[2]:1]
==>[v[1]:1,v[2]:1,v[3]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1]
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
{code}

This will ensure that all traversals will return consistent results, regardless 
of if is is run in a lazy or eager traversal engine.




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

Reply via email to