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

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

The interface is mostly used as a proof of concept that the new class - 
ModernNamedList implements the same methods as that of NamedList. Eventually - 
the interface would be gotten rid of , once we are happy with the same. 

As far as NamedList , I believe if we want to have the flexibility of allowing 
any type in it - we might as well define it to an Object. If we do qualify it 
as a specific type - then we might as well implement type-safety in the class. 
javac does not complain today because the compiler switch to indicate 
type-safety errors has been turned off.

Previous implementation used to be having a pre-jdk5 List , with members being 
String and a type depending on the index. The revised implementation has 
Map.Entry<String, T> interface - which is directly intuitive to what is 
required ( a Map with order being preserved , allowing duplicates and nulls ).  
I did profile with 2 different implementations , involving Map.Entry<?> and a 
heterogenous list with String and a type (with insertion / deletion of 100,000 
records). The current implementation in fact , failed in the performance 
comparison in both insertion / deletion in the middle of the List ( remove () ) 
, since we have to add/remove elements twice from the List (as in the current 
impl) , as compared to 1 insertion/deletion in the Map.Entry<> implementation. 
) Given that addition/deletion in the List is worst-case linear - I believe the 
perceived performance degradation due to additional object , turns out to be 
not so bad when compared to 2-path insertion / deletion as we have today. 

NamedList does seem to implement the interface Iterable<T> . I am not sure how 
the consumer of the API can have independent iterators (since only NamedList is 
supposed to be aware of the internal data structures and not the consumer). So 
I believe it would be upto NamedList<T> to provide an iterator to the user of 
the API. 

> 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: clients - java
>    Affects Versions: 1.4
>         Environment: Tomcat 6, JRE 6, Solr 1.3+ nightlies 
>            Reporter: Kay Kay
>            Priority: Minor
>             Fix For: 1.3.1
>
>         Attachments: 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