Hi
I have a use case where i am pushing tens of thousands of data into a HashMap.
the structure of the HashMap is like
HashMap<String1, Map<String2, Map<String3, String4>>>
Here the String1 would anyway be unique, but the String3 and
String 4 are very frequently repeating Strings.
These are representing the Status and Priority values in each "calendar week" (String 2)
The String3 (Status) and String4 (Priority) values can only be withing a predefined set of ten to 15 strings.
Now when i use the below code for serializing the hash map,
----------------------------------------------------------------------------------------------------------------
File file=new File("C:\\testData1.ser");
FileOutputStream fos=new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(new DeflaterOutputStream(fos));
oos.writeObject(MasterChartingData);
oos.flush();
oos.close();
fos.close();
----------------------------------------------------------------------------------------------------------------
and the below code for deserializing,
----------------------------------------------------------------------------------------------------------------
File file=new File("C:\\testData1.ser");
FileInputStream fis=new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(new InflaterInputStream(fis));
HashMap DeserializedMasterChartingData=(HashMap<String, Map<String,Map<String,String>>>)ois.readObject();
ois.close();
fis.close();
----------------------------------------------------------------------------------------------------------------
The repetition of the strings are identified and removed and the storage file size reduces to ~600 KB, where as a normal serialization, without using deflator/inflator, would create a file of ~6MB.
But the problem here is, when the number of entries increases, the
Java run time is not able to handle the growing size of the HashMap during runtime.
Is there any effecient ways where, right at the time of constructing the hashmap itself, to identify the data repetition and avoid it, and the HashMap construction is done memory effeciently?
regards
mad