You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Kay Kay (JIRA)" <ji...@apache.org> on 2009/01/19 18:53:59 UTC

[jira] Commented: (SOLR-967) NamedList - Deprecating ctor. with heterogenous List and replacing with a type-safe variant.

    [ https://issues.apache.org/jira/browse/SOLR-967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12665165#action_12665165 ] 

Kay Kay commented on SOLR-967:
------------------------------

|    1.  add an "Entry<String, T>[]" constructor (with a warning, but no commitment, that modifying the array contents may affect the NamedList) which builds up a pairwise List<Object> and delegates to the existing "List" constructor

Once we build a pairwise List<Object> and delegate to the external "List" ctor , I am not sure how we can give a 'partial' guarantee that modifying the array affecting NamedList since we are essentially flattening the former data structure (Map.Entry<String, T> ) into the latter ( String key; T value; } 

So - I have added documentation such a way that the guarantee is not possible.  


|    2. deprecate the existing List constructor.

In addition to deprecating the existing ctor. the comment has also been modified such that the external modification guarantee would not be held again in the future implementations and users are advised to use add / remove etc. for the modification as opposed to changing the data structure without the knowledge of the class. 

 In fact-  if we eventually bring back List < Map.Entry<String, ? > > , the external modification guarantee might be honored although I am not sure if that is a big development plus as providing multiple ways to modify the underlying data structure might be hard to track in the code. 

Let me know if this patch would provide the intended transition. 


> NamedList - Deprecating ctor. with heterogenous List and replacing with a type-safe variant. 
> ---------------------------------------------------------------------------------------------
>
>                 Key: SOLR-967
>                 URL: https://issues.apache.org/jira/browse/SOLR-967
>             Project: Solr
>          Issue Type: Improvement
>         Environment: Java 6, Tomcat 6
>            Reporter: Kay Kay
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: SOLR-967.patch
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> NamedList (org/apache/solr/common/util/NamedList ) currently has a heterogenous List (even numbered indices are String-s ) and the odd-numbered indices are the specific types.  As per benchmarks ( see SOLR-912 ) - the implementation could be improved in favor of a Map.Entry<String, T> that beats in performance and ease of code maintenance. 
> As per the discussion in SOLR-912 , a separate issue in JIRA is created that temporarily deprecates the List ctor. in NamedList and replaces the same with a Map.Entry<String, T> [] arg. constructor . 
> This would be go in 1.4 to enable people to migrate their code for the new ctor. and move away from List<?> . 
> At a later version of Solr (may be v2) - the optimal implementation would be brought back in with the List <Map.Entry<String, ?> > for better type-safety and performance. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.