|
||||||||||
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 | |
---|---|
protected IElementSerializer |
elementSerializer
The serializer. |
static byte |
HEADER_SIZE_BYTES
The size of the header that indicates the amount of data stored in an occupied block. |
Constructor Summary | |
---|---|
BlockDisk(File file,
IElementSerializer elementSerializer)
Constructor for the Disk object |
|
BlockDisk(File file,
int blockSizeBytes)
Creates the file and set the block size in bytes. |
|
BlockDisk(File file,
int blockSizeBytes,
IElementSerializer elementSerializer)
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 String |
getFilePath()
This is used for debugging. |
protected int |
getNumberOfBlocks()
|
protected long |
length()
Returns the raf length. |
protected Serializable |
read(int[] blockNumbers)
Reads an object that is located in the specified blocks. |
String |
toString()
For debugging only. |
protected int[] |
write(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
protected IElementSerializer elementSerializer
Constructor Detail |
---|
public BlockDisk(File file, IElementSerializer elementSerializer) throws FileNotFoundException
file
- elementSerializer
-
FileNotFoundException
public BlockDisk(File file, int blockSizeBytes) throws FileNotFoundException
file
- blockSizeBytes
-
FileNotFoundException
public BlockDisk(File file, int blockSizeBytes, IElementSerializer elementSerializer) throws FileNotFoundException
file
- blockSizeBytes
- elementSerializer
-
FileNotFoundException
Method Detail |
---|
protected int[] write(Serializable object) throws IOException
The program flow is as follows:
object
-
IOException
protected byte[][] getBlockChunks(byte[] complete, int numBlocksNeeded)
complete
- numBlocksNeeded
-
protected Serializable read(int[] blockNumbers) throws IOException, ClassNotFoundException
blockNumbers
-
IOException
ClassNotFoundException
protected void freeBlocks(int[] blocksToFree)
blocksToFree
- protected int calculateByteOffsetForBlock(int block)
block
-
protected int calculateTheNumberOfBlocksNeeded(byte[] data)
data
-
protected long length() throws IOException
IOException
protected void close() throws IOException
IOException
protected int getNumberOfBlocks()
protected int getBlockSizeBytes()
protected long getAveragePutSizeBytes()
protected int getEmptyBlocks()
public String toString()
toString
in class Object
protected String getFilePath()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |