You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Markus Heiden (JIRA)" <ji...@apache.org> on 2014/09/17 18:19:34 UTC

[jira] [Comment Edited] (LUCENE-5959) Optimized memory management in Automaton.Builder.finish()

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

Markus Heiden edited comment on LUCENE-5959 at 9/17/14 4:18 PM:
----------------------------------------------------------------

A better approach would be to create the Automaton with the correct size in Builder.finish() instead of creating it in the constructor with a default size. But I can't do that, because the states have already been added the automaton at that point.

I may directly allocate 
a.transitions = new int[numTransitions * 4]; 
in Builder.finish(), but this looks a bit dirty to me. The overhead of the approach in the patch should be negligible.


was (Author: markus_heiden):
A better approach would be to create the Automaton with the correct size in Builder.finish() instead of creating it in the constructor with a default size. But I don't know if there may be changes to Builder.a prior to calling Build.finish(), so I choose that safe approach in the patch.

> Optimized memory management in Automaton.Builder.finish()
> ---------------------------------------------------------
>
>                 Key: LUCENE-5959
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5959
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/other
>    Affects Versions: 4.10
>            Reporter: Markus Heiden
>            Priority: Minor
>              Labels: patch
>         Attachments: finish.patch
>
>
> Reworked Automaton.Builder.finish() to not allocate memory stepwise. Added growTransitions(int numTransitions) to be able to resize the transistions array just once.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org