lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Why doesn't Document use a HashSet instead of a LinkedList (DocumentFieldList)
Date Tue, 07 Sep 2004 16:56:03 GMT
Kevin A. Burton wrote:
> It looks like Document.java uses its own implementation of a LinkedList..
> 
> Why not use a HashMap to enable O(1) lookup... right now field lookup is 
> O(N) which is certainly no fun.
> 
> Was this benchmarked?  Perhaps theres the assumption that since 
> documents often have few fields the object overhead and hashcode 
> overhead would have been less this way.

I have never benchmarked this but would be surprised if it makes a 
measureable difference in any real application.  A linked list is used 
because it naturally supports multiple entries with the same key.  A 
home-grown linked list was used because, when Lucene was first written, 
java.util.LinkedList did not exist.

Please feel free to benchmark this against a HashMap of LinkedList of 
Field.  This would be slower to construct, which may offset any 
increased access speed.

Doug

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


Mime
View raw message