Package com.db4o.io
Class MemoryBin
- java.lang.Object
-
- com.db4o.io.MemoryBin
-
-
Constructor Summary
Constructors Constructor Description MemoryBin(byte[] bytes, GrowthStrategy growthStrategy)MemoryBin(int initialSize, GrowthStrategy growthStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longbufferSize()voidclose()closes the Bin.byte[]data()Returns a copy of the raw data contained in this bin for external processing.longlength()returns the length of the Bin (on disc, in memory).intread(long pos, byte[] bytes, int length)reads a given number of bytes into an array of bytes at an offset position.voidsync()flushes the buffer content to the physical storage media.voidsync(java.lang.Runnable runnable)runs the Runnable between two calls to sync();intsyncRead(long position, byte[] bytes, int bytesToRead)reads a given number of bytes into an array of bytes at an offset position.voidwrite(long pos, byte[] buffer, int length)for internal processing only.
-
-
-
Constructor Detail
-
MemoryBin
public MemoryBin(int initialSize, GrowthStrategy growthStrategy)
-
MemoryBin
public MemoryBin(byte[] bytes, GrowthStrategy growthStrategy)
-
-
Method Detail
-
length
public long length()
Description copied from interface:Binreturns the length of the Bin (on disc, in memory).
-
bufferSize
public long bufferSize()
-
read
public int read(long pos, byte[] bytes, int length) throws Db4oIOExceptionDescription copied from interface:Binreads a given number of bytes into an array of bytes at an offset position.- Specified by:
readin interfaceBin- Parameters:
pos- the offset position to read atbytes- the byte array to read bytes intolength- the number of bytes to be read- Returns:
- The number of bytes actually read (<= bytesToRead) or -1 if position already points to/exceeds the end of the bin
- Throws:
Db4oIOException
-
sync
public void sync() throws Db4oIOExceptionDescription copied from interface:Binflushes the buffer content to the physical storage media.- Specified by:
syncin interfaceBin- Throws:
Db4oIOException
-
syncRead
public int syncRead(long position, byte[] bytes, int bytesToRead)Description copied from interface:Binreads a given number of bytes into an array of bytes at an offset position. In contrast to the normalBin.read(long, byte[], int)method, the Bin should ensure direct access to the raw storage medium. No caching should take place.
-
close
public void close()
Description copied from interface:Bincloses the Bin.
-
data
public byte[] data()
Returns a copy of the raw data contained in this bin for external processing. Access to the data is not guarded by synchronisation. If this method is called while the MemoryBin is in use, it is possible that the returned byte array is not consistent.
-
write
public void write(long pos, byte[] buffer, int length) throws Db4oIOExceptionfor internal processing only.- Specified by:
writein interfaceBin- Parameters:
pos- the offset position to write atbuffer- the array of bytes to writelength- the number of bytes to write- Throws:
Db4oIOException
-
-