Modifier and Type | Field and Description |
---|---|
static byte |
HEADER_SIZE_BYTES
The size of the header that indicates the amount of data stored in an occupied block.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
protected int |
calculateByteOffsetForBlock(int block)
Deprecated.
(since 2.0) use
calculateByteOffsetForBlockAsLong(int) instead |
protected long |
calculateByteOffsetForBlockAsLong(int block)
Calculates the file offset for a particular block.
|
protected int |
calculateTheNumberOfBlocksNeeded(byte[] data)
The number of blocks needed.
|
protected void |
close()
Closes the file.
|
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 file length.
|
protected <T extends Serializable> |
read(int[] blockNumbers)
Reads an object that is located in the specified blocks.
|
protected void |
reset()
Resets the file.
|
String |
toString()
For debugging only.
|
protected int[] |
write(Serializable object)
This writes an object to disk and returns the blocks it was stored in.
|
public static final byte HEADER_SIZE_BYTES
public BlockDisk(File file, IElementSerializer elementSerializer) throws IOException
file
- elementSerializer
- IOException
public BlockDisk(File file, int blockSizeBytes) throws IOException
file
- blockSizeBytes
- IOException
public BlockDisk(File file, int blockSizeBytes, IElementSerializer elementSerializer) throws IOException
file
- blockSizeBytes
- elementSerializer
- IOException
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 <T extends Serializable> T read(int[] blockNumbers) throws IOException, ClassNotFoundException
blockNumbers
- IOException
ClassNotFoundException
protected void freeBlocks(int[] blocksToFree)
blocksToFree
- @Deprecated protected int calculateByteOffsetForBlock(int block)
calculateByteOffsetForBlockAsLong(int)
insteadblock
- numberprotected long calculateByteOffsetForBlockAsLong(int block)
block
- numberprotected int calculateTheNumberOfBlocksNeeded(byte[] data)
data
- protected long length() throws IOException
IOException
protected void close() throws IOException
IOException
protected void reset() throws IOException
IOException
protected int getNumberOfBlocks()
protected int getBlockSizeBytes()
protected long getAveragePutSizeBytes()
protected int getEmptyBlocks()
protected String getFilePath()
Copyright © 2002–2018 The Apache Software Foundation. All rights reserved.