dk.vajhoej.isam.cache
Class CacheIsamSource

java.lang.Object
  extended by dk.vajhoej.isam.cache.CacheIsamSource
All Implemented Interfaces:
IsamSource

public class CacheIsamSource
extends java.lang.Object
implements IsamSource

Class CacheIsamSource is a wrapper adding a cache to an ISAM source.


Constructor Summary
CacheIsamSource(IsamSource real)
          Create instance of CacheIsamSource with default cache implementation.
CacheIsamSource(IsamSource real, IsamCache cache)
          Create instance of CacheIsamSource.
 
Method Summary
 void close()
          Close ISAM source.
<T> void
create(T o)
          Create record in ISAM source.
<T,TK> void
delete(java.lang.Class<T> t, Key<TK> k)
          Delete record from ISAM source.
 double getHitRate()
          Get hit rate.
<T,TK> T
read(java.lang.Class<T> t, Key<TK> k)
          Read record from ISAM source.
<T,TK> IsamResult<T>
readGE(java.lang.Class<T> t, Key<TK> k)
          Find all records greater than or equal key.
<T,TK> IsamResult<T>
readGT(java.lang.Class<T> t, Key<TK> k)
          Read all records greater than key.
<T,TK> IsamResult<T>
readLE(java.lang.Class<T> t, Key<TK> k)
          Read all records less than or equal key.
<T,TK> IsamResult<T>
readLT(java.lang.Class<T> t, Key<TK> k)
          Read all records less than key.
<T> void
update(T o)
          Update record in ISAM source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheIsamSource

public CacheIsamSource(IsamSource real)
Create instance of CacheIsamSource with default cache implementation.

Parameters:
real - ISAM source

CacheIsamSource

public CacheIsamSource(IsamSource real,
                       IsamCache cache)
Create instance of CacheIsamSource.

Parameters:
real - ISAM source
cache - cache implementation
Method Detail

read

public <T,TK> T read(java.lang.Class<T> t,
                     Key<TK> k)
       throws IsamException,
              RecordException
Description copied from interface: IsamSource
Read record from ISAM source.

Specified by:
read in interface IsamSource
Parameters:
t - type to read
k - key of record to read
Returns:
object read
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

create

public <T> void create(T o)
            throws IsamException,
                   RecordException
Description copied from interface: IsamSource
Create record in ISAM source.

Specified by:
create in interface IsamSource
Parameters:
o - object to create
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

update

public <T> void update(T o)
            throws IsamException,
                   RecordException
Description copied from interface: IsamSource
Update record in ISAM source.

Specified by:
update in interface IsamSource
Parameters:
o - object to update
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

delete

public <T,TK> void delete(java.lang.Class<T> t,
                          Key<TK> k)
            throws IsamException,
                   RecordException
Description copied from interface: IsamSource
Delete record from ISAM source.

Specified by:
delete in interface IsamSource
Parameters:
t - type to delete
k - key of record to delete
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

close

public void close()
           throws IsamException
Description copied from interface: IsamSource
Close ISAM source.

Specified by:
close in interface IsamSource
Throws:
IsamException - if problem with ISAM source

readGE

public <T,TK> IsamResult<T> readGE(java.lang.Class<T> t,
                                   Key<TK> k)
                     throws IsamException,
                            RecordException
Description copied from interface: IsamSource
Find all records greater than or equal key.

Specified by:
readGE in interface IsamSource
Parameters:
t - type to find
k - key to find
Returns:
result
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

readGT

public <T,TK> IsamResult<T> readGT(java.lang.Class<T> t,
                                   Key<TK> k)
                     throws IsamException,
                            RecordException
Description copied from interface: IsamSource
Read all records greater than key.

Specified by:
readGT in interface IsamSource
Parameters:
t - type to find
k - key to find
Returns:
result
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

readLE

public <T,TK> IsamResult<T> readLE(java.lang.Class<T> t,
                                   Key<TK> k)
                     throws IsamException,
                            RecordException
Description copied from interface: IsamSource
Read all records less than or equal key. Note that the performance of reading reverse may be very poor in some implementations.

Specified by:
readLE in interface IsamSource
Parameters:
t - type to find
k - key to find
Returns:
result
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

readLT

public <T,TK> IsamResult<T> readLT(java.lang.Class<T> t,
                                   Key<TK> k)
                     throws IsamException,
                            RecordException
Description copied from interface: IsamSource
Read all records less than key. Note that the performance of reading reverse may be very poor in some implementations.

Specified by:
readLT in interface IsamSource
Parameters:
t - type to find
k - key to find
Returns:
result
Throws:
IsamException - if problem with ISAM source
RecordException - if problem converting data

getHitRate

public double getHitRate()
Get hit rate.

Returns:
cache hit rate