private static int mergeMaps ( Map < String , Integer > map , Map < String , Integer > other ) { int deltaSize = 0 ; for ( Map . Entry < String , Integer > entry : other . entrySet ( ) ) { if ( ! map . containsKey ( entry . getKey ( ) ) ) { deltaSize += entry . getKey ( ) . getBytes ( ) . length + SIZE_OF_INT ; } map . put ( entry . getKey ( ) , map . getOrDefault ( entry . getKey ( ) , 0 ) + other . getOrDefault ( entry . getKey ( ) , 0 ) ) ; } return deltaSize ; }
Returns the estimated memory increase in map