Balaram26
Balaram26

Reputation: 1389

How to store HashMap values separately in scala?

I have a scala hashmap which is generated by one app and used by another. The hashmap is big,like 100MB of size or more.

var actMap = new collection.mutable.HashMap[String, Seq[Object]];

Currently the whole map is loaded in the memory by the second app when it starts.I am trying to just load the keys in the memory and later when looking for key in the map,it should give the value which is stored in the disk. Is there anyway to achieve this? Individually saving every value and accessing them on the fly would take lot of time if standard serialization is used. What are the alternatives?

Upvotes: 3

Views: 324

Answers (1)

bearrito
bearrito

Reputation: 2316

You might want to think about using memory mapped files for this. You could roll your own.

Assuming you can change your interface slightly and use 3rd party libraries you could look at

http://software.clapper.org/javautil/api/org/clapper/util/misc/FileHashMap.html

https://github.com/bmc/javautil/blob/master/src/main/java/org/clapper/util/misc/FileHashMap.java

Upvotes: 3

Related Questions