| org.archive.util.CachedBdbMap
CachedBdbMap | public class CachedBdbMap extends AbstractMap implements Map<K, V>,Serializable(Code) | | A BDB JE backed hashmap. It extends the normal BDB JE map implementation by
holding a cache of soft referenced objects. That is objects are not written
to disk until they are not referenced by any other object and therefore can be
Garbage Collected.
author: John Erik Halse author: stack author: gojomo |
Inner Class :protected static class DbEnvironmentEntry | |
Field Summary | |
protected transient Database | db The BDB JE database used for this instance. | protected transient StoredSortedMap | diskMap The Collection view of the BDB JE database used for this instance. | protected int | diskMapSize The number of objects in the diskMap StoredMap. | protected transient ReferenceQueue<V> | refQueue | protected static Field | referentField Reference to the Reference#referent Field. |
Method Summary | |
public synchronized void | clear() Note that a call to this method CLOSEs the underlying bdbje.
This instance is no longer of any use. | public synchronized void | close() | public synchronized boolean | containsKey(Object key) | public synchronized boolean | containsValue(Object value) | protected StoredSortedMap | createDiskMap(Database database, StoredClassCatalog classCatalog, Class keyClass, Class valueClass) | public Set<Map.Entry<K, V>> | entrySet() | protected void | finalize() | public synchronized V | get(Object object) | protected String | getDatabaseName() | public synchronized void | initialize(Environment env, Class keyClass, Class valueClass, StoredClassCatalog classCatalog) Call this method when you have an instance when you used the
default constructor or when you have a deserialized instance that you
want to reconnect with an extant bdbje environment. | protected void | initializeInstance() Do any instance setup. | public Set<K> | keySet() The keySet of the diskMap is all relevant keys. | protected Database | openDatabase(Environment environment, String dbName) | public synchronized V | put(K key, V value) | public synchronized boolean | quickContainsKey(Object key) | public synchronized boolean | quickContainsValue(Object value) | public synchronized V | remove(Object key) | public int | size() | public synchronized void | sync() Sync in-memory map entries to backing disk store. |
db | protected transient Database db(Code) | | The BDB JE database used for this instance.
|
diskMap | protected transient StoredSortedMap diskMap(Code) | | The Collection view of the BDB JE database used for this instance.
|
diskMapSize | protected int diskMapSize(Code) | | The number of objects in the diskMap StoredMap.
(Package access for unit testing.)
|
referentField | protected static Field referentField(Code) | | Reference to the Reference#referent Field.
|
CachedBdbMap | public CachedBdbMap(File dbDir, String dbName, Class<K> keyClass, Class<V> valueClass) throws DatabaseException(Code) | | A constructor for creating a new CachedBdbMap.
Even though the put and get methods conforms to the Collections interface
taking any object as key or value, you have to submit the class of the
allowed key and value objects here and will get an exception if you try
to put anything else in the map.
This constructor internally calls
CachedBdbMap.initialize(Environment,Class,Class,StoredClassCatalog) .
Do not call initialize if you use this constructor.
Parameters: dbDir - The directory where the database will be created. Parameters: dbName - The name of the database to back this map by. Parameters: keyClass - The class of the objects allowed as keys. Parameters: valueClass - The class of the objects allowed as values. throws: DatabaseException - is thrown if the underlying BDB JE databasethrows an exception. |
clear | public synchronized void clear()(Code) | | Note that a call to this method CLOSEs the underlying bdbje.
This instance is no longer of any use. It must be re-initialized.
We close the db here because if this BigMap is being treated as a plain
Map, this is only opportunity for cleanup.
|
close | public synchronized void close() throws DatabaseException(Code) | | |
containsKey | public synchronized boolean containsKey(Object key)(Code) | | |
containsValue | public synchronized boolean containsValue(Object value)(Code) | | |
createDiskMap | protected StoredSortedMap createDiskMap(Database database, StoredClassCatalog classCatalog, Class keyClass, Class valueClass)(Code) | | |
initialize | public synchronized void initialize(Environment env, Class keyClass, Class valueClass, StoredClassCatalog classCatalog) throws DatabaseException(Code) | | Call this method when you have an instance when you used the
default constructor or when you have a deserialized instance that you
want to reconnect with an extant bdbje environment. Do not
call this method if you used the
CachedBdbMap.CachedBdbMap(File,String,Class,Class) constructor.
Parameters: env - Parameters: keyClass - Parameters: valueClass - Parameters: classCatalog - throws: DatabaseException - |
initializeInstance | protected void initializeInstance()(Code) | | Do any instance setup.
This method is used by constructors and when deserializing an instance.
|
openDatabase | protected Database openDatabase(Environment environment, String dbName) throws DatabaseException(Code) | | |
put | public synchronized V put(K key, V value)(Code) | | |
quickContainsKey | public synchronized boolean quickContainsKey(Object key)(Code) | | |
quickContainsValue | public synchronized boolean quickContainsValue(Object value)(Code) | | |
sync | public synchronized void sync()(Code) | | Sync in-memory map entries to backing disk store.
When done, the memory map will be cleared and all entries stored
on disk.
|
|
|