You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2015/06/05 21:35:00 UTC

[jira] [Resolved] (LUCENE-5805) QueryNodeImpl.removeFromParent does a lot of work without any effect

     [ https://issues.apache.org/jira/browse/LUCENE-5805?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-5805.
----------------------------------------
       Resolution: Fixed
    Fix Version/s: 5.3
                   Trunk

Thanks Christoph and [~caomanhdat]!

> QueryNodeImpl.removeFromParent does a lot of work without any effect
> --------------------------------------------------------------------
>
>                 Key: LUCENE-5805
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5805
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/queryparser
>    Affects Versions: 4.7.2, 4.9
>            Reporter: Christoph Kaser
>            Assignee: Michael McCandless
>             Fix For: Trunk, 5.3
>
>         Attachments: LUCENE-5805.patch
>
>
> The method _removeFromParent_ of _QueryNodeImpl_, calls _getChildren_ on the parent and removes any occurrence of "this" from the result.
> However, since a few releases, _getChildren_ returns a *copy* of the children list, so the code has no effect (except creating a copy of the children list which will then be thrown away). 
> Even worse, since _setChildren_ calls _removeFromParent_ on any previous child, _setChildren_ now has a complexity of O(n^2) and creates a lot of throw-away copies of the children list (for nodes with a lot of children)
> {code}
> public void removeFromParent() {
>     if (this.parent != null) {
>       List<QueryNode> parentChildren = this.parent.getChildren();
>       Iterator<QueryNode> it = parentChildren.iterator();
>       
>       while (it.hasNext()) {
>         if (it.next() == this) {
>           it.remove();
>         }
>       }
>       
>       this.parent = null;
>     }
>   }
> {code}



--
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