Package alluxio.file
Class ByteArrayTargetBuffer
- java.lang.Object
-
- alluxio.file.ByteArrayTargetBuffer
-
- All Implemented Interfaces:
ReadTargetBuffer
public class ByteArrayTargetBuffer extends java.lang.Object implements ReadTargetBuffer
Target buffer backed by bytes array for zero-copy read from page store.
-
-
Constructor Summary
Constructors Constructor Description ByteArrayTargetBuffer(byte[] target, int offset)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
byteArray()
java.nio.ByteBuffer
byteBuffer()
java.nio.channels.WritableByteChannel
byteChannel()
int
offset()
void
offset(int newOffset)
Sets the new offset in the buffer.int
readFromFile(java.io.RandomAccessFile file, int length)
int
readFromInputStream(java.io.InputStream is, int length)
long
remaining()
void
writeBytes(byte[] srcArray, int srcOffset, int length)
void
writeBytes(io.netty.buffer.ByteBuf buf)
-
-
-
Method Detail
-
byteArray
public byte[] byteArray()
- Specified by:
byteArray
in interfaceReadTargetBuffer
- Returns:
- the byte array
-
byteBuffer
public java.nio.ByteBuffer byteBuffer()
- Specified by:
byteBuffer
in interfaceReadTargetBuffer
- Returns:
- the byte buffer
-
offset
public int offset()
- Specified by:
offset
in interfaceReadTargetBuffer
- Returns:
- offset in the buffer
-
offset
public void offset(int newOffset)
Description copied from interface:ReadTargetBuffer
Sets the new offset in the buffer.- Specified by:
offset
in interfaceReadTargetBuffer
- Parameters:
newOffset
- the new offset
-
remaining
public long remaining()
- Specified by:
remaining
in interfaceReadTargetBuffer
- Returns:
- the remaining for this buffer
-
writeBytes
public void writeBytes(byte[] srcArray, int srcOffset, int length)
- Specified by:
writeBytes
in interfaceReadTargetBuffer
-
writeBytes
public void writeBytes(io.netty.buffer.ByteBuf buf)
- Specified by:
writeBytes
in interfaceReadTargetBuffer
-
readFromFile
public int readFromFile(java.io.RandomAccessFile file, int length) throws java.io.IOException
- Specified by:
readFromFile
in interfaceReadTargetBuffer
- Returns:
- bytes read from the file
- Throws:
java.io.IOException
-
readFromInputStream
public int readFromInputStream(java.io.InputStream is, int length) throws java.io.IOException
- Specified by:
readFromInputStream
in interfaceReadTargetBuffer
- Returns:
- bytes read from input stream
- Throws:
java.io.IOException
-
byteChannel
public java.nio.channels.WritableByteChannel byteChannel()
- Specified by:
byteChannel
in interfaceReadTargetBuffer
- Returns:
- the writable channel
-
-