tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject tinkerpop git commit: foo
Date Tue, 13 Mar 2018 18:13:19 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TRAVIS-TEST 37d7d2953 -> f18cec874


foo


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

Branch: refs/heads/TRAVIS-TEST
Commit: f18cec874268649dad3041ddac5dd596949b3966
Parents: 37d7d29
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Tue Mar 13 11:13:16 2018 -0700
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Tue Mar 13 11:13:16 2018 -0700

----------------------------------------------------------------------
 .../process/traversal/TraversalSource.java      | 23 +++++++++++++++++---
 .../decoration/RequirementsStrategy.java        |  4 ++++
 .../util/DefaultTraversalStrategies.java        |  5 +++--
 3 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f18cec87/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
index 2421a78..f6a4bb2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
@@ -24,12 +24,16 @@ import org.apache.tinkerpop.gremlin.process.computer.Computer;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
 import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.RequirementsStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SackStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SideEffectStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.util.function.ConstantSupplier;
 
 import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Optional;
 import java.util.function.BinaryOperator;
 import java.util.function.Supplier;
@@ -100,10 +104,23 @@ public interface TraversalSource extends Cloneable, AutoCloseable {
      * @return a new traversal source with updated strategies
      */
     public default TraversalSource withStrategies(final TraversalStrategy... traversalStrategies)
{
-        final TraversalSource clone = this.clone();
-        clone.getStrategies().addStrategies(traversalStrategies);
-        clone.getBytecode().addSource(TraversalSource.Symbols.withStrategies, traversalStrategies);
+        final List<TraversalStrategy> strategiesWithDependencies = new ArrayList<>(traversalStrategies.length);
+        boolean addRequirementStrategy = false, containsRequirementStrategy = false;
         for (final TraversalStrategy traversalStrategy : traversalStrategies) {
+            strategiesWithDependencies.add(traversalStrategy);
+            addRequirementStrategy |= traversalStrategy instanceof SubgraphStrategy;
+            containsRequirementStrategy |= traversalStrategy instanceof RequirementsStrategy;
+        }
+        if (addRequirementStrategy && !containsRequirementStrategy) {
+            strategiesWithDependencies.add(RequirementsStrategy.instance());
+        }
+        final TraversalStrategy[] allStrategies = strategiesWithDependencies.toArray(
+                new TraversalStrategy[strategiesWithDependencies.size()]);
+
+        final TraversalSource clone = this.clone();
+        clone.getStrategies().addStrategies(allStrategies);
+        clone.getBytecode().addSource(TraversalSource.Symbols.withStrategies, allStrategies);
+        for (final TraversalStrategy traversalStrategy : allStrategies) {
             if (traversalStrategy instanceof VertexProgramStrategy) {
                 ((VertexProgramStrategy) traversalStrategy).addGraphComputerStrategies(clone);
             }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f18cec87/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/RequirementsStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/RequirementsStrategy.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/RequirementsStrategy.java
index 247835c..aec2706 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/RequirementsStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/RequirementsStrategy.java
@@ -69,6 +69,10 @@ public final class RequirementsStrategy extends AbstractTraversalStrategy<Traver
         Collections.addAll(strategy.requirements, requirements);
     }
 
+    public static RequirementsStrategy instance() {
+        return new RequirementsStrategy();
+    }
+
     @Override
     public Set<Class<? extends DecorationStrategy>> applyPost() {
         return Collections.singleton(VertexProgramStrategy.class);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f18cec87/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalStrategies.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalStrategies.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalStrategies.java
index 74e84e2..992d998 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalStrategies.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalStrategies.java
@@ -82,8 +82,9 @@ public class DefaultTraversalStrategies implements TraversalStrategies {
 
     @Override
     public void applyStrategies(final Traversal.Admin<?, ?> traversal) {
-        for (final TraversalStrategy<?> traversalStrategy : this.traversalStrategies)
{
-            traversalStrategy.apply(traversal);
+        //for (final TraversalStrategy<?> traversalStrategy : this.traversalStrategies)
{
+        for (int i = 0; i < this.traversalStrategies.size(); i++) {
+            this.traversalStrategies.get(i).apply(traversal);
         }
     }
 


Mime
View raw message