com.timeindexing.cache
Class DefaultIndexCache

java.lang.Object
  extended bycom.timeindexing.cache.DefaultIndexCache
All Implemented Interfaces:
IndexCache
Direct Known Subclasses:
FileIndexCache

public class DefaultIndexCache
extends java.lang.Object
implements IndexCache

The default implementation of a cache which holds the index items.


Constructor Summary
DefaultIndexCache(ManagedIndex index)
          Create a DefaultIndexCache object.
 
Method Summary
 long addItem(IndexItem item, long position)
          Add an Index Item to the Index.
 long addItem(IndexItem item, Position position)
          Add an Index Item to the Index.
 boolean clear()
          Clear the whole cache This does nothing by default as the data will be lost.
 boolean containsItem(long pos)
          Contains the IndexItem at the speicifed position.
 boolean containsItem(Position p)
          Contains the IndexItem at the speicifed position.
 long getDataVolume()
          Get the current data volume held by IndexItems in this cache.
 Timestamp getFirstDataTime()
          Get the time the first IndexItem was put into the Index.
 Timestamp getFirstIndexTime()
          Get the time the first IndexItem was put into the Index.
 IndexItem getItem(long pos)
          Get an Index Item from the Index.
 IndexItem getItem(Position p)
          Get an Index Item from the Index.
 Timestamp getLastDataTime()
          Get the time the last IndexItem was put into the Index.
 Timestamp getLastIndexTime()
          Get the time the last IndexItem was put into the Index.
 CachePolicy getPolicy()
          Get the current cache policy.
 boolean hollowItem(long pos)
          Hollow the IndexItem at the position.
 boolean hollowItem(Position p)
          Hollow the IndexItem at the position.
 boolean removeItem(long pos)
          Remove the IndexItem at the speicifed position.
 boolean removeItem(Position p)
          Remove the IndexItem at the speicifed position.
 CachePolicy setPolicy(CachePolicy pol)
          Set the cache policy.
 long size()
          Get the no of items in the cache
protected  long sparce(long start, long end)
          Create some sparce elements in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultIndexCache

public DefaultIndexCache(ManagedIndex index)
Create a DefaultIndexCache object.

Method Detail

size

public long size()
Get the no of items in the cache

Specified by:
size in interface IndexCache

addItem

public long addItem(IndexItem item,
                    Position position)
Add an Index Item to the Index.

Specified by:
addItem in interface IndexCache
Parameters:
item - the IndexItem to add
Returns:
the no of items in the index.

addItem

public long addItem(IndexItem item,
                    long position)
Add an Index Item to the Index.

Specified by:
addItem in interface IndexCache
Parameters:
item - the IndexItem to add
Returns:
the no of items in the index.

getItem

public IndexItem getItem(long pos)
Get an Index Item from the Index.

Specified by:
getItem in interface IndexCache

getItem

public IndexItem getItem(Position p)
Get an Index Item from the Index.

Specified by:
getItem in interface IndexCache

containsItem

public boolean containsItem(long pos)
Contains the IndexItem at the speicifed position. If the cache contains the item, it means it is loaded.

Specified by:
containsItem in interface IndexCache

containsItem

public boolean containsItem(Position p)
Contains the IndexItem at the speicifed position. If the cache contains the item, it means it is loaded.

Specified by:
containsItem in interface IndexCache

hollowItem

public boolean hollowItem(long pos)
Hollow the IndexItem at the position. This does nothing by default as the data will be lost.

Specified by:
hollowItem in interface IndexCache

hollowItem

public boolean hollowItem(Position p)
Hollow the IndexItem at the position.

Specified by:
hollowItem in interface IndexCache

removeItem

public boolean removeItem(long pos)
Remove the IndexItem at the speicifed position. This does nothing by default as the data will be lost.

Specified by:
removeItem in interface IndexCache

removeItem

public boolean removeItem(Position p)
Remove the IndexItem at the speicifed position.

Specified by:
removeItem in interface IndexCache

clear

public boolean clear()
Clear the whole cache This does nothing by default as the data will be lost.

Specified by:
clear in interface IndexCache

getDataVolume

public long getDataVolume()
Get the current data volume held by IndexItems in this cache.

Specified by:
getDataVolume in interface IndexCache

getFirstIndexTime

public Timestamp getFirstIndexTime()
Get the time the first IndexItem was put into the Index.

Specified by:
getFirstIndexTime in interface IndexCache

getLastIndexTime

public Timestamp getLastIndexTime()
Get the time the last IndexItem was put into the Index.

Specified by:
getLastIndexTime in interface IndexCache

getFirstDataTime

public Timestamp getFirstDataTime()
Get the time the first IndexItem was put into the Index.

Specified by:
getFirstDataTime in interface IndexCache

getLastDataTime

public Timestamp getLastDataTime()
Get the time the last IndexItem was put into the Index.

Specified by:
getLastDataTime in interface IndexCache

setPolicy

public CachePolicy setPolicy(CachePolicy pol)
Set the cache policy.

Specified by:
setPolicy in interface IndexCache
Returns:
the old cache policy

getPolicy

public CachePolicy getPolicy()
Get the current cache policy.

Specified by:
getPolicy in interface IndexCache

sparce

protected long sparce(long start,
                      long end)
Create some sparce elements in the cache.