|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.processmining.framework.log.rfb.io.VirtFsRandomAccessStorage
public class VirtFsRandomAccessStorage
This class implements a file metaphor, i.e. an ordered set of bytes which can be randomly accessed and modified. As it is dynamically backed by a virtual file system, the VFS/NIKEFS restrictions apply:
This file metaphor has the restriction, that the file must either be written in exactly the same granularity on re-writing specific address spaces, or preferably no modification other than appending data does occur.
Field Summary | |
---|---|
protected java.util.ArrayList<StorageBlock> |
blocks
List of blocks representing this file's contents |
protected VirtualFileSystem |
fs
Virtual file system from which blocks are allocated |
protected static int |
INSTANCE_COUNTER
Static instance counter, used to provide short names to instances of this class. |
protected int |
instanceNumber
Instance number, for short reference |
static int |
MAX_BLOCKS_PER_STORAGE
This constant holds the maximal number of blocks that a virtual file / random access storage from this class can be distributed over. |
protected long |
pointer
Current virtual file pointer |
Constructor Summary | |
---|---|
VirtFsRandomAccessStorage(VirtualFileSystem vfs)
Creates a new virtual file metaphor, based on the given virtual file system object for allocating blocks. |
Method Summary | |
---|---|
void |
close()
Closes the data storage container. |
protected StorageBlock |
consolidateBlocks(int minNewSize)
Consolidates the virtual file, i.e.: allocates a new block that can accomodate at least the size of the currently contained blocks, copy the contents of these to the new block, and finally replace the previous blocks with the new block. This prevents scattering of virtual files over too many blocks, thus increasing R/W performance of the virtual file system. |
RandomAccessStorage |
copy()
Creates a clone, or copy, of this storage, having the exact same contents and the file pointer reset to zero. |
protected StorageBlock |
getBlockForReading(int bytes)
Returns a block for safely reading the specified number of bytes from the current file pointer offset. |
protected StorageBlock |
getBlockForWriting(int bytes)
Returns a block, to which the specified number of bytes can be safely written, starting from the current pointer. |
long |
getFilePointer()
Returns the current file pointer of the storage container. |
long |
length()
Returns the length, or size, in number of bytes currently used by this instance. |
boolean |
readBoolean()
|
byte |
readByte()
|
char |
readChar()
|
double |
readDouble()
|
float |
readFloat()
|
void |
readFully(byte[] b)
|
void |
readFully(byte[] b,
int off,
int len)
|
int |
readInt()
|
java.lang.String |
readLine()
|
long |
readLong()
|
short |
readShort()
|
int |
readUnsignedByte()
|
int |
readUnsignedShort()
|
java.lang.String |
readUTF()
|
void |
seek(long pos)
Repositions the offset, or file pointer, at which the next read or write operation will occur. |
int |
skipBytes(int n)
Moves the offset, or file pointer, a specified number of bytes towards the end of the storage container. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
void |
writeBoolean(boolean v)
|
void |
writeByte(int v)
|
void |
writeBytes(java.lang.String s)
|
void |
writeChar(int v)
|
void |
writeChars(java.lang.String s)
|
void |
writeDouble(double v)
|
void |
writeFloat(float v)
|
void |
writeInt(int v)
|
void |
writeLong(long v)
|
void |
writeShort(int v)
|
void |
writeUTF(java.lang.String str)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static int INSTANCE_COUNTER
public static final int MAX_BLOCKS_PER_STORAGE
protected int instanceNumber
protected VirtualFileSystem fs
protected java.util.ArrayList<StorageBlock> blocks
protected long pointer
Constructor Detail |
---|
public VirtFsRandomAccessStorage(VirtualFileSystem vfs)
vfs
- Virtual file system providing blocks for this file.Method Detail |
---|
protected StorageBlock getBlockForWriting(int bytes) throws java.io.IOException
bytes
- Number of bytes to be written.
java.io.IOException
protected StorageBlock consolidateBlocks(int minNewSize) throws java.io.IOException
minNewSize
- Minimal size, in bytes, the newly allocated block
should be able to accomodate.
java.io.IOException
protected StorageBlock getBlockForReading(int bytes) throws java.io.IOException
bytes
- Number of bytes to be read.
java.io.IOException
public void close() throws java.io.IOException
RandomAccessStorage
close
in interface RandomAccessStorage
java.io.IOException
public long getFilePointer() throws java.io.IOException
RandomAccessStorage
getFilePointer
in interface RandomAccessStorage
java.io.IOException
public long length() throws java.io.IOException
RandomAccessStorage
length
in interface RandomAccessStorage
java.io.IOException
public void seek(long pos) throws java.io.IOException
RandomAccessStorage
seek
in interface RandomAccessStorage
pos
- The offset in bytes, at which the next operation
will occur.
java.io.IOException
public int skipBytes(int n) throws java.io.IOException
RandomAccessStorage
skipBytes
in interface java.io.DataInput
skipBytes
in interface RandomAccessStorage
java.io.IOException
public void write(int b) throws java.io.IOException
write
in interface java.io.DataOutput
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in interface java.io.DataOutput
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in interface java.io.DataOutput
java.io.IOException
public void writeBoolean(boolean v) throws java.io.IOException
writeBoolean
in interface java.io.DataOutput
java.io.IOException
public void writeByte(int v) throws java.io.IOException
writeByte
in interface java.io.DataOutput
java.io.IOException
public void writeBytes(java.lang.String s) throws java.io.IOException
writeBytes
in interface java.io.DataOutput
java.io.IOException
public void writeChar(int v) throws java.io.IOException
writeChar
in interface java.io.DataOutput
java.io.IOException
public void writeChars(java.lang.String s) throws java.io.IOException
writeChars
in interface java.io.DataOutput
java.io.IOException
public void writeDouble(double v) throws java.io.IOException
writeDouble
in interface java.io.DataOutput
java.io.IOException
public void writeFloat(float v) throws java.io.IOException
writeFloat
in interface java.io.DataOutput
java.io.IOException
public void writeInt(int v) throws java.io.IOException
writeInt
in interface java.io.DataOutput
java.io.IOException
public void writeLong(long v) throws java.io.IOException
writeLong
in interface java.io.DataOutput
java.io.IOException
public void writeShort(int v) throws java.io.IOException
writeShort
in interface java.io.DataOutput
java.io.IOException
public void writeUTF(java.lang.String str) throws java.io.IOException
writeUTF
in interface java.io.DataOutput
java.io.IOException
public boolean readBoolean() throws java.io.IOException
readBoolean
in interface java.io.DataInput
java.io.IOException
public byte readByte() throws java.io.IOException
readByte
in interface java.io.DataInput
java.io.IOException
public char readChar() throws java.io.IOException
readChar
in interface java.io.DataInput
java.io.IOException
public double readDouble() throws java.io.IOException
readDouble
in interface java.io.DataInput
java.io.IOException
public float readFloat() throws java.io.IOException
readFloat
in interface java.io.DataInput
java.io.IOException
public void readFully(byte[] b) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public void readFully(byte[] b, int off, int len) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public int readInt() throws java.io.IOException
readInt
in interface java.io.DataInput
java.io.IOException
public java.lang.String readLine() throws java.io.IOException
readLine
in interface java.io.DataInput
java.io.IOException
public long readLong() throws java.io.IOException
readLong
in interface java.io.DataInput
java.io.IOException
public short readShort() throws java.io.IOException
readShort
in interface java.io.DataInput
java.io.IOException
public java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
java.io.IOException
public int readUnsignedByte() throws java.io.IOException
readUnsignedByte
in interface java.io.DataInput
java.io.IOException
public int readUnsignedShort() throws java.io.IOException
readUnsignedShort
in interface java.io.DataInput
java.io.IOException
public RandomAccessStorage copy() throws java.io.IOException
RandomAccessStorage
copy
in interface RandomAccessStorage
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |