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

Andy Seaborne commented on JENA-966:
------------------------------------

In {{Unparser.listSubjects}} the iterator {{firstChoiceCyclic}} is setup with:

{noformat}
Iterator<Resource> firstChoiceCyclic = allInfiniteLeft()
                                .filterKeep(r -> {
                                        codeCoverage[4]++;
                                        if (r.isAnon())
                                                return false;
                                        Integer cnt = objectTable.get(r);
                                        if (cnt == null || cnt.intValue() <= 1)
                                                return false;
                                        return true;
                                });
{noformat}

{{allInfiniteLeft}} with the old code, {{LateBindingIterator}} calls 
{{NiceIterator.filterKeep}} which itself creates a {{FilterIterator}} and the 
unlazy operation is first called at the "hasNext" stage - i.e. first use in the 
iterator of iterators, and after {{fakeLazyEvaluator}} which is the 
initialization of {{infinite}}.

{{allInfiniteLeft} with the new code, {{LazyIterator}} calls the unlazy 
operation during {{LazyIterator.filterKeep}} hence it's called at setup time 
assigning to {{firstChoiceCyclic}}.

Temporary fix applied to {{LazyIterator}} : the NiceIterator code for 
filterKeep, filterDrop copied to LazyIterator.

NB It looks like {{LazyIterator.mapWith}} is also wrong. Fix applied for 
review. It uses {Map1Iterator}}.

Possible proper solutions:

# {{LazyIterator}} extends {{NiceIterator}} and only override hasNext, next, 
remove.
# Drop {{LazyIterator}}, use {{LateBindingIterator}} (renamed?)
# Drop both, put a copy of {{LateBindingIterator}} into package-scoped in the 
unparser package as {{UnparserLateBindingIterator}} for unparser use only.

Comments?

> LazyIterator
> ------------
>
>                 Key: JENA-966
>                 URL: https://issues.apache.org/jira/browse/JENA-966
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: Jena 3.0.0
>            Reporter: Claude Warren
>            Assignee: Claude Warren
>
> LazyIterator is an abstract class.  The documentation indicates that the 
> create() method needs to be overridden to create an instance.  From this I 
> would expect that 
> now LazyIterator(){
> @Override
> public ExtendedIterator<Model> create() {
>                       ...
> }};
> Would work however LazyIterator does not override:
> remoteNext(), andThen(), toList(), and toSet().
> I believe these should be implemented in the class.



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

Reply via email to