gr.uoa.di.madgik.grs.store.record
Class CacheRecordStore

java.lang.Object
  extended by gr.uoa.di.madgik.grs.store.record.CacheRecordStore
All Implemented Interfaces:
IRecordStore

public class CacheRecordStore
extends java.lang.Object
implements IRecordStore


Constructor Summary
CacheRecordStore()
           
CacheRecordStore(int keepInMemory)
           
CacheRecordStore(int keepInMemory, MemoryStoreEvictionPolicy evictionPolicy)
           
 
Method Summary
 void dispose()
          Disposes the IRecordStore instance as well as any permanent storage resources occupied
 void enableOrder(boolean enableOrder)
          Whether the IRecordStore.retrieveByIndex(long, boolean) operation should be enabled or not
 long getRecordCount()
          Retrieves the number of Records stored using this IRecordStore
 void persist(Record record)
          Persists the provided Record
 Record retrieve(long recordID, boolean reset)
          Retrieves a previously stored Record based on its id
 Record retrieveByIndex(long recordIndex, boolean reset)
          Retrieve a previously stored Record based on the index by which it was stored.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheRecordStore

public CacheRecordStore(int keepInMemory,
                        MemoryStoreEvictionPolicy evictionPolicy)

CacheRecordStore

public CacheRecordStore(int keepInMemory)

CacheRecordStore

public CacheRecordStore()
Method Detail

enableOrder

public void enableOrder(boolean enableOrder)
Description copied from interface: IRecordStore
Whether the IRecordStore.retrieveByIndex(long, boolean) operation should be enabled or not

Specified by:
enableOrder in interface IRecordStore
Parameters:
enableOrder - whether the IRecordStore.retrieveByIndex(long, boolean) operation should be enabled or not

getRecordCount

public long getRecordCount()
Description copied from interface: IRecordStore
Retrieves the number of Records stored using this IRecordStore

Specified by:
getRecordCount in interface IRecordStore
Returns:
the number of Records stored

persist

public void persist(Record record)
             throws GRS2RecordStoreException
Description copied from interface: IRecordStore
Persists the provided Record

Specified by:
persist in interface IRecordStore
Parameters:
record - the Record to persist
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed

retrieve

public Record retrieve(long recordID,
                       boolean reset)
                throws GRS2RecordStoreException
Description copied from interface: IRecordStore
Retrieves a previously stored Record based on its id

Specified by:
retrieve in interface IRecordStore
Parameters:
recordID - the ID of the Record to be retrieved
reset - whether during the Record.inflate(java.io.DataInput, boolean) invocation the reset parameter should be set to true or false
Returns:
the Record retrieved
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed

retrieveByIndex

public Record retrieveByIndex(long recordIndex,
                              boolean reset)
                       throws GRS2RecordStoreException
Description copied from interface: IRecordStore
Retrieve a previously stored Record based on the index by which it was stored. This method is only available if before the first time a IRecordStore.persist(Record) was invoked the method IRecordStore.enableOrder(boolean) has been set to true

Specified by:
retrieveByIndex in interface IRecordStore
Parameters:
recordIndex - The index by which the Record to be retrieved was stored
reset - whether during the Record.inflate(java.io.DataInput, boolean) invocation the reset parameter should be set to true or false
Returns:
the Record retrieved
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed

dispose

public void dispose()
             throws GRS2RecordStoreException
Description copied from interface: IRecordStore
Disposes the IRecordStore instance as well as any permanent storage resources occupied

Specified by:
dispose in interface IRecordStore
Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed