You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/09/28 17:38:22 UTC

[22/41] tinkerpop git commit: per @spmallettes request -- added JavaDoc to InlineFilter'Strategy. Also, used the new TraversalHelper.copyLabels() method in InlineFilterStrategy.

per @spmallettes request -- added JavaDoc to InlineFilter'Strategy. Also, used the new TraversalHelper.copyLabels() method in InlineFilterStrategy.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/79da3a66
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/79da3a66
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/79da3a66

Branch: refs/heads/TINKERPOP-790
Commit: 79da3a6653efbc80606a60a95840ab3658c3c890
Parents: 6b1a2d9
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Sep 26 09:43:04 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Sep 27 12:45:49 2016 -0600

----------------------------------------------------------------------
 .../optimization/InlineFilterStrategy.java      | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/79da3a66/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
index 0944361..ba2f832 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
@@ -35,7 +35,17 @@ import java.util.List;
 import java.util.Set;
 
 /**
+ * InlineFilterStrategy analyzes filter-steps with child traversals that themselves are pure filters.
+ * If the child traversals are pure filters then the wrapping parent filter is not needed and thus, the
+ * children can be "inlined."
+ * <p/>
+ *
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @example <pre>
+ * __.filter(has("name","marko"))                                // is replaced by __.has("name","marko")
+ * __.and(has("name"),has("age"))                                // is replaced by __.has("name").has("age")
+ * __.and(filter(has("name","marko").has("age")),hasNot("blah")) // is replaced by __.has("name","marko").has("age").hasNot("blah")
+ * </pre>
  */
 public final class InlineFilterStrategy extends AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy> implements TraversalStrategy.OptimizationStrategy {
 
@@ -59,10 +69,8 @@ public final class InlineFilterStrategy extends AbstractTraversalStrategy<Traver
                     TraversalHelper.applySingleLevelStrategies(traversal, childTraversal, InlineFilterStrategy.class);
                     final Step<?, ?> finalStep = childTraversal.getEndStep();
                     TraversalHelper.insertTraversal((Step) step, childTraversal, traversal);
+                    TraversalHelper.copyLabels(step, finalStep, false);
                     traversal.removeStep(step);
-                    for (final String label : step.getLabels()) {
-                        finalStep.addLabel(label);
-                    }
                 }
             }
             for (final AndStep<?> step : TraversalHelper.getStepsOfAssignableClass(AndStep.class, traversal)) {
@@ -78,12 +86,8 @@ public final class InlineFilterStrategy extends AbstractTraversalStrategy<Traver
                         TraversalHelper.insertTraversal((Step) step, childTraversals.get(i), traversal);
 
                     }
+                    if (null != finalStep) TraversalHelper.copyLabels(step, finalStep, false);
                     traversal.removeStep(step);
-                    if (null != finalStep) {
-                        for (final String label : step.getLabels()) {
-                            finalStep.addLabel(label);
-                        }
-                    }
                 }
             }
         }