You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (Jira)" <ji...@apache.org> on 2021/08/23 09:25:00 UTC

[jira] [Comment Edited] (JENA-2151) Iter.filter does not close nested iterator

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

Andy Seaborne edited comment on JENA-2151 at 8/23/21, 9:24 AM:
---------------------------------------------------------------

The link is to a 2 line change in `StageMatchTriple` needed to modify 4.1.0.

You did a change for the `IteratorFilter`. This is no harder. (You didn't run the build for `IteratorFilter` - it doesn't build.)

Replace:
{code:java}
        Iterator<Binding> iter = graphIter.mapWith( r -> mapper(resultsBuilder, s, p, o, r));
        //Iterator<Binding> iter = Iter.map(graphIter, r -> mapper(resultsBuilder, s, p, o, r));
        return Iter.removeNulls(iter);
{code}
with
{code:java}
        ExtendedIterator<Binding> iter = graphIter.mapWith( r -> mapper(resultsBuilder, s, p, o, r)).filterDrop(Objects::isNull);
        return iter;
{code}
Or:
 The whole, short commit (not the rest of the PR) for this JIRA is specifically setup so it is easy for you to pick up.

There is a significant change on PR#1030 that gets rid of a lot of tech debt that will go in immediately after the 4.2.0 release.


was (Author: andy.seaborne):
The link is to a 2 line change in `StageMatchTriple` needed to modify 4.1.0. 

You did a change for the `IteratorFilter`. This is no harder. (You didn't run the build for `IteratorFilter` - it doesn't build.)

Replace:
```
        Iterator<Binding> iter = graphIter.mapWith( r -> mapper(resultsBuilder, s, p, o, r));
        //Iterator<Binding> iter = Iter.map(graphIter, r -> mapper(resultsBuilder, s, p, o, r));
        return Iter.removeNulls(iter);
```
with
```
        ExtendedIterator<Binding> iter = graphIter.mapWith( r -> mapper(resultsBuilder, s, p, o, r)).filterDrop(Objects::isNull);
        return iter;
```

The whole, short commit for this JIRA is specifically so it is easy for you to pick up.

There is a significant change on PR#1030 that gets rid of a lot of tech debt that will go in immediately after the 4.2.0 release.


> Iter.filter does not close nested iterator
> ------------------------------------------
>
>                 Key: JENA-2151
>                 URL: https://issues.apache.org/jira/browse/JENA-2151
>             Project: Apache Jena
>          Issue Type: Bug
>    Affects Versions: Jena 4.1.0
>            Reporter: Holger Knublauch
>            Priority: Major
>         Attachments: IteratorFilter.java
>
>
> We recently attempted to upgrade our product to Jena 4.1.0 but noticed unclosed iterator warnings. I believe I have tracked it down to the fact that Iter.filter does not return a Closeable iterator and therefore does not close its nested (stream) iterator. I am attaching an implementation class that seems to fix it. With this, org.apache.jena.atlas.iterator.Iter.filter simply need to become
> {code:java}
>     public static <T> Iterator<T> filter(final Iterator<? extends T> stream, final Predicate<T> filter) {
>         return new IteratorFilter<T>(stream, filter);
>     }
> {code}
> (Although Iter.filter hasn't changed for a while, I suspect some other changes to Jena caused the SPARQL engine to use it, and this has broken some scenarios for us - in particular calling SPIN/SHACL-SPARQL functions with BGPs in the WHERE clause).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)