Large map with string key and arraylist of custom java Objects as values - most optimal mapdb solution ?

414 views
Skip to first unread message

pushkala jayaraman

unread,
Aug 2, 2017, 12:01:56 PM8/2/17
to MapDB
Hello, 

before, i begin, i would like to thank you for providing a java based solution for storage of really large memory intensive data structures :)

I'm new to MapDB, and I'm trying to store data into a huge hashmap which looks like this:
LinkedHashMap<String, List<OligoObject>>

I assumed i use the mapdb equivalent : 
        DB db2 = DBMaker.tempFileDB().fileDeleteAfterClose().make();
        HTreeMap<String, List<OligoObject>> allPairsObjectsMapMapdb = db2.hashMap("allPairsObjectsMapMapdb").keySerializer(new SerializerCompressionWrapper(Serializer.STRING)).createOrOpen();

this map does contain arraylist of objects as values to a string key. How would i append to the list? and is this the most optimal way to do this?
would it be possible, to simply append to the existing arraylist of values and then "put" the new appended list to the same string key? or woudl it be faster in Mapdb to store all custom objects as a separate map with unique keys and then store string, arraylist of those unique keys ?

how would i implement it? i would imagine this is a very common requirement. 
what mapdb structure would i use? the reaosn i ask is because, i dont see examples for it in the forum.. 

Regards,
Pushkala

Ramesh M

unread,
Mar 28, 2019, 3:59:28 PM3/28/19
to MapDB
I am also want to use MapDB exact similar requirement, how you used it ?

1

I want to use mapDb to store List object syntax wise not throwing any error, but after getting data for map getting class cast exception. but I do see below warnings in eclipse: Multiple markers at this line

  • Type safety: The expression of type HTreeMap needs unchecked
    conversion to conform to ConcurrentMap>.
  • Type safety: The expression of type GroupSerializer needs unchecked
    conversion to conform to Serializer.
  • Type safety: Unchecked invocation hashMap(String, GroupSerializer, GroupSerializer) of the generic method hashMap(String, Serializer, Serializer) of type DB.

below is the code.

DB db = DBMaker.fileDB("file.db").fileMmapEnable().make();
ConcurrentMap<String,List<Employee>> map = db.hashMap("map", Serializer.STRING, Serializer.JAVA).createOrOpen();
List<Employee> employees = new ArrayList<Employee>(); 
map.put("2019_JAN", employees );
map.put("2019_FEB", employees ); 
db.commit();
db.close();

not use where I am doing wrong, your inputs will be valuable

Reply all
Reply to author
Forward
0 new messages