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

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

GitHub user okram opened a pull request:

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

    TINKERPOP-1471: IncidentToAdjacentStrategy use hidden marker to avoid 
repeated recursion.

    https://issues.apache.org/jira/browse/TINKERPOP-1471
    
    Hidden labels can be used by strategies as a way to communicate between 
"layers" of the compilation tree. This model is now applied to 
`IncidentToAdjacentStrategy` where if the traversal (as a whole) should NOT be 
processed by `IncidentToAdjacentStrategy`, then each traversal in the tree is 
"marked." If the traversal can be processed by `IncidentToAdjacentStrategy`, 
then there is no need to mark the traversals. This removes the need to, for 
every traversal, do a recursion from the parent traversal looking for 
invalidating step classes.
    
    VOTE +1.

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

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

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

    https://github.com/apache/tinkerpop/pull/474.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 #474
    
----
commit 6a1a0741ea8ee64427a126e8980ecf7db1a3299a
Author: Marko A. Rodriguez <okramma...@gmail.com>
Date:   2016-11-01T17:54:50Z

    IncidentToAdjacentStrategy now uses a hidden marker label to remove the 
need for constant rootTraversal recrussion in search of invalidating steps.

----


> IncidentToAdjacentStrategy use hidden marker to avoid repeated recursion.
> -------------------------------------------------------------------------
>
>                 Key: TINKERPOP-1471
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1471
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.2.2
>            Reporter: Marko A. Rodriguez
>            Assignee: Daniel Kuppitz
>
> TINKERPOP-1456 introduces the notion that "hidden labels" on steps will be 
> removed from the traversal prior to evaluation. This use of "hidden labels" 
> was necessary for {{SubgraphStrategy}} and it is not always possible to 
> remove the add "hidden labels" in {{SubgraphStrategy}} completely. Thus, 
> prior to evaluation, in hidden labels are removed.
> This concept of "hidden labels" is useful for marking steps in a traversal so 
> that  a strategy applied at a child gets information from the strategy 
> applied at a parent.
> This can be used to make {{IncidentToAdjacentStrategy}} faster. In 
> particular, the following recursion is called repeatedly for each child.
> {code}
>   if 
> (TraversalHelper.hasStepOfAssignableClassRecursively(INVALIDATING_STEP_CLASSES,
>  TraversalHelper.getRootTraversal(traversal)))
>             return;
> {code}
> Instead, it would be smart to do this and then, you don't need to recurse 
> from the root traversal over and over again.
> {code}
>     private final void addMarkerToChildren(final Traversal.Admin<?, ?> 
> traversal) {
>         traversal.getStartStep().addLabel(MARKER);
>         for (final Step<?, ?> step : traversal.getSteps()) {
>             if (step instanceof TraversalParent) {
>                 ((TraversalParent) 
> step).getLocalChildren().forEach(this::addMarkerToChildren);
>                 ((TraversalParent) 
> step).getGlobalChildren().forEach(this::addMarkerToChildren);
>             }
>         }
>     }
> public void apply(Traversal traversal) {
>   if(traversal.getParent() instanceof EmptyStep) {
>     boolean mark = 
> TraversalHelper.hasStepOfAssignableClassRecursively(INVALIDATING_STEP_CLASSES,
>  traversal)
>     if(mark)  this.addMarkerToChildren(traversal)
>   }
>   // if the marker exists, don't optimize
>   if(traversal.getStartStep().getLabels().contains(MARKER)) {
>     traversal.getStartStep().removeLabel(MARKER);
>     return;
>   }
> // else do the rest of the code.
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to