Package org.apache.accumulo.core.util
Class UnsynchronizedBuffer.Writer
- java.lang.Object
-
- org.apache.accumulo.core.util.UnsynchronizedBuffer.Writer
-
- Enclosing class:
- UnsynchronizedBuffer
public static class UnsynchronizedBuffer.Writer extends Object
A byte buffer writer.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(boolean b)
Adds a Boolean value to this writer's buffer.void
add(byte[] bytes, int off, int length)
Adds bytes to this writer's buffer.int
size()
byte[]
toArray()
Gets (a copy of) the contents of this writer's buffer.ByteBuffer
toByteBuffer()
Gets aByteBuffer
wrapped around this writer's buffer.void
writeVInt(int i)
Adds an integer value to this writer's buffer.void
writeVLong(long i)
Adds a long value to this writer's buffer.
-
-
-
Method Detail
-
add
public void add(byte[] bytes, int off, int length)
Adds bytes to this writer's buffer.- Parameters:
bytes
- byte arrayoff
- offset into array to start copying byteslength
- number of bytes to add- Throws:
IndexOutOfBoundsException
- if off or length are invalid
-
add
public void add(boolean b)
Adds a Boolean value to this writer's buffer.- Parameters:
b
- Boolean value
-
toArray
public byte[] toArray()
Gets (a copy of) the contents of this writer's buffer.- Returns:
- byte buffer contents
-
toByteBuffer
public ByteBuffer toByteBuffer()
Gets aByteBuffer
wrapped around this writer's buffer.- Returns:
- byte buffer
-
writeVInt
public void writeVInt(int i)
Adds an integer value to this writer's buffer. The integer is encoded as a variable-length list of bytes. SeewriteVLong(long)
for a description of the encoding.- Parameters:
i
- integer value
-
writeVLong
public void writeVLong(long i)
Adds a long value to this writer's buffer. The long is encoded as a variable-length list of bytes. For a description of the encoding scheme, seeWritableUtils.writeVLong()
in the Hadoop API. [link]- Parameters:
i
- long value
-
size
public int size()
-
-