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/04/24 22:50:20 UTC

[1/5] tinkerpop git commit: Fix typos in GraphManager and DefaultGraphManager javadoc [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1950 d7d0aafc0 -> 4fa21313b (forced update)


Fix typos in GraphManager and DefaultGraphManager javadoc


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

Branch: refs/heads/TINKERPOP-1950
Commit: 268423d2d16397ad749082041ea0e17075a3093d
Parents: 682f298
Author: Justin Chu <15...@users.noreply.github.com>
Authored: Fri Apr 20 22:47:31 2018 -0400
Committer: Justin Chu <15...@users.noreply.github.com>
Committed: Fri Apr 20 22:52:30 2018 -0400

----------------------------------------------------------------------
 .../java/org/apache/tinkerpop/gremlin/server/GraphManager.java   | 4 ++--
 .../tinkerpop/gremlin/server/util/DefaultGraphManager.java       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/268423d2/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java
index 8e3198f..bcb4a8e 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java
@@ -69,8 +69,8 @@ public interface GraphManager {
      *
      * @return a {@link Map} where the key is the name of the {@link TraversalSource} and the value is the
      *         {@link TraversalSource} itself
-     * @deprecated  As of release 3.2.5, replaced by a combination of {@link #getTraversalSource(String)} ()} and
-     * {@link #getTraversalSource(String)} (String)} - note that the expectation is this method return an immutable
+     * @deprecated  As of release 3.2.5, replaced by a combination of {@link #getTraversalSourceNames()} and
+     * {@link #getTraversalSource(String)} - note that the expectation is this method return an immutable
      * {@code Map} which was not the expectation prior to 3.2.5.
      */
     @Deprecated

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/268423d2/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java
index 5e4a355..9b5668f 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java
@@ -96,8 +96,8 @@ public final class DefaultGraphManager implements GraphManager {
      *
      * @return a {@code Map} where the key is the name of the {@link TraversalSource} and the value is the
      * {@link TraversalSource} itself
-     * @deprecated As of release 3.2.5, replaced by a combination of {@link #getTraversalSource(String)} ()} and
-     * {@link #getTraversalSource(String)} (String)}
+     * @deprecated As of release 3.2.5, replaced by a combination of {@link #getTraversalSourceNames()} and
+     * {@link #getTraversalSource(String)}
      */
     @Deprecated
     public final Map<String, TraversalSource> getTraversalSources() {


[4/5] tinkerpop git commit: Added Pop.all to python gherkin test support

Posted by sp...@apache.org.
Added Pop.all to python gherkin test support

Pop.all in python is Pop.all_ in python - needed that translation for tests that use that expression CTR


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

Branch: refs/heads/TINKERPOP-1950
Commit: 8462f857d78a11e4d383fdc077fe8bb8688cbe67
Parents: c155818
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Apr 24 09:17:18 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Apr 24 09:17:18 2018 -0400

----------------------------------------------------------------------
 gremlin-python/src/main/jython/radish/feature_steps.py | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8462f857/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 5cf9059..80137b0 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -25,6 +25,7 @@ from gremlin_python.process.traversal import Barrier, Cardinality, P, Pop, Scope
 from radish import given, when, then
 from hamcrest import *
 
+regex_all = re.compile(r"Pop\.all")
 regex_and = re.compile(r"([(.,\s])and\(")
 regex_as = re.compile(r"([(.,\s])as\(")
 regex_from = re.compile(r"([(.,\s])from\(")
@@ -233,6 +234,7 @@ def _table_assertion(data, result, ctx, ordered):
 
 def _translate(traversal):
     replaced = traversal.replace("\n", "")
+    replaced = regex_all.sub(r"Pop.all_", replaced)
     replaced = regex_and.sub(r"\1and_(", replaced)
     replaced = regex_from.sub(r"\1from_(", replaced)
     replaced = regex_global.sub(r"\1global_", replaced)


[5/5] tinkerpop git commit: TINKERPOP-1950 Cached global strategy lookups during traversal construction

Posted by sp...@apache.org.
TINKERPOP-1950 Cached global strategy lookups during traversal construction

This change leads to a 1.5x to 2x speed improvement in traversal construction. It is especially effective when processing traversals that have many child traversals within them as this method is called for not only the parent traversal but all the children as well.


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

Branch: refs/heads/TINKERPOP-1950
Commit: 4fa21313bd4647015072b59ec3ba2d7bfb5c665d
Parents: 8462f85
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 20 16:18:13 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Apr 24 18:50:01 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../process/traversal/TraversalStrategies.java  | 29 ++++++++++++++------
 2 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4fa21313/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 51c9f68..ea7473b 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 
 * Bumped to httpclient 4.5.5.
 * Improved performance of GraphSON deserialization of `Bytecode`.
+* Improved performance of traversal construction.
 
 [[release-3-2-8]]
 === TinkerPop 3.2.8 (Release Date: April 2, 2018)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4fa21313/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
index c7ee5bf..7ca5b61 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
@@ -63,6 +63,8 @@ import java.util.stream.Collectors;
  */
 public interface TraversalStrategies extends Serializable, Cloneable {
 
+    static Set<Class> LOADED = new HashSet<>();
+
     static List<Class<? extends TraversalStrategy>> STRATEGY_CATEGORIES = Collections.unmodifiableList(Arrays.asList(TraversalStrategy.DecorationStrategy.class, TraversalStrategy.OptimizationStrategy.class, TraversalStrategy.ProviderOptimizationStrategy.class, TraversalStrategy.FinalizationStrategy.class, TraversalStrategy.VerificationStrategy.class));
 
     /**
@@ -244,20 +246,31 @@ public interface TraversalStrategies extends Serializable, Cloneable {
         public static TraversalStrategies getStrategies(final Class graphOrGraphComputerClass) {
             try {
                 // be sure to load the class so that its static{} traversal strategy registration component is loaded.
-                // this is more important for GraphComputer classes as they are typically not instantiated prior to strategy usage like Graph classes.
-                final String graphComputerClassName = null != graphOrGraphComputerClass.getDeclaringClass() ?
+                // this is more important for GraphComputer classes as they are typically not instantiated prior to
+                // strategy usage like Graph classes.
+                if (!LOADED.contains(graphOrGraphComputerClass)) {
+                    final String graphComputerClassName = null != graphOrGraphComputerClass.getDeclaringClass() ?
                         graphOrGraphComputerClass.getCanonicalName().replace("." + graphOrGraphComputerClass.getSimpleName(), "$" + graphOrGraphComputerClass.getSimpleName()) :
                         graphOrGraphComputerClass.getCanonicalName();
-                Class.forName(graphComputerClassName);
+                    Class.forName(graphComputerClassName);
+
+                    // keep track of stuff we already loaded once - stuff in this if/statement isn't cheap and this
+                    // method gets called a lot, basically every time a new traversal gets spun up (that includes
+                    // child traversals.
+                    LOADED.add(graphOrGraphComputerClass);
+                }
             } catch (final ClassNotFoundException e) {
                 throw new IllegalStateException(e.getMessage(), e);
             }
-            if (Graph.class.isAssignableFrom(graphOrGraphComputerClass)) {
-                final TraversalStrategies traversalStrategies = GRAPH_CACHE.get(graphOrGraphComputerClass);
-                return null == traversalStrategies ? GRAPH_CACHE.get(Graph.class) : traversalStrategies;
+            
+            if (GRAPH_CACHE.containsKey(graphOrGraphComputerClass)) {
+                return GRAPH_CACHE.get(graphOrGraphComputerClass);
+            } else if (Graph.class.isAssignableFrom(graphOrGraphComputerClass)) {
+                return GRAPH_CACHE.get(Graph.class);
+            } else if (GRAPH_COMPUTER_CACHE.containsKey(graphOrGraphComputerClass)) {
+                return GRAPH_COMPUTER_CACHE.get(graphOrGraphComputerClass);
             } else if (GraphComputer.class.isAssignableFrom(graphOrGraphComputerClass)) {
-                final TraversalStrategies traversalStrategies = GRAPH_COMPUTER_CACHE.get(graphOrGraphComputerClass);
-                return null == traversalStrategies ? GRAPH_COMPUTER_CACHE.get(GraphComputer.class) : traversalStrategies;
+                return GRAPH_COMPUTER_CACHE.get(GraphComputer.class);
             } else {
                 throw new IllegalArgumentException("The TraversalStrategies.GlobalCache only supports Graph and GraphComputer strategy caching: " + graphOrGraphComputerClass.getCanonicalName());
             }


[3/5] tinkerpop git commit: Merge branch 'js-doc-example' into tp32

Posted by sp...@apache.org.
Merge branch 'js-doc-example' into tp32


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

Branch: refs/heads/TINKERPOP-1950
Commit: c155818793c38a144edfa5bc803284ff82c2e8ca
Parents: 268423d e08651b
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Apr 24 10:39:17 2018 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Tue Apr 24 10:39:17 2018 +0200

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc | 47 +++++++++++++++++------
 1 file changed, 36 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[2/5] tinkerpop git commit: Improve JavaScript Gremlin documentation

Posted by sp...@apache.org.
Improve JavaScript Gremlin documentation

Several fixes to the JavaScript GLV documentation:
- Use 'gremlin' package name
- Include information regarding Promises
- Fix method names


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

Branch: refs/heads/TINKERPOP-1950
Commit: e08651b946e936579db538f9114dd1c5c9079bcb
Parents: 2591302
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Apr 23 10:26:36 2018 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Mon Apr 23 10:26:36 2018 +0200

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc | 47 +++++++++++++++++------
 1 file changed, 36 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e08651b9/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index d929b3c..7a85ab1 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -458,17 +458,24 @@ their Java counterparts which makes it possible to use lambdas with Gremlin.Net
 == Gremlin-JavaScript
 
 image:gremlin-js.png[width=130,float=right] Apache TinkerPop's Gremlin-JavaScript implements Gremlin within the
-JavaScript language. It targets Node.js runtime and can be used on different operating systems on any Node.js 4 or
+JavaScript language. It targets Node.js runtime and can be used on different operating systems on any Node.js 6 or
 above. Since the JavaScript naming conventions are very similar to that of Java, it should be very easy to switch
 between Gremlin-Java and Gremlin-JavaScript.
 
 [source,bash]
-npm install gremlin-javascript
+npm install gremlin
 
 The Gremlin-JavaScript provides `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes
 in Gremlin-Java. The `GraphTraversalSource` requires a RemoteConnection implementation in order to communicate with
 <<gremlin-server,GremlinServer>>.
 
+[source,javascript]
+----
+const gremlin = require('gremlin');
+const Graph = gremlin.structure.Graph;
+const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
+----
+
 A traversal source can be spawned with `RemoteStrategy` from an empty `Graph`.
 
 [source,javascript]
@@ -489,27 +496,45 @@ IMPORTANT: Gremlin-JavaScript’s `Traversal` base class supports the standard G
 
 === RemoteConnection Submission
 
-Very similar to Gremlin-Python and Gremlin-Java, there are various ways to submit a traversal to a
-`RemoteConnection` using terminal/action methods off of `Traversal`.
+In a similar way as in other GLVs, there are various ways to submit a traversal to a
+`RemoteConnection` using terminal/action methods off of `Traversal`. Given that I/O operations in Node.js are
+asynchronous by default, this terminal methods return a `Promise`.
 
-* `Traversal.next()`
-* `Traversal.toList()`
+* `Traversal.toList()`: Returns a `Promise` with an `Array` as result value.
+* `Traversal.next()`: Returns a `Promise` with a `{ value, done }` tuple as result value, according to the
+link:https://github.com/tc39/proposal-async-iteration[async iterator proposal].
+* `Traversal.iterate()`: Returns a `Promise` without a value.
+
+
+For example:
+
+[source,javascript]
+----
+g.V().hasLabel('person').values('name').toList()
+  .then(names => console.log(names));
+----
+
+You can `await` the promises if you are using `async` functions.
+
+[source,javascript]
+----
+const names = await g.V().hasLabel('person').values('name').toList();
+console.log(names);
+----
 
 === Static Enums and Methods
 
 Gremlin has various tokens (e.g. `t`, `P`, `order`, `direction`, etc.) that are represented in Gremlin-JavaScript as
 objects.
 
-These can be used analogously to how they are used in Gremlin-Java.
-
 [source,javascript]
-g.V().hasLabel("person").has("age",P.gt(30)).Order().By("age", order.decr).toList()
+g.V().hasLabel('person').has('age', P.gt(30)).order().by('age', order.decr).toList()
 
 These objects must be required manually from the `process` namespace:
 
 [source,javascript]
 ----
-const gremlin = require('gremlin-javascript');
+const gremlin = require('gremlin');
 const P = gremlin.process.P;
 ----
 
@@ -517,7 +542,7 @@ Finally, using static `__` anonymous traversals like `__.out()` can be expressed
 
 [source,javascript]
 ----
-const gremlin = require('gremlin-javascript');
+const gremlin = require('gremlin');
 const __ = gremlin.process.statics;
 
 g.V().repeat(__.out()).times(2).values("name").fold().toList();