[Biojava-dev] HashMap ==> LinkedHashMap in HashSequenceDB

Andreas Prlic andreas at sdsc.edu
Mon Nov 16 17:40:15 UTC 2009


Talking about Map implementations... I recently added
org.biojava.utils.io.SoftHashMap

It can be used to create temporary in-memory caches. It allows the
Garbage Collector to clean up objects, and one does not have to take
care of removing the objects from the cache. I use it  to cache small
files that are more efficiently read from the memory, rather than
going to the hard disk (or NFS...)

The code is based on
http://java-interview-faqs.blogspot.com/2008/09/building-faster-and-efficient-cache.html

Andreas






On Mon, Nov 16, 2009 at 6:59 AM, Richard Holland
<holland at eaglegenomics.com> wrote:
> Sounds like a plan - are there any performance implications?
>
> On 16 Nov 2009, at 14:53, Matias Piipari wrote:
>
>> Hello
>>
>> I'd like to propose a change to org.biojava.bio.seq.db.HashSequenceDB: swap
>> the map implementation used to store the sequence-by-id map from HashMap to
>> LinkedHashMap. This would allow iterating the sequences in a defined order
>> (the order in which they were added to the map).
>>
>> Best wishes
>> Matias
>>
>>
>> An example patch relative to rev 7059:
>>
>> --- src/org/biojava/bio/seq/db/HashSequenceDB.java      (revision 7059)
>> +++ src/org/biojava/bio/seq/db/HashSequenceDB.java      (working copy)
>> @@ -22,8 +22,8 @@
>> package org.biojava.bio.seq.db;
>>
>> import java.io.Serializable;
>> -import java.util.HashMap;
>> import java.util.Iterator;
>> +import java.util.LinkedHashMap;
>> import java.util.Map;
>> import java.util.Set;
>>
>> @@ -203,6 +203,6 @@
>>   public HashSequenceDB(org.biojava.bio.seq.db.IDMaker idMaker, String
>> name) {
>>     this.idMaker = idMaker;
>>     this.name = name;
>> -    this.sequenceByID = new HashMap();
>> +    this.sequenceByID = new LinkedHashMap();
>>   }
>> }
>> _______________________________________________
>> biojava-dev mailing list
>> biojava-dev at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/biojava-dev
>
> --
> Richard Holland, BSc MBCS
> Operations and Delivery Director, Eagle Genomics Ltd
> T: +44 (0)1223 654481 ext 3 | E: holland at eaglegenomics.com
> http://www.eaglegenomics.com/
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-dev
>




More information about the biojava-dev mailing list