You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/06/23 01:46:41 UTC

incubator-tinkerpop git commit: added Traversal.toStream() which turns Traversal into a Stream.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 7e5428235 -> 707ea2fe7


added Traversal.toStream() which turns Traversal<S,E> into a Stream<E>.


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

Branch: refs/heads/master
Commit: 707ea2fe755d923c60cc9d3d0ece9b02d31242d6
Parents: 7e54282
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Jun 22 17:46:36 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Jun 22 17:46:36 2015 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../gremlin/process/traversal/Traversal.java    | 22 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/707ea2fe/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index f6f5ad7..05eed4d 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::http://www.tinkerpop.com/docs/current/images/gremlin-hindu.png[width=225]
 TinkerPop 3.0.0.GA (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Added `Traversal.toStream()` to turn the `Traversal<S,E>` into a `Stream<E>`.
 * Added `Scoping.Variable` enum of `START` and `END` which allows the `Scoping` step to specify where its bindings are.
 * `ComputerVerificationStrategy` is smart about not allowed `WhereStep` with a start-variable to run in OLAP as it selects the value from the path.
 * Rewrote `MatchStep` where it now works on `GraphComputer`, solves more patterns, provides plugable execution plans, supports nested AND/OR, not-patterns, etc.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/707ea2fe/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
index 315ca4f..735c537 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
@@ -30,9 +30,20 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 
 import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.Spliterators;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 
 /**
  * A {@link Traversal} represents a directed walk over a {@link Graph}.
@@ -111,6 +122,15 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable {
     }
 
     /**
+     * Return the traversal as a {@link Stream}.
+     *
+     * @return the traversal as a stream.
+     */
+    public default Stream<E> toStream() {
+        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, Spliterator.IMMUTABLE | Spliterator.SIZED), false);
+    }
+
+    /**
      * Add all the results of the traversal to the provided collection.
      *
      * @param collection the collection to fill