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 2018/10/04 10:48:57 UTC
[1/2] tinkerpop git commit: TINKERPOP-2049 Added with(k) overload
Repository: tinkerpop
Updated Branches:
refs/heads/master 2ae8c5bec -> 3a8f58088
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/master
Commit: 9b4cddb94a97a1ea3dee79259e25c2aa28518972
Parents: 1e3d4d2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 27 08:49:41 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
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 <<release-3-3-3, 3.3.3>>.
* 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<S, E> extends Traversal<S, E> {
//// 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 <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#with-step" target="_blank">Reference Documentation - With Step</a>
+ * @since 3.4.0
+ */
+ public default GraphTraversal<S,E> 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<String> 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<String> NO_ANONYMOUS = new HashSet<>(Arrays.asList("start", "__"));
- private static Set<String> IGNORES_BYTECODE = new HashSet<>(Arrays.asList("asAdmin", "read", "write", "iterate", "mapValues", "mapKeys"));
+ private static Set<String> 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<GraphTraversal>... 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
/// <summary>
/// Adds the with step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
+ public GraphTraversal<S, E> With (string key)
+ {
+ Bytecode.AddStep("with", key);
+ return Wrap<S, E>(this);
+ }
+
+ /// <summary>
+ /// Adds the with step to this <see cref="GraphTraversal{SType, EType}" />.
+ /// </summary>
public GraphTraversal<S, E> 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<Vertex, Path> 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<Vertex, Path> 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
[2/2] tinkerpop git commit: Merge branch 'TINKERPOP-2049'
Posted by sp...@apache.org.
Merge branch 'TINKERPOP-2049'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3a8f5808
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3a8f5808
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3a8f5808
Branch: refs/heads/master
Commit: 3a8f580880796fb81619c3572ab2167088320026
Parents: 2ae8c5b 9b4cddb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Oct 4 06:48:39 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Oct 4 06:48:39 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/3a8f5808/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3a8f5808/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------