/** * Copies entries from the specified map to this map, */ public void putAll(Map<? extends K, ? extends V> m) { // for (Map.Entry<? extends K, ? extends V> entry : m.entrySet()) // { // put(entry.getKey(), entry.getValue()); // } for (K key : m.keySet()) { put(key, m.get(key)); } }
File file = new File(tmpdir + File.separator + "pmaptest.map"); file.delete(); PersistentMap<String, String> pm = new PersistentMap<String, String>(file, false, null); pm.put(key + i, value + i); String lastval = pm.get(key + (writes - 1)); long delta = System.currentTimeMillis() - ts; System.out.println(delta); System.out.println((double) writes / delta * 1000); System.out.println("Dirty: " + pm.getDirtyBytes() + ", Map size: " + pm.size()); String val = pm.get(key + i); System.out.print(":" + val + ", "); pm.remove(key + i); 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()); System.out.println(lastval); System.out.println(pm.get(key + (writes - 1))); System.out.println(lastval.equals(pm.get(key + (writes - 1)))); pm.close();
/** * Returns the values of the map. * * NOTE: This is very slow, use with caution. */ public Collection<V> values() { List<V> ret = new ArrayList<V>(indexmap.size()); for (Map.Entry<K, ValueInfo> entry : indexmap.entrySet()) { ret.add(get(entry.getKey())); } return ret; }
/** * 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(); } }
/** * Returns whether the map contains the * specified value. * * NOTE: This is very slow, use with caution. */ public boolean containsValue(Object value) { for (Map.Entry<K, ValueInfo> entry : indexmap.entrySet()) { if (value != null) { if (value.equals(get(entry.getKey()))) { return true; } } else { if (value == get(entry.getKey())) { return true; } } } return false; }
if (indexmap.containsKey(key)) ret = get(key); ValueInfo oldvalinfo = indexmap.remove(key); DeletedKey dk = new DeletedKey(key);
V ret = get(key);