com.google.cloud.bigtable.hbase.util
Class ZeroCopyByteStringUtil
- java.lang.Object
-
- com.google.cloud.bigtable.hbase.util.ZeroCopyByteStringUtil
-
public final class ZeroCopyByteStringUtil extends Object
Helper class to extract byte arrays fromByteString
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).
- Version:
- $Id: $Id
- Author:
- sduskis
-
-
Constructor Summary
Constructors Constructor and Description ZeroCopyByteStringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static byte[]
get(ByteString byteString)
Extracts the byte array from the givenByteString
without copy.static ByteString
wrap(byte[] array)
Wraps a byte array in aByteString
without copying it.
-
-
-
Method Detail
-
wrap
public static ByteString wrap(byte[] array)
Wraps a byte array in aByteString
without copying it.- Parameters:
array
- an array of byte.- Returns:
- a
ByteString
object.
-
get
public static byte[] get(ByteString byteString)
Extracts the byte array from the givenByteString
without copy.- Parameters:
byteString
- AByteString
from which to extract the array.- Returns:
- an array of byte.
-
-