|
db4o 6.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.db4o.io.IoAdapter
com.db4o.io.CachedIoAdapter
public class CachedIoAdapter
CachedIoAdapter is an IOAdapter for random access files, which caches data
for IO access. Its functionality is similar to OS cache.
Example:
delegateAdapter = new RandomAccessFileAdapter();
Db4o.configure().io(new CachedIoAdapter(delegateAdapter));
Constructor Summary | |
---|---|
CachedIoAdapter(IoAdapter ioAdapter)
Creates an instance of CachedIoAdapter with the default page size and page count. |
|
CachedIoAdapter(IoAdapter ioAdapter,
int pageSize,
int pageCount)
Creates an instance of CachedIoAdapter with a custom page size and page count. |
|
CachedIoAdapter(java.lang.String path,
boolean lockFile,
long initialLength,
IoAdapter io,
int pageSize,
int pageCount)
Creates an instance of CachedIoAdapter with extended parameters. |
Method Summary | |
---|---|
void |
close()
Flushes and closes the file |
IoAdapter |
delegatedIoAdapter()
|
void |
delete(java.lang.String path)
Deletes the database file |
boolean |
exists(java.lang.String path)
Checks if the file exists |
long |
getLength()
Returns the file length |
IoAdapter |
open(java.lang.String path,
boolean lockFile,
long initialLength)
Creates and returns a new CachedIoAdapter |
int |
read(byte[] buffer,
int length)
Reads the file into the buffer using pages from cache. |
void |
seek(long pos)
Moves the pointer to the specified file position |
void |
sync()
Flushes cache to a physical storage |
void |
write(byte[] buffer,
int length)
Writes the buffer to cache using pages |
Methods inherited from class com.db4o.io.IoAdapter |
---|
blockCopy, blockSeek, blockSeek, blockSize, blockSize, copy, read, write |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachedIoAdapter(IoAdapter ioAdapter)
IoAdapter
- delegate IO adapter (RandomAccessFileAdapter by default)public CachedIoAdapter(IoAdapter ioAdapter, int pageSize, int pageCount)
IoAdapter
- delegate IO adapter (RandomAccessFileAdapter by default)pageSize
- cache page sizepageCount
- allocated amount of pagespublic CachedIoAdapter(java.lang.String path, boolean lockFile, long initialLength, IoAdapter io, int pageSize, int pageCount) throws java.io.IOException
path
- database file pathlockFile
- determines if the file should be lockedinitialLength
- initial file length, new writes will start from this pointIoAdapter
- delegate IO adapter (RandomAccessFileAdapter by default)pageSize
- cache page sizepageCount
- allocated amount of pages
java.io.IOException
Method Detail |
---|
public IoAdapter open(java.lang.String path, boolean lockFile, long initialLength) throws java.io.IOException
open
in class IoAdapter
path
- database file pathlockFile
- determines if the file should be lockedinitialLength
- initial file length, new writes will start from this point
java.io.IOException
public void delete(java.lang.String path)
delete
in class IoAdapter
path
- file pathpublic boolean exists(java.lang.String path)
exists
in class IoAdapter
path
- file pathpublic int read(byte[] buffer, int length) throws java.io.IOException
read
in class IoAdapter
buffer
- destination bufferlength
- how many bytes to read
java.io.IOException
public void write(byte[] buffer, int length) throws java.io.IOException
write
in class IoAdapter
buffer
- source bufferlength
- how many bytes to write
java.io.IOException
public void sync() throws java.io.IOException
sync
in class IoAdapter
java.io.IOException
public long getLength() throws java.io.IOException
getLength
in class IoAdapter
java.io.IOException
public void close() throws java.io.IOException
close
in class IoAdapter
java.io.IOException
public IoAdapter delegatedIoAdapter()
delegatedIoAdapter
in class IoAdapter
public void seek(long pos) throws java.io.IOException
seek
in class IoAdapter
pos
- position within the file
java.io.IOException
|
db4o 6.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |