I use mapDB to store my Data, which are inserted in maps. I followed the instructions on mapDB-Site and was able to set up an Database and also fill it with values. But my problem is right here, I insert my data into the maps and then call the Database-Class to insert the Map into the DB. The current map is then added to the DB, but automatically overwrites the previous entry, so that the number of entries are always 1.
Here is my code:
for(Element objects : objectInstanceList)
{
mapID = objects.getName().toString();
List<Element> listObjects1 = objects.getChildren();
Multimap<String, Values> mm = HashMultimap.create();
for(Element objectClasses : listObjects1 )
{
List<Element> listObjects2 = objectClasses.getChildren();
for(Element objectAttributes : listObjects2)
{
String name = objectAttributes.getAttributeValue("name");
String type = objectAttributes.getAttributeValue("type");
String value = objectAttributes.getAttributeValue("value");
Values v = new Values(name, type, value);
mm.put(objectClasses.getName(), v);
}
}
DataBase.putHW(mapID, mm);
System.out.println(mm);
}
Like I said I fill the Multimap mm with some values and the Method Database.putHW, which looks like this(created like in the examples of the mapDB page).
public class DataBase {
static DB dbHW = DBMaker.newMemoryDB().make();
static NavigableSet<Fun.Tuple2<String, Multimap<String,Values>>> multimapHW
= dbHW.getTreeSet("Applications");
public static void putHW(String mapID, Multimap<String,Values> dbMap) {
multimapHW = dbHW.createTreeSet("Delta").serializer(BTreeKeySerializer.TUPLE2).make();
multimapHW.add(Fun.t2(mapID, dbMap)); // Fun means functional, its the Function to add values in the map
}
}
So why does the multimapHW in the Database just contains 1 entry, instead of many entries?