Class PersistentMap<K,V>
- java.lang.Object
- 
- jadex.binary.persistent.collections.PersistentMap<K,V>
 
- 
- All Implemented Interfaces:
- java.util.Map<K,V>
 
 public class PersistentMap<K,V> extends java.lang.Object implements java.util.Map<K,V>A map implementation supporting automatic serialization its data and persisting it on disk.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classPersistentMap.DeletedKeyMarker for deleted entries.protected classPersistentMap.ValueInfoInformation about a stored value.
 - 
Field SummaryFields Modifier and Type Field Description protected longautocompactionthresholdDirty threshold for auto-compaction.protected java.lang.ClassLoaderclassloaderClass loader used for serialization.protected longdirtybytesBytes of dirty entries.protected java.io.FilefileThe persistence file.protected java.util.Map<K,PersistentMap.ValueInfo>indexmapThe index map, key to position and size of value.protected java.lang.StringmodeThe file access mode.protected java.io.RandomAccessFilerafRandom access to the persistence file
 - 
Constructor SummaryConstructors Constructor Description PersistentMap(java.io.File file, boolean synchronous, java.lang.ClassLoader classloader)Creates the map.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuildIndex()Builds the index.voidclear()Removes all of the entries from this map.voidclose()Closes the persistence file.voidcompact()Removes stale entries and compacts the map.booleancontainsKey(java.lang.Object key)Returns whether this map contains the specified key.booleancontainsValue(java.lang.Object value)Returns whether the map contains the specified value.protected VdoPut(K key, V value)Commits a value to the mapVdoRemove(java.lang.Object key)java.util.Set<java.util.Map.Entry<K,V>>entrySet()Returns the map's entry set.Vget(java.lang.Object key)Returns the value for a specified key.longgetDirtyBytes()Returns the bytes wasted due to stale entries.booleanisEmpty()Returns whether this map is empty.java.util.Set<K>keySet()Returns the keys of the map.static voidmain(java.lang.String[] args)Test main method.Vput(K key, V value)Puts a new value in the map.voidputAll(java.util.Map<? extends K,? extends V> m)Copies entries from the specified map to this map,Vremove(java.lang.Object key)Removes a map entry.voidsetAutoCompactionThreshold(long threshold)Sets the threshold of stale bytes before auto-compaction is executed.intsize()Returns the size of the map.java.util.Collection<V>values()Returns the values of the map.
 
- 
- 
- 
Field Detail- 
indexmapprotected java.util.Map<K,PersistentMap.ValueInfo> indexmap The index map, key to position and size of value.
 - 
fileprotected java.io.File file The persistence file.
 - 
modeprotected java.lang.String mode The file access mode.
 - 
rafprotected java.io.RandomAccessFile raf Random access to the persistence file
 - 
dirtybytesprotected long dirtybytes Bytes of dirty entries.
 - 
autocompactionthresholdprotected long autocompactionthreshold Dirty threshold for auto-compaction.
 - 
classloaderprotected java.lang.ClassLoader classloader Class loader used for serialization.
 
- 
 - 
Method Detail- 
mainpublic static void main(java.lang.String[] args) Test main method.- Parameters:
- args- Arguments.
 
 - 
sizepublic int size() Returns the size of the map.
 - 
isEmptypublic boolean isEmpty() Returns whether this map is empty.
 - 
containsKeypublic boolean containsKey(java.lang.Object key) Returns whether this map contains the specified key.
 - 
containsValuepublic boolean containsValue(java.lang.Object value) Returns whether the map contains the specified value. NOTE: This is very slow, use with caution.
 - 
getpublic V get(java.lang.Object key) Returns the value for a specified key.
 - 
removepublic V remove(java.lang.Object key) Removes a map entry.
 - 
putAllpublic void putAll(java.util.Map<? extends K,? extends V> m) Copies entries from the specified map to this map,
 - 
clearpublic void clear() Removes all of the entries from this map.
 - 
keySetpublic java.util.Set<K> keySet() Returns the keys of the map. Note: Unlike other maps, this is the preferred (fastest mode) for iteration.
 - 
valuespublic java.util.Collection<V> values() Returns the values of the map. NOTE: This is very slow, use with caution.
 - 
entrySetpublic java.util.Set<java.util.Map.Entry<K,V>> entrySet() Returns the map's entry set. Warning: SLOW!
 - 
compactpublic void compact() Removes stale entries and compacts the map.
 - 
closepublic void close() Closes the persistence file. The map ceases to function after calling this.
 - 
getDirtyBytespublic long getDirtyBytes() Returns the bytes wasted due to stale entries.
 - 
setAutoCompactionThresholdpublic void setAutoCompactionThreshold(long threshold) Sets the threshold of stale bytes before auto-compaction is executed. Setting the threshold to Long.MAX_VALUE disables auto-compaction.
 - 
buildIndexprotected void buildIndex() Builds the index.
 - 
doRemovepublic V doRemove(java.lang.Object key) 
 
- 
 
-