From commits-return-32718-archive-asf-public=cust-asf.ponee.io@tinkerpop.apache.org Fri Oct 5 13:37:26 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id BD24C18077A for ; Fri, 5 Oct 2018 13:37:24 +0200 (CEST) Received: (qmail 4636 invoked by uid 500); 5 Oct 2018 11:37:23 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 4591 invoked by uid 99); 5 Oct 2018 11:37:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2018 11:37:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 364DAE08DE; Fri, 5 Oct 2018 11:37:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rdale@apache.org To: commits@tinkerpop.apache.org Date: Fri, 05 Oct 2018 11:37:25 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [03/48] tinkerpop git commit: TINKERPOP-2049 Added with(k) overload TINKERPOP-2049 Added with(k) overload Makes flag-like uses of with() a bit more succinct. Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9b4cddb9 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9b4cddb9 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9b4cddb9 Branch: refs/heads/TINKERPOP-2037 Commit: 9b4cddb94a97a1ea3dee79259e25c2aa28518972 Parents: 1e3d4d2 Author: Stephen Mallette Authored: Thu Sep 27 08:49:41 2018 -0400 Committer: Stephen Mallette Committed: Thu Sep 27 15:38:19 2018 -0400 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 2 +- .../traversal/dsl/graph/GraphTraversal.java | 17 +++++++++++++++++ .../traversal/dsl/graph/GraphTraversalTest.java | 15 +++++++++++++-- .../Process/Traversal/GraphTraversal.cs | 9 +++++++++ gremlin-test/features/map/ShortestPath.feature | 4 ++-- .../traversal/step/map/ShortestPathTest.java | 4 ++-- 6 files changed, 44 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9b4cddb9/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index efb3e43..8f9f328 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -49,7 +49,7 @@ This release also includes changes from <>. * Moved `Parameterizing` interface to the `org.apache.tinkerpop.gremlin.process.traversal.step` package with other marker interfaces of its type. * Replaced `Parameterizing.addPropertyMutations()` with `Configuring.configure()`. * Changed interface hierarchy for `Parameterizing` and `Mutating` interfaces as they are tightly related. -* Introduced the `with()` step modulator which can supply configuration options to `Configuring` steps. +* Introduced the `with(k,v)` and `with(k)` step modulators which can supply configuration options to `Configuring` steps. * Added `connectedComponent()` step and related `VertexProgram`. * Added `supportsUpsert()` option to `VertexFeatures` and `EdgeFeatures`. * `min()` and `max()` now support all types implementing `Comparable`. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9b4cddb9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java index 0f8677e..66b45ec 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java @@ -2564,6 +2564,23 @@ public interface GraphTraversal extends Traversal { //// WITH-MODULATOR /** + * Provides a configuration to a step in the form of a key which is the same as {@code with(key, true)}. The key + * of the configuration must be step specific and therefore a configuration could be supplied that is not known to + * be valid until execution. + * + * @param key the key of the configuration to apply to a step + * @return the traversal with a modulated step + * @see Reference Documentation - With Step + * @since 3.4.0 + */ + public default GraphTraversal with(final String key) { + this.asAdmin().getBytecode().addStep(Symbols.with, key); + final Object[] configPair = { key, true }; + ((Configuring) this.asAdmin().getEndStep()).configure(configPair); + return this; + } + + /** * Provides a configuration to a step in the form of a key and value pair. The key of the configuration must be * step specific and therefore a configuration could be supplied that is not known to be valid until execution. * http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9b4cddb9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java index 0d57f49..166c890 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java @@ -33,6 +33,7 @@ import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.Set; +import java.util.function.Consumer; import static org.junit.Assert.assertEquals; @@ -45,7 +46,7 @@ public class GraphTraversalTest { private static Set NO_GRAPH = new HashSet<>(Arrays.asList("asAdmin", "by", "read", "write", "with", "option", "iterate", "to", "from", "profile", "pageRank", "connectedComponent", "peerPressure", "shortestPath", "program", "none")); private static Set NO_ANONYMOUS = new HashSet<>(Arrays.asList("start", "__")); - private static Set IGNORES_BYTECODE = new HashSet<>(Arrays.asList("asAdmin", "read", "write", "iterate", "mapValues", "mapKeys")); + private static Set IGNORES_BYTECODE = new HashSet<>(Arrays.asList("asAdmin", "read", "write", "iterate")); @Test public void shouldHaveMethodsOfGraphTraversalOnAnonymousGraphTraversal() { @@ -100,10 +101,16 @@ public class GraphTraversalTest { /// if (stepMethod.getName().equals("by")) traversal.order(); + else if (stepMethod.getName().equals("with")) + randomPossibleStep(random, traversal, + GraphTraversal::V, GraphTraversal::shortestPath, GraphTraversal::pageRank, + GraphTraversal::connectedComponent, GraphTraversal::peerPressure, t -> t.addE("link"), + GraphTraversal::addV); else if (stepMethod.getName().equals("option")) traversal.branch(__.identity().out(randomString(random))); else if (stepMethod.getName().equals("to") || stepMethod.getName().equals("from")) traversal.addE(randomString(random)); + if (stepMethod.getName().equals("range")) { if (Scope.class.isAssignableFrom(stepMethod.getParameterTypes()[0])) { list.add(arguments[0] = Scope.local); @@ -166,7 +173,11 @@ public class GraphTraversalTest { } } - private final static String randomString(final Random random) { + private static void randomPossibleStep(final Random random, final GraphTraversal t, final Consumer... possible) { + possible[random.nextInt(possible.length)].accept(t); + } + + private static String randomString(final Random random) { String s = ""; for (int i = 0; i < random.nextInt(10) + 1; i++) { s = (s + (char) (random.nextInt(100) + 1)).trim(); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9b4cddb9/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 83dbe85..b4d342f 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -1724,6 +1724,15 @@ namespace Gremlin.Net.Process.Traversal /// /// Adds the with step to this . /// + public GraphTraversal With (string key) + { + Bytecode.AddStep("with", key); + return Wrap(this); + } + + /// + /// Adds the with step to this . + /// public GraphTraversal With (string key, object value) { Bytecode.AddStep("with", key, value); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9b4cddb9/gremlin-test/features/map/ShortestPath.feature ---------------------------------------------------------------------- diff --git a/gremlin-test/features/map/ShortestPath.feature b/gremlin-test/features/map/ShortestPath.feature index eff743f..9ae01b2 100644 --- a/gremlin-test/features/map/ShortestPath.feature +++ b/gremlin-test/features/map/ShortestPath.feature @@ -113,7 +113,7 @@ Feature: Step - shortestPath() Given the modern graph And the traversal of """ - g.withComputer().V().shortestPath().with("~tinkerpop.shortestPath.includeEdges", true) + g.withComputer().V().shortestPath().with("~tinkerpop.shortestPath.includeEdges") """ When iterated to list Then the result should be unordered @@ -206,7 +206,7 @@ Feature: Step - shortestPath() And the traversal of """ g.withComputer().V().shortestPath(). - with("~tinkerpop.shortestPath.includeEdges", true). + with("~tinkerpop.shortestPath.includeEdges"). with("~tinkerpop.shortestPath.edges", __.outE()) """ When iterated to list http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9b4cddb9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ShortestPathTest.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ShortestPathTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ShortestPathTest.java index a55215b..620f566 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ShortestPathTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ShortestPathTest.java @@ -276,7 +276,7 @@ public abstract class ShortestPathTest extends AbstractGremlinProcessTest { @Override public Traversal get_g_V_shortestPath_edgesIncluded() { - return g.V().shortestPath().with(includeEdges, true); + return g.V().shortestPath().with(includeEdges); } @Override @@ -291,7 +291,7 @@ public abstract class ShortestPathTest extends AbstractGremlinProcessTest { @Override public Traversal get_g_V_shortestPath_edgesIncluded_edgesXoutEX() { - return g.V().shortestPath().with(includeEdges, true).with(edges, __.outE()); + return g.V().shortestPath().with(includeEdges).with(edges, __.outE()); } @Override