|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
org.archive.util.CachedBdbMap<K,V>
public class CachedBdbMap<K,V>
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.
Nested Class Summary | |
---|---|
protected static class |
CachedBdbMap.DbEnvironmentEntry
Simple structure to keep needed information about a DB Environment. |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Field Summary | |
---|---|
protected com.sleepycat.je.Database |
db
The BDB JE database used for this instance. |
protected com.sleepycat.collections.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 static java.lang.reflect.Field |
referentField
Reference to the Reference#referent Field. |
protected java.lang.ref.ReferenceQueue<V> |
refQueue
|
Constructor Summary | |
---|---|
CachedBdbMap(java.io.File dbDir,
java.lang.String dbName,
java.lang.Class<K> keyClass,
java.lang.Class<V> valueClass)
A constructor for creating a new CachedBdbMap. |
|
CachedBdbMap(java.lang.String dbName)
Constructor. |
Method Summary | |
---|---|
void |
clear()
Note that a call to this method CLOSEs the underlying bdbje. |
void |
close()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
protected com.sleepycat.collections.StoredSortedMap |
createDiskMap(com.sleepycat.je.Database database,
com.sleepycat.bind.serial.StoredClassCatalog classCatalog,
java.lang.Class keyClass,
java.lang.Class valueClass)
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
|
protected void |
finalize()
|
V |
get(java.lang.Object object)
|
protected java.lang.String |
getDatabaseName()
|
void |
initialize(com.sleepycat.je.Environment env,
java.lang.Class keyClass,
java.lang.Class valueClass,
com.sleepycat.bind.serial.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. |
java.util.Set<K> |
keySet()
The keySet of the diskMap is all relevant keys. |
protected com.sleepycat.je.Database |
openDatabase(com.sleepycat.je.Environment environment,
java.lang.String dbName)
|
V |
put(K key,
V value)
|
boolean |
quickContainsKey(java.lang.Object key)
|
boolean |
quickContainsValue(java.lang.Object value)
|
V |
remove(java.lang.Object key)
|
int |
size()
|
void |
sync()
Sync in-memory map entries to backing disk store. |
Methods inherited from class java.util.AbstractMap |
---|
clone, equals, hashCode, isEmpty, putAll, toString, values |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode, isEmpty, putAll, values |
Field Detail |
---|
protected transient com.sleepycat.je.Database db
protected transient com.sleepycat.collections.StoredSortedMap diskMap
protected transient java.lang.ref.ReferenceQueue<V> refQueue
protected int diskMapSize
protected static java.lang.reflect.Field referentField
Constructor Detail |
---|
public CachedBdbMap(java.lang.String dbName)
initialize(Environment, Class, Class, StoredClassCatalog)
to finish construction. Construction is two-stepped to support
reconnecting a deserialized CachedBdbMap with its backing bdbje
database.
dbName
- Name of the backing db this instance should use.public CachedBdbMap(java.io.File dbDir, java.lang.String dbName, java.lang.Class<K> keyClass, java.lang.Class<V> valueClass) throws com.sleepycat.je.DatabaseException
This constructor internally calls
initialize(Environment, Class, Class, StoredClassCatalog)
.
Do not call initialize if you use this constructor.
dbDir
- The directory where the database will be created.dbName
- The name of the database to back this map by.keyClass
- The class of the objects allowed as keys.valueClass
- The class of the objects allowed as values.
com.sleepycat.je.DatabaseException
- is thrown if the underlying BDB JE database
throws an exception.Method Detail |
---|
public void initialize(com.sleepycat.je.Environment env, java.lang.Class keyClass, java.lang.Class valueClass, com.sleepycat.bind.serial.StoredClassCatalog classCatalog) throws com.sleepycat.je.DatabaseException
CachedBdbMap(File, String, Class, Class)
constructor.
env
- keyClass
- valueClass
- classCatalog
-
com.sleepycat.je.DatabaseException
protected void initializeInstance()
protected com.sleepycat.collections.StoredSortedMap createDiskMap(com.sleepycat.je.Database database, com.sleepycat.bind.serial.StoredClassCatalog classCatalog, java.lang.Class keyClass, java.lang.Class valueClass)
protected com.sleepycat.je.Database openDatabase(com.sleepycat.je.Environment environment, java.lang.String dbName) throws com.sleepycat.je.DatabaseException
com.sleepycat.je.DatabaseException
public void close() throws com.sleepycat.je.DatabaseException
com.sleepycat.je.DatabaseException
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public java.util.Set<K> keySet()
keySet
in interface java.util.Map<K,V>
keySet
in class java.util.AbstractMap<K,V>
Map.keySet()
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
entrySet
in class java.util.AbstractMap<K,V>
public V get(java.lang.Object object)
get
in interface java.util.Map<K,V>
get
in class java.util.AbstractMap<K,V>
public V put(K key, V value)
put
in interface java.util.Map<K,V>
put
in class java.util.AbstractMap<K,V>
public void clear()
clear
in interface java.util.Map<K,V>
clear
in class java.util.AbstractMap<K,V>
public V remove(java.lang.Object key)
remove
in interface java.util.Map<K,V>
remove
in class java.util.AbstractMap<K,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
containsKey
in class java.util.AbstractMap<K,V>
public boolean quickContainsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<K,V>
containsValue
in class java.util.AbstractMap<K,V>
public boolean quickContainsValue(java.lang.Object value)
public int size()
size
in interface java.util.Map<K,V>
size
in class java.util.AbstractMap<K,V>
protected java.lang.String getDatabaseName()
public void sync()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |