|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.processmining.framework.log.rfb.io.ManagedRandomAccessFile
org.processmining.framework.log.rfb.io.CachedRandomAccessFile
public class CachedRandomAccessFile
This class implements the interface of ManagedRandomAccessFile, providing high-level type read and write operations on a managed random access file.
On top of such managed random access file, this class provides a transparent caching layer, which is supposed to speed up read operations by limiting actual calls to the low-level I/O layer.
Caching is performed read-only, which has, in its current implementation, the following implications:
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.processmining.framework.log.rfb.io.ManagedRandomAccessFile |
---|
ManagedRandomAccessFile.ShutdownHook |
Field Summary | |
---|---|
protected java.nio.ByteBuffer |
buffer
Byte buffer which abstracts from the cache for read operations of basic Java types. |
protected byte[] |
cache
Cache for underlying file data. |
protected boolean |
cacheDirty
Indicates, whether the cache has been invalidated (e.g. |
protected long |
cacheOffset
Describes the offset within the cached file, which is represented by the first byte currently in the cache. |
protected int |
cacheSize
Size of the cache, in bytes. |
protected int |
cacheValidSize
Describes the remaining valid bytes in the cache. |
static int |
DEFAULT_CACHE_SIZE
Defines the default cache size, which is used when no value is provided in the constructor. |
Fields inherited from class org.processmining.framework.log.rfb.io.ManagedRandomAccessFile |
---|
currentFilePointer, file, isOpen, maxOpenFiles, openFilesCounter, openFilesList, raf, TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX |
Constructor Summary | |
---|---|
CachedRandomAccessFile()
Creates a new instance caching the default amount of bytes in heap memory. |
|
CachedRandomAccessFile(CachedRandomAccessFile template)
Creates a new instance which is a clone of the provided template instance. |
|
CachedRandomAccessFile(int cacheSize)
Creates a new instance caching the given amount of bytes in heap memory. |
Method Summary | |
---|---|
protected java.nio.ByteBuffer |
buffer(int size)
Retrieves a ByteBuffer, which can read the given number of bytes from the current (virtual) file pointer position. |
protected void |
cache(int size)
Ensures that the given amount of bytes from the current file position are available from the cache. |
void |
close()
Closes this instance virtually (flushes and releases the managed file) |
RandomAccessStorage |
copy()
Creates a clone, or copy, of this storage, having the exact same contents and the file pointer reset to zero. |
boolean |
readBoolean()
Wrapped method from DataInput interface. |
byte |
readByte()
Wrapped method from DataInput interface. |
char |
readChar()
Wrapped method from DataInput interface. |
double |
readDouble()
Wrapped method from DataInput interface. |
float |
readFloat()
Wrapped method from DataInput interface. |
void |
readFully(byte[] arr)
Wrapped method from DataInput interface. |
void |
readFully(byte[] arg0,
int offset,
int length)
Wrapped method from DataInput interface. |
int |
readInt()
Wrapped method from DataInput interface. |
java.lang.String |
readLine()
Wrapped method from DataInput interface. |
long |
readLong()
Wrapped method from DataInput interface. |
short |
readShort()
Wrapped method from DataInput interface. |
int |
readUnsignedByte()
Wrapped method from DataInput interface. |
int |
readUnsignedShort()
Wrapped method from DataInput interface. |
java.lang.String |
readUTF()
Warning: custom implementation will expect different low-level byte encoding than e.g. |
int |
skipBytes(int arg0)
Wrapped method from DataInput interface. |
void |
write(byte[] arg)
Wrapped method from DataOutput interface. |
void |
write(byte[] arg,
int arg1,
int arg2)
Wrapped method from DataOutput interface. |
void |
write(int val)
Wrapped method from DataOutput interface. |
void |
writeBoolean(boolean bool)
Wrapped method from DataOutput interface. |
void |
writeByte(int arg0)
Wrapped method from DataOutput interface. |
void |
writeBytes(java.lang.String arg0)
Wrapped method from DataOutput interface. |
void |
writeChar(int arg0)
Wrapped method from DataOutput interface. |
void |
writeChars(java.lang.String arg0)
Wrapped method from DataOutput interface. |
void |
writeDouble(double arg0)
Wrapped method from DataOutput interface. |
void |
writeFloat(float arg0)
Wrapped method from DataOutput interface. |
void |
writeInt(int arg0)
Wrapped method from DataOutput interface. |
void |
writeLong(long arg0)
Wrapped method from DataOutput interface. |
void |
writeShort(int arg0)
Wrapped method from DataOutput interface. |
void |
writeUTF(java.lang.String arg0)
Warning: This method uses a custom format to encode UTF-8 strings to bytes than specified in DataOutput. |
Methods inherited from class org.processmining.framework.log.rfb.io.ManagedRandomAccessFile |
---|
closeHandle, copyFile, createTempFile, delete, deleteOnExit, finalize, getFilePointer, length, raf, releaseOpenFileSlot, reOpen, retrieveOpenFileSlot, seek |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int DEFAULT_CACHE_SIZE
protected int cacheSize
protected int cacheValidSize
protected long cacheOffset
protected byte[] cache
protected boolean cacheDirty
protected java.nio.ByteBuffer buffer
Constructor Detail |
---|
public CachedRandomAccessFile(int cacheSize) throws java.io.IOException
cacheSize
- Size of the memory cache, in bytes.
java.io.IOException
public CachedRandomAccessFile() throws java.io.IOException
java.io.IOException
public CachedRandomAccessFile(CachedRandomAccessFile template) throws java.io.IOException
Changes are defined to be not synchronized between template and clone, i.e. the created clone will behave as a truly separate and independent instance after creation.
template
- Template to create a clone from.
java.io.IOException
Method Detail |
---|
public RandomAccessStorage copy() throws java.io.IOException
RandomAccessStorage
copy
in interface RandomAccessStorage
copy
in class ManagedRandomAccessFile
java.io.IOException
protected void cache(int size) throws java.io.IOException
size
- Number of bytes to be cached, referred from the current (virtual)
file pointer position.
Notice: It is assumed that the given number of bytes is between zero and the cache size. This property must be ensured outside of this method!
java.io.IOException
protected java.nio.ByteBuffer buffer(int size) throws java.io.IOException
size
- Number of bytes, that are to be read from the provided byte buffer.
Warning: This method relies on the correctness of this value, which must be absolute and correct; i.e. this is not an upper bound, but must be exactly the number of bytes actually read from the byte buffer. If this is not ensured, the internal state of this instance will become inconsistend, rendering future read operation results unpredictable.
java.io.IOException
public void close() throws java.io.IOException
ManagedRandomAccessFile
close
in interface RandomAccessStorage
close
in class ManagedRandomAccessFile
java.io.IOException
public boolean readBoolean() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readBoolean
in interface java.io.DataInput
readBoolean
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public byte readByte() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readByte
in interface java.io.DataInput
readByte
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public char readChar() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readChar
in interface java.io.DataInput
readChar
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public double readDouble() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readDouble
in interface java.io.DataInput
readDouble
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public float readFloat() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readFloat
in interface java.io.DataInput
readFloat
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public void readFully(byte[] arg0, int offset, int length) throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readFully
in interface java.io.DataInput
readFully
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public void readFully(byte[] arr) throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readFully
in interface java.io.DataInput
readFully
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public int readInt() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readInt
in interface java.io.DataInput
readInt
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public java.lang.String readLine() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readLine
in interface java.io.DataInput
readLine
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public long readLong() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readLong
in interface java.io.DataInput
readLong
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public short readShort() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readShort
in interface java.io.DataInput
readShort
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public int readUnsignedByte() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readUnsignedByte
in interface java.io.DataInput
readUnsignedByte
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public int readUnsignedShort() throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
readUnsignedShort
in interface java.io.DataInput
readUnsignedShort
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public java.lang.String readUTF() throws java.io.IOException
ManagedRandomAccessFile
RandomAccessFile
!
Preserves the internal state of the managed proxy instance.
readUTF
in interface java.io.DataInput
readUTF
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public int skipBytes(int arg0) throws java.io.IOException
ManagedRandomAccessFile
DataInput
interface.
Preserves the internal state of the managed proxy instance.
skipBytes
in interface java.io.DataInput
skipBytes
in interface RandomAccessStorage
skipBytes
in class ManagedRandomAccessFile
java.io.IOException
DataInput
public void write(byte[] arg, int arg1, int arg2) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
write
in interface java.io.DataOutput
write
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void write(byte[] arg) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
write
in interface java.io.DataOutput
write
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void write(int val) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
write
in interface java.io.DataOutput
write
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeBoolean(boolean bool) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeBoolean
in interface java.io.DataOutput
writeBoolean
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeByte(int arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeByte
in interface java.io.DataOutput
writeByte
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeBytes(java.lang.String arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeBytes
in interface java.io.DataOutput
writeBytes
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeChar(int arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeChar
in interface java.io.DataOutput
writeChar
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeChars(java.lang.String arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeChars
in interface java.io.DataOutput
writeChars
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeDouble(double arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeDouble
in interface java.io.DataOutput
writeDouble
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeFloat(float arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeFloat
in interface java.io.DataOutput
writeFloat
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeInt(int arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeInt
in interface java.io.DataOutput
writeInt
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeLong(long arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeLong
in interface java.io.DataOutput
writeLong
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeShort(int arg0) throws java.io.IOException
ManagedRandomAccessFile
DataOutput
interface.
Preserves the internal state of the managed proxy instance.
writeShort
in interface java.io.DataOutput
writeShort
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
public void writeUTF(java.lang.String arg0) throws java.io.IOException
ManagedRandomAccessFile
Preserves the internal state of the managed proxy instance.
writeUTF
in interface java.io.DataOutput
writeUTF
in class ManagedRandomAccessFile
java.io.IOException
DataOutput
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |