|
db4o 7.4 | ||||||||
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,
boolean readOnly,
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()
Delegated IO Adapter |
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,
boolean readOnly)
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, boolean readOnly, IoAdapter io, int pageSize, int pageCount) throws Db4oIOException
path
- database file pathlockFile
- determines if the file should be lockedinitialLength
- initial file length, new writes will start from this pointreadOnly
- if the file should be used in read-onlyt mode.io
- delegate IO adapter (RandomAccessFileAdapter by default)pageSize
- cache page sizepageCount
- allocated amount of pages
Db4oIOException
Method Detail |
---|
public IoAdapter open(java.lang.String path, boolean lockFile, long initialLength, boolean readOnly) throws Db4oIOException
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
Db4oIOException
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 Db4oIOException
read
in class IoAdapter
buffer
- destination bufferlength
- how many bytes to read
Db4oIOException
public void write(byte[] buffer, int length) throws Db4oIOException
write
in class IoAdapter
buffer
- source bufferlength
- how many bytes to write
Db4oIOException
public void sync() throws Db4oIOException
sync
in class IoAdapter
Db4oIOException
public long getLength() throws Db4oIOException
getLength
in class IoAdapter
Db4oIOException
public void close() throws Db4oIOException
close
in class IoAdapter
Db4oIOException
public IoAdapter delegatedIoAdapter()
IoAdapter
delegatedIoAdapter
in class IoAdapter
public void seek(long pos) throws Db4oIOException
seek
in class IoAdapter
pos
- position within the file
Db4oIOException
|
db4o 7.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |