[
https://issues.apache.org/jira/browse/LUCENE-6365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14373083#comment-14373083
]
Markus Heiden commented on LUCENE-6365:
---------------------------------------
I prefer a "standard" Iterator too. But by implementing it, my implementation
loses some of its benefits, because an iterator needs a look-ahead for
hasNext().
I chose the current implementation because:
1) I can reuse the iterator for different iterations (similar to Transition):
See AnalyzingSuggester. So e.g. the internal stack does not need to be
reallocated. This avoids not just the initial allocation, but the resizes
during the iterations too. BTW: May we choose a bigger initial size for the
stack?
2) By avoiding a look-ahead, my implementation can return the internal IntRefs
(from the used IntsRefBuilder) in next(), without the need for a deep copy.
> Optimized iteration of finite strings
> -------------------------------------
>
> Key: LUCENE-6365
> URL: https://issues.apache.org/jira/browse/LUCENE-6365
> Project: Lucene - Core
> Issue Type: Improvement
> Components: core/other
> Affects Versions: 5.0
> Reporter: Markus Heiden
> Priority: Minor
> Labels: patch, performance
> Attachments: FiniteStringsIterator.patch
>
>
> Replaced Operations.getFiniteStrings() by an optimized FiniteStringIterator.
> Benefits:
> Avoid huge hash set of finite strings.
> Avoid massive object/array creation during processing.
> "Downside":
> Iteration order changed, so when iterating with a limit, the result may
> differ slightly. Old: emit current node, if accept / recurse. New: recurse /
> emit current node, if accept.
> The old method Operations.getFiniteStrings() still exists, because it eases
> the tests. It is now implemented by use of the new FiniteStringIterator.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]