[ 
https://issues.apache.org/jira/browse/TINKERPOP-1589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15839812#comment-15839812
 ] 

ASF GitHub Bot commented on TINKERPOP-1589:
-------------------------------------------

GitHub user pauljackson opened a pull request:

    https://github.com/apache/tinkerpop/pull/548

    TINKERPOP-1589 Re-introduced CloseableIterator

    https://issues.apache.org/jira/browse/TINKERPOP-1589
    
    Add support for the closing of `Iterators` returned from
    `Vertex.vertices()` and `Vertex.edges()`.
    Iterators are closed once they are read to completion.
    Make `FlatMapStep` implement `AutoCloseable` in case iterator is not
    read to completion, should get closed when Traversal is closed.
    Remove unnecessary null check (null is never an instanceof).
    OLTP mode support only. More extensive changes required for OLAP.
    NOTE: Rethrowing checked Exception from `close()` as unchecked
    RuntimeException in order to retain `Step.reset()` and
    `AbstractStep.processNextStart()` signature.
    Fix bug in last commit where iterator is not set to
    EMPTY_ITERATOR for iterators that are not Closeable.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/pauljackson/tinkerpop tp32

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tinkerpop/pull/548.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #548
    
----
commit c8d5ff9db6ec8908abfad434c4fb339c5ad53468
Author: PaulJackson123 <pauljackson...@verizon.net>
Date:   2017-01-26T01:43:22Z

    TINKERPOP-1589 Re-introduced CloseableIterator
    
    https://issues.apache.org/jira/browse/TINKERPOP-1589
    Add support for the closing of Iterators returned from
    Vertex.vertices() and Vertex.edges().
    Iterators are closed once they are read to completion.
    Make FlatMapStep implement AutoCloseable in case iterator is not
    read to completion, should get closed when Traversal is closed.
    Remove unnecessary null check (null is never an instanceof).
    OLTP mode support only. More extensive changes required for OLAP.
    NOTE: Rethrowing checked Exception from close() as unchecked
    RuntimeException in order to retain Step.reset() and
    AbstractStep.processNextStart() signatured.

commit c2d183acf4418733666d1cd603f15a87beb9aa97
Author: PaulJackson123 <pauljackson...@verizon.net>
Date:   2017-01-26T14:52:30Z

    TINKERPOP-1589 Re-introduced CloseableIterator
    
    https://issues.apache.org/jira/browse/TINKERPOP-1589
    Add support for the closing of Iterators returned from
    Vertex.vertices() and Vertex.edges().
    Iterators are closed once they are read to completion.
    Make FlatMapStep implement AutoCloseable in case iterator is not
    read to completion, should get closed when Traversal is closed.
    Remove unnecessary null check (null is never an instanceof).
    OLTP mode support only. More extensive changes required for OLAP.
    NOTE: Rethrowing checked Exception from close() as unchecked
    RuntimeException in order to retain Step.reset() and
    AbstractStep.processNextStart() signatured.
    Fix bug in last commit where iterator is not set to
    EMPTY_ITERATOR for iterators that are not Closeable.

----


> Re-Introduce CloseableIterator
> ------------------------------
>
>                 Key: TINKERPOP-1589
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1589
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: structure
>    Affects Versions: 3.2.3
>            Reporter: stephen mallette
>            Assignee: stephen mallette
>             Fix For: 3.2.4
>
>
> In Blueprints, we used to have {{CloseableIterable}}, which allowed users to 
> release resources that might have been held by the underlying graph database. 
> We didn't port that interface to TinkerPop 3.x for some reason. Graphs like 
> OrientDB require a {{close()}} method for iterators returned from methods 
> like {{Graph.vertices()}} and {{Graph.edges()}}. In addition, allowing 
> {{close()}} from those iterators would make the {{close()}} on {{Traversal}} 
> (non-remote) more useful and meaningful (right now it is an empty method by 
> default). 
> In Blueprints, {{Graph.getVertices()}} and {{Graph.getEdges()}} returned a 
> {{Iterable}} and the Graph could choose to return {{CloseableIterator}}. 
> Users who wanted to write provider agnostic code would then have to do:
> {code}
> if (iterable instanceof CloseableIterable))
>   ((CloseableIterable) iterable).close();
> {code}
> I'm not sure why we didn't simply return {{CloseableIterable}} from those 
> methods. Any reason we shouldn't do that now? Perhaps the approach is to 
> introduce {{CloseableIterator}} to 3.2.4, but keep the return type of 
> {{edges/vertices()}} as {{Iterator}} and then for 3.3.0 change the return 
> type to {{CloseableIterator}}. In this way, the feature can be available in 
> next release of 3.2.4 without any API changes and users can do the 
> {{instanceof}} check above if they need to. Then for 3.3.0 when we allow API 
> changes we can just make it more convenient with a {{CloseableIterator}} 
> return type.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to