Reputation: 9
I am working on a project and I end up with a large hashmap, and now i am trying to sort it by values.
ArrayList<Map.Entry<String, Integer>> entries = new ArrayList<Map.Entry<String, Integer>>(BloomFilter.map.entrySet());
But when I do this, I get an OutOfMemoryError.
Is there any way to prevent this?
Edit:This my if it's in the bloomfilter function
hash1 = MurmurHash2.hash32(genom);
hash2 = genom.hashCode();
inList = true;
for (int i = 0; i < k-1 ; i++) {
hashedGenom = ( hash1 + hash2 * i) % a.size();
hashedGenom = CheckForNegative(hashedGenom);
if(!(a.get(hashedGenom))){
a.set(hashedGenom);
inList = false;
}
}
return inList;
This is my where im doing bloom filter:
if(CheckIfThere(s, k, fBitset)){
// System.out.println("var");
val = map.get(s);
if(val != null){
map.put(s, map.get(s) + 1);
//map.remove(s);
//map.put(s, new Integer(val + 1));
}else{
map.put(s,1);
}
I am basically, getting the string and send it to CheckIfThere and if it gets true i am putting it to hashmap.
Upvotes: 1
Views: 224
Reputation: 101
there are several algorithm to resolve it
but i think the easiest way is using database.
you can insert all the values into mysql/oracle/sql server/postgres ... and then
select xxxx from xxx order by xxx
if you worried about the database is big and hard to deploy, have a try of sqlite
Upvotes: 1