gr.uoa.di.madgik.grs.store.record
Interface IRecordStore

All Known Implementing Classes:
CacheRecordStore, FileRecordStore

public interface IRecordStore

This interface defines a way a persistency manager can be interfaced to enabling persistency of Records and retrieval based on either their ids, or the order by which they were stored. The Record persistency must be handled by the respective Record.deflate(java.io.DataOutput) operation while the retrieval by the respective Record.inflate(java.io.DataInput, boolean) method. The storage medium over which the Records are persisted is left to the implementation specifics

Author:
gpapanikos

Method Summary
 void dispose()
          Disposes the IRecordStore instance as well as any permanent storage resources occupied
 void enableOrder(boolean enableOrder)
          Whether the 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.
 

Method Detail

enableOrder

void enableOrder(boolean enableOrder)
Whether the retrieveByIndex(long, boolean) operation should be enabled or not

Parameters:
enableOrder - whether the retrieveByIndex(long, boolean) operation should be enabled or not

getRecordCount

long getRecordCount()
Retrieves the number of Records stored using this IRecordStore

Returns:
the number of Records stored

persist

void persist(Record record)
             throws GRS2RecordStoreException
Persists the provided Record

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

retrieve

Record retrieve(long recordID,
                boolean reset)
                throws GRS2RecordStoreException
Retrieves a previously stored Record based on its id

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

Record retrieveByIndex(long recordIndex,
                       boolean reset)
                       throws GRS2RecordStoreException
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 persist(Record) was invoked the method enableOrder(boolean) has been set to true

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

void dispose()
             throws GRS2RecordStoreException
Disposes the IRecordStore instance as well as any permanent storage resources occupied

Throws:
GRS2RecordStoreException - the state of the IRecordStore does not allow for this operation to be completed