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

Kay Kay commented on SOLR-912:
------------------------------

|  We also need to make sure we don't eliminate any public constructors, which 
seems to be the case based on my quick glance at the latest patch. 


<code>
-   public NamedList(List nameValuePairs) {
-   nvPairs=nameValuePairs;
+  protected NamedList(List<Map.Entry<String, T>> nameValuePairs) {
+    nvPairs = nameValuePairs;
-   }
</code>

As part of ensuring type-safety , the previous code had a heterogenous List 
ctor. as before.  I changed the access level and added another public ctor.  ( 
Object [] ) with deprecated tag to it so that people are still able to use the 
functionality. 

Otherwise - retaining the same signature after type safety would imply - people 
passing in a List of String-s and T-s , when the List expects Map.Entry<String 
, T > and would cause more confusion. 

Thanks to the erasure of generics , List and List<Map.Entry<String, T>> are all 
equal , not helping here. 
If backward compatibility is the key here-  I can revisit the patch again 
ensuring the same. 


| If there are performance gains to be had in the common case i'm all for it 
... but i still feel like i'm not understanding the original goal: how does 
this approach give us more type safety? 

When I logged the issue - type-safety was the major reason behind the same. 
When I submitted by first patch and did the benchmarking - performance was also 
found to be a major constraint , (with incremental addition and creation of 
iterator objects).  NamedList seemed to be used all over the place. As long as 
we preserve the contract of the methods - this should definitely give an 
additional boost - since I discovered as part of profiling of the launch of 
SolrCore ( CoreContainer.Initializer.initalize() .. ) . 




> org.apache.solr.common.util.NamedList - Typesafe efficient variant - 
> ModernNamedList introduced - implementing the same API as NamedList
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-912
>                 URL: https://issues.apache.org/jira/browse/SOLR-912
>             Project: Solr
>          Issue Type: Improvement
>          Components: search
>    Affects Versions: 1.4
>         Environment: Tomcat 6, JRE 6, Solr 1.3+ nightlies 
>            Reporter: Kay Kay
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: NLProfile.java, SOLR-912.patch, SOLR-912.patch
>
>   Original Estimate: 72h
>  Remaining Estimate: 72h
>
> The implementation of NamedList - while being fast - is not necessarily 
> type-safe. I have implemented an additional implementation of the same - 
> ModernNamedList (a type-safe variation providing the same interface as 
> NamedList) - while preserving the semantics in terms of ordering of elements 
> and allowing null elements for key and values (keys are always Strings , 
> while values correspond to generics ). 

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

Reply via email to