ZeroCopyByteStringUtil (Cloud Bigtable HBase Client for Java 1.12.0 API)

com.google.cloud.bigtable.hbase.util

Class ZeroCopyByteStringUtil



  • public final class ZeroCopyByteStringUtil
    extends Object
    Helper class to extract byte arrays from 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).

    Version:
    $Id: $Id
    Author:
    sduskis
    • Constructor Detail

      • ZeroCopyByteStringUtil

        public ZeroCopyByteStringUtil()
    • Method Detail

      • wrap

        public static ByteString wrap(byte[] array)
        Wraps a byte array in a ByteString 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 given ByteString without copy.
        Parameters:
        byteString - A ByteString from which to extract the array.
        Returns:
        an array of byte.