com.bigdata.cache
Class StoreAndAddressLRUCache<V>

java.lang.Object
  extended by com.bigdata.cache.StoreAndAddressLRUCache<V>
All Implemented Interfaces:
IGlobalLRU<Long,V>

public class StoreAndAddressLRUCache<V>
extends Object
implements IGlobalLRU<Long,V>

Global LRU implementation based on a single map whose keys include both the IRawStore.getUUID() and the long addr of the record within the store.

Version:
$Id: StoreAndAddressLRUCache.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
TODO:
Implement a variant of the HardReferenceGlobalLRU and this class which uses a single ConcurrentHashMap but also maintains the linked-list LRU ordering.

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.bigdata.cache.IGlobalLRU
IGlobalLRU.IGlobalLRUCounters, IGlobalLRU.ILRUCache<K,V>
 
Constructor Summary
StoreAndAddressLRUCache(long maximumBytesInMemory, int minimumCacheSetCapacity, int initialCacheCapacity, float loadFactor)
           
 
Method Summary
 void deleteCache(UUID uuid)
          Remove the cache for the IRawStore from the set of caches maintained by this class and clear any entries in that cache.
 void discardAllCaches()
          Removes all entries from the cache and the backing LRU for all IRawStores.
 IGlobalLRU.ILRUCache<Long,V> getCache(UUID uuid, IAddressManager am)
          An canonicalizing factory for cache instances supporting random access to decompressed IDataRecords, higher-level data structures wrapping those decompressed data records (INodeData and ILeafData ), or objects deserialized from those IDataRecords.
 CounterSet getCounterSet()
          The counters for the global LRU.
 int size()
          Return the #of entries in the backing LRU across all IRawStores.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StoreAndAddressLRUCache

public StoreAndAddressLRUCache(long maximumBytesInMemory,
                               int minimumCacheSetCapacity,
                               int initialCacheCapacity,
                               float loadFactor)
Parameters:
maximumBytesInMemory - The maximum bytes in memory for the cached records across all cache instances.
minimumCacheSetCapacity - The #of per-IRawStore ILRUCache instances that will be maintained by hard references unless their cache is explicitly discarded.
initialCacheCapacity - The initial capacity of each new cache instance (in fact, a single map is shared by all cache instances - the cache instances are just logical views onto the shared map).
loadFactor - The load factor for the cache instances.
Method Detail

size

public int size()
Return the #of entries in the backing LRU across all IRawStores.


getCache

public IGlobalLRU.ILRUCache<Long,V> getCache(UUID uuid,
                                             IAddressManager am)
Description copied from interface: IGlobalLRU
An canonicalizing factory for cache instances supporting random access to decompressed IDataRecords, higher-level data structures wrapping those decompressed data records (INodeData and ILeafData ), or objects deserialized from those IDataRecords.

Specified by:
getCache in interface IGlobalLRU<Long,V>
Parameters:
uuid - The store's UUID.
am - The IAddressManager for that store (optional, but used to compute the bytes on disk for record and hence highly desired).
Returns:
The cache for records in the store.
See Also:
AbstractBTree.readNodeOrLeaf(long), IndexSegmentStore.reopen(), LRUNexus.getCache(IRawStore)

deleteCache

public void deleteCache(UUID uuid)
Description copied from interface: IGlobalLRU
Remove the cache for the IRawStore from the set of caches maintained by this class and clear any entries in that cache. This method SHOULD be used when the persistent resources for the store are deleted. It SHOULD NOT be used if a store is simply closed in a context when the store COULD be re-opened. In such cases, the cache for that store will be automatically released after it has become only weakly reachable.

Specified by:
deleteCache in interface IGlobalLRU<Long,V>
Parameters:
uuid - The store's UUID.
See Also:
IRawStore.destroy(), IRawStore.deleteResources()

discardAllCaches

public void discardAllCaches()
Removes all entries from the cache and the backing LRU for all IRawStores.

Specified by:
discardAllCaches in interface IGlobalLRU<Long,V>

getCounterSet

public CounterSet getCounterSet()
Description copied from interface: IGlobalLRU
The counters for the global LRU.

Specified by:
getCounterSet in interface IGlobalLRU<Long,V>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.