public final class HBaseZeroCopyByteString
extends LiteralByteString
ByteString
without copy.
Without this protobufs would force us to copy every single byte array out of the objects de-serialized from the wire (which already do one copy, on top of the copies the JVM does to go from kernel buffer to C buffer and from C buffer to JVM buffer).
Modifier and Type | Method and Description |
---|---|
static ByteString |
wrap(byte[] array)
Wraps a byte array in a
ByteString without copying it. |
static ByteString |
wrap(byte[] array,
int offset,
int length)
Wraps a subset of a byte array in a
ByteString without copying it. |
static byte[] |
zeroCopyGetBytes(ByteString buf)
Extracts the byte array from the given
ByteString without copy. |
public static ByteString wrap(byte[] array)
ByteString
without copying it.public static ByteString wrap(byte[] array, int offset, int length)
ByteString
without copying it.public static byte[] zeroCopyGetBytes(ByteString buf)
ByteString
without copy.buf
- A buffer from which to extract the array. This buffer must be
actually an instance of a LiteralByteString
.