|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jcs.auxiliary.disk.block.BlockDisk
public class BlockDisk
This class manages reading an writing data to disk. When asked to write a value, it returns a block array. It can read an object from the block numbers in a byte array.
Field Summary | |
---|---|
static byte |
HEADER_SIZE_BYTES
The size of the header that indicates the amount of data stored in an occupied block. |
Constructor Summary | |
---|---|
BlockDisk(java.io.File file)
Constructor for the Disk object |
|
BlockDisk(java.io.File file,
int blockSizeBytes)
Creates the file and set the block size in bytes. |
Method Summary | |
---|---|
protected int |
calculateByteOffsetForBlock(int block)
Calcuates the file offset for a particular block. |
protected int |
calculateTheNumberOfBlocksNeeded(byte[] data)
The number of blocks needed. |
protected void |
close()
Closes the raf. |
protected void |
freeBlocks(int[] blocksToFree)
Add these blocks to the emptyBlock list. |
protected long |
getAveragePutSizeBytes()
|
protected byte[][] |
getBlockChunks(byte[] complete,
int numBlocksNeeded)
Return the amount to put in each block. |
protected int |
getBlockSizeBytes()
|
protected int |
getEmptyBlocks()
|
protected int |
getNumberOfBlocks()
|
protected long |
length()
Returns the raf length. |
protected java.io.Serializable |
read(int[] blockNumbers)
Reads an object that is located in the specified blocks. |
protected static byte[] |
serialize(java.io.Serializable obj)
Returns the serialized form of the given object in a byte array. |
java.lang.String |
toString()
For debugging only. |
protected int[] |
write(java.io.Serializable object)
This writes an object to disk and returns the blocks it was stored in. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte HEADER_SIZE_BYTES
Constructor Detail |
---|
public BlockDisk(java.io.File file) throws java.io.FileNotFoundException
file
-
java.io.FileNotFoundException
public BlockDisk(java.io.File file, int blockSizeBytes) throws java.io.FileNotFoundException
file
- blockSizeBytes
-
java.io.FileNotFoundException
Method Detail |
---|
protected int[] write(java.io.Serializable object) throws java.io.IOException
The program flow is as follows:
object
-
java.io.IOException
protected byte[][] getBlockChunks(byte[] complete, int numBlocksNeeded)
complete
- numBlocksNeeded
-
protected java.io.Serializable read(int[] blockNumbers) throws java.io.IOException, java.lang.ClassNotFoundException
blockNumbers
-
java.io.IOException
java.lang.ClassNotFoundException
protected void freeBlocks(int[] blocksToFree)
blocksToFree
- protected int calculateByteOffsetForBlock(int block)
block
-
protected int calculateTheNumberOfBlocksNeeded(byte[] data)
data
-
protected long length() throws java.io.IOException
java.io.IOException
protected void close() throws java.io.IOException
java.io.IOException
protected static byte[] serialize(java.io.Serializable obj) throws java.io.IOException
Use the Serilizer abstraction layer.
obj
-
java.io.IOException
protected int getNumberOfBlocks()
protected int getBlockSizeBytes()
protected long getAveragePutSizeBytes()
protected int getEmptyBlocks()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |