/** * Sets the threshold of stale bytes * before auto-compaction is executed. * Setting the threshold to Long.MAX_VALUE * disables auto-compaction. */ public void setAutoCompactionThreshold(long threshold) { autocompactionthreshold = threshold; if (dirtybytes > autocompactionthreshold) { compact(); } }
/** * Puts a new value in the map. */ public V put(K key, V value) { V ret = doPut(key, value); if (dirtybytes > autocompactionthreshold) { compact(); } return ret; }
/** * Removes a map entry. */ public V remove(Object key) { V ret = doRemove(key); if (dirtybytes > autocompactionthreshold) { compact(); } return ret; }
System.out.println("Dirty: " + pm.getDirtyBytes() + ", Map size: " + pm.size()); ts = System.currentTimeMillis(); pm.compact(); System.out.println("Compaction took: " + (System.currentTimeMillis() - ts)); System.out.println("Dirty: " + pm.getDirtyBytes() + ", Map size: " + pm.size());