https://issues.apache.org/jira/browse/TINKERPOP-1589

Add support for the closing of Iterators returned from
`Vertex.vertices()` and `Vertex.edges()`.
Make `FlatMapStep` close iterator after read to completion.
Make `EdgeVertexStep`, `PropertiesStep`, `VertexStep`
`AutoCloseable` in case iterator is not read to completion
to ensure closed when Traversal is closed.
OLTP mode support only. More extensive changes required for OLAP.
Rearrange `closeIterator()` and `this.starts.next()`


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

Branch: refs/heads/TINKERPOP-1599
Commit: 020317621e62ab1f0736878694f375517ac1d385
Parents: 4944966
Author: PaulJackson123 <[email protected]>
Authored: Wed Feb 1 14:53:42 2017 -0500
Committer: PaulJackson123 <[email protected]>
Committed: Wed Feb 1 14:53:42 2017 -0500

----------------------------------------------------------------------
 .../gremlin/process/traversal/step/map/FlatMapStep.java        | 2 +-
 .../gremlin/process/traversal/step/map/GraphStep.java          | 6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/02031762/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
index 59fc4e7..7bdd4a5 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
@@ -44,8 +44,8 @@ public abstract class FlatMapStep<S, E> extends 
AbstractStep<S, E> {
             if (this.iterator.hasNext()) {
                 return this.head.split(this.iterator.next(), this);
             } else {
-                this.head = this.starts.next();
                 closeIterator();
+                this.head = this.starts.next();
                 this.iterator = this.flatMap(this.head);
             }
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/02031762/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GraphStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GraphStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GraphStep.java
index e6b2c38..03a0bc4 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GraphStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GraphStep.java
@@ -169,10 +169,8 @@ public class GraphStep<S, E extends Element> extends 
AbstractStep<S, E> implemen
      * be released at some point.
      */
     @Override
-    public void close() throws Exception {
-        if (iterator instanceof CloseableIterator) {
-            ((CloseableIterator) iterator).close();
-        }
+    public void close() {
+        CloseableIterator.closeIterator(iterator);
     }
 
     /**

Reply via email to