You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/05/06 02:06:22 UTC

incubator-tinkerpop git commit: added JavaDoc for AdjacentToIncidentStrategy

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 0605e6432 -> 3a58e3b16


added JavaDoc for AdjacentToIncidentStrategy


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

Branch: refs/heads/master
Commit: 3a58e3b16a5bf51ac3be1d0a6407d0cf91ff1578
Parents: 0605e64
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Wed May 6 02:05:50 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Wed May 6 02:05:50 2015 +0200

----------------------------------------------------------------------
 .../AdjacentToIncidentStrategy.java             | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3a58e3b1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
index aceb27b..4c6a199 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
@@ -34,6 +34,23 @@ import org.apache.tinkerpop.gremlin.structure.PropertyType;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 
 /**
+ * This strategy looks for vertex- and value-emitting steps followed by a {@link CountGlobalStep} and replaces the
+ * pattern with an edge- or property-emitting step followed by a <code>CountGlobalStep</code>. For example:
+ * <p/>
+ * <code>
+ * __.out().count()          // is replaced by __.outE().count()
+ * __.in().limit(3).count()  // is replaced by __.inE().limit(3).count()
+ * __.values("name").count() // is replaced by __.properties("name").count()
+ * </code>
+ * <p/>
+ * Furthermore, if a vertex- or value-emitting step is the last step in a <code>.has(traversal)</code> child traversal,
+ * it is replaced by an appropriate edge- or property-emitting step. For example:
+ * <p/>
+ * <code>
+ * __.has(out())    // is replaced by __.has(__.outE())
+ * __.has(values()) // is replaced by __.has(__.properties())
+ * </code>
+ *
  * @author Daniel Kuppitz (http://gremlin.guru)
  */
 public final class AdjacentToIncidentStrategy extends AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy>
@@ -66,11 +83,24 @@ public final class AdjacentToIncidentStrategy extends AbstractTraversalStrategy<
         }
     }
 
+    /**
+     * Checks whether a given step is optimizable or not.
+     *
+     * @param step the step to check
+     * @return <code>true</code> if the step is optimizable, otherwise <code>false</code>
+     */
     private static boolean isOptimizable(final Step step) {
         return ((step instanceof VertexStep && Vertex.class.equals(((VertexStep) step).getReturnClass())) ||
                 (step instanceof PropertiesStep && PropertyType.VALUE.equals(((PropertiesStep) step).getReturnType())));
     }
 
+    /**
+     * Optimizes the given step if possible. Basically this method converts <code>.out()</code> to <code>.outE()</code>
+     * and <code>.values()</code> to <code>.properties()</code>.
+     *
+     * @param traversal the traversal that holds the given step
+     * @param step      the step to replace
+     */
     private static void optimizeStep(final Traversal.Admin traversal, final Step step) {
         final Step newStep;
         if (step instanceof VertexStep) {