public abstract class BlockHandler extends Object implements Closeable
Constructor and Description |
---|
BlockHandler() |
Modifier and Type | Method and Description |
---|---|
int |
append(long blockOffset,
byte[] buf,
int offset,
int length)
Append data to the block from a byte array
|
abstract int |
append(long blockOffset,
ByteBuffer srcBuf)
Appends data to the block from a ByteBuffer
|
abstract boolean |
delete()
Deletes the block
|
static BlockHandler |
get(String path)
Create a block handler according to path scheme
|
abstract ByteChannel |
getChannel()
Gets channel used to access block
|
abstract long |
getLength()
Gets the length of the block
|
abstract ByteBuffer |
read(long offset,
int length)
Reads data from block
|
public static BlockHandler get(String path) throws IOException, IllegalArgumentException
path
- the block pathIOException
IllegalArgumentException
public int append(long blockOffset, byte[] buf, int offset, int length) throws IOException
blockOffset
- starting position of the block filebuf
- the data bufferoffset
- the offset of the bufferlength
- the length of the dataIOException
public abstract int append(long blockOffset, ByteBuffer srcBuf) throws IOException
blockOffset
- starting position of the block filesrcBuf
- ByteBuffer that data is stored inIOException
public abstract boolean delete() throws IOException
IOException
public abstract ByteChannel getChannel()
public abstract long getLength() throws IOException
IOException
public abstract ByteBuffer read(long offset, int length) throws IOException
offset
- the offset from starting of the block filelength
- the length of data to read, -1 represents reading the rest of the blockIOException
Copyright © 2015. All Rights Reserved.