org.tranche.flatfile
Class DataBlockCache

java.lang.Object
  extended by org.tranche.flatfile.DataBlockCache

public class DataBlockCache
extends java.lang.Object

Used to cache the location of a chunk.

The idea is that hasData or hasMetaData is used before get or set. If cache results, won't have to read in header from data block.

Author:
Bryan Smith - bryanesmith@gmail.com

Field Summary
static int CACHE_ENTRY_SIZE
          The number of entries to keep in memory for data or meta data chunks.
 
Constructor Summary
DataBlockCache()
           
 
Method Summary
 void add(DataBlockCacheEntry e, boolean isMetaData)
          Add a DataBlockCacheEntry to the cache.
 void clear()
          Clear out the cache resources.
 DataBlockCacheEntry get(BigHash hash, boolean isMetaData)
          Returns the DataBlockCacheEntry from the cache if exists, or null if not there.
 void remove(BigHash h, boolean isMetaData)
          Remove a specific DataBlockCacheEntry from the cache, if there.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_ENTRY_SIZE

public static final int CACHE_ENTRY_SIZE

The number of entries to keep in memory for data or meta data chunks.

See Also:
Constant Field Values
Constructor Detail

DataBlockCache

public DataBlockCache()
Method Detail

add

public void add(DataBlockCacheEntry e,
                boolean isMetaData)

Add a DataBlockCacheEntry to the cache. Removes oldest entries if maximum size is exceeded.

Parameters:
e -
isMetaData -

get

public DataBlockCacheEntry get(BigHash hash,
                               boolean isMetaData)
                        throws AssertionFailedException,
                               java.lang.Exception

Returns the DataBlockCacheEntry from the cache if exists, or null if not there.

Parameters:
hash -
isMetaData -
Returns:
Throws:
AssertionFailedException
java.lang.Exception

clear

public void clear()

Clear out the cache resources.


remove

public void remove(BigHash h,
                   boolean isMetaData)

Remove a specific DataBlockCacheEntry from the cache, if there. Otherwise, do nothing.

Parameters:
h -
isMetaData -


This code is free for use both commercially and non-commercially as stated in the project's license