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

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

Github user dkuppitz commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/474#discussion_r86029705
  
    --- Diff: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java
 ---
    @@ -105,21 +105,11 @@ private SubgraphStrategy(final Traversal<Vertex, ?> 
vertexCriterion, final Trave
             this.vertexPropertyCriterion = null == vertexPropertyCriterion ? 
null : vertexPropertyCriterion.asAdmin().clone();
     
             if (null != this.vertexCriterion)
    -            this.addLabelMarker(this.vertexCriterion);
    +            TraversalHelper.applyTraversalRecursively(t -> 
t.getStartStep().addLabel(MARKER), this.vertexCriterion);
    --- End diff --
    
    Ha, it's getting late here.....


> 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