com.google.protobuf
Class HBaseZeroCopyByteString

java.lang.Object
  extended by com.google.protobuf.ByteString
      extended by com.google.protobuf.HBaseZeroCopyByteString
All Implemented Interfaces:
Iterable<Byte>

public final class HBaseZeroCopyByteString
extends com.google.protobuf.ByteString

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).

Since:
0.96.1

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.protobuf.ByteString
com.google.protobuf.ByteString.ByteIterator, com.google.protobuf.ByteString.Output
 
Field Summary
protected  byte[] bytes
           
 
Fields inherited from class com.google.protobuf.ByteString
EMPTY
 
Method Summary
 ByteBuffer asReadOnlyByteBuffer()
           
 List<ByteBuffer> asReadOnlyByteBufferList()
           
 byte byteAt(int arg0)
           
 void copyTo(ByteBuffer arg0)
           
protected  void copyToInternal(byte[] arg0, int arg1, int arg2, int arg3)
           
 boolean equals(Object arg0)
           
protected  int getOffsetIntoBytes()
           
protected  int getTreeDepth()
           
 int hashCode()
           
protected  boolean isBalanced()
           
 boolean isValidUtf8()
           
 com.google.protobuf.ByteString.ByteIterator iterator()
           
 com.google.protobuf.CodedInputStream newCodedInput()
           
 InputStream newInput()
           
protected  int partialHash(int arg0, int arg1, int arg2)
           
protected  int partialIsValidUtf8(int arg0, int arg1, int arg2)
           
protected  int peekCachedHashCode()
           
 int size()
           
 com.google.protobuf.ByteString substring(int arg0, int arg1)
           
 String toString(String arg0)
           
static com.google.protobuf.ByteString wrap(byte[] array)
          Wraps a byte array in a ByteString without copying it.
static com.google.protobuf.ByteString wrap(byte[] array, int offset, int length)
          Wraps a subset of a byte array in a ByteString without copying it.
 void writeTo(OutputStream arg0)
           
static byte[] zeroCopyGetBytes(com.google.protobuf.ByteString buf)
          Extracts the byte array from the given ByteString without copy.
 
Methods inherited from class com.google.protobuf.ByteString
concat, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFromUtf8, copyTo, copyTo, isEmpty, newOutput, newOutput, readFrom, readFrom, readFrom, startsWith, substring, toByteArray, toString, toStringUtf8
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bytes

protected final byte[] bytes
Method Detail

wrap

public static com.google.protobuf.ByteString wrap(byte[] array)
Wraps a byte array in a ByteString without copying it.


wrap

public static com.google.protobuf.ByteString wrap(byte[] array,
                                                  int offset,
                                                  int length)
Wraps a subset of a byte array in a ByteString without copying it.


zeroCopyGetBytes

public static byte[] zeroCopyGetBytes(com.google.protobuf.ByteString buf)
Extracts the byte array from the given ByteString without copy.

Parameters:
buf - A buffer from which to extract the array. This buffer must be actually an instance of a LiteralByteString.

byteAt

public byte byteAt(int arg0)
Specified by:
byteAt in class com.google.protobuf.ByteString

size

public int size()
Specified by:
size in class com.google.protobuf.ByteString

substring

public com.google.protobuf.ByteString substring(int arg0,
                                                int arg1)
Specified by:
substring in class com.google.protobuf.ByteString

copyToInternal

protected void copyToInternal(byte[] arg0,
                              int arg1,
                              int arg2,
                              int arg3)
Specified by:
copyToInternal in class com.google.protobuf.ByteString

copyTo

public void copyTo(ByteBuffer arg0)
Specified by:
copyTo in class com.google.protobuf.ByteString

asReadOnlyByteBuffer

public ByteBuffer asReadOnlyByteBuffer()
Specified by:
asReadOnlyByteBuffer in class com.google.protobuf.ByteString

asReadOnlyByteBufferList

public List<ByteBuffer> asReadOnlyByteBufferList()
Specified by:
asReadOnlyByteBufferList in class com.google.protobuf.ByteString

writeTo

public void writeTo(OutputStream arg0)
             throws IOException
Specified by:
writeTo in class com.google.protobuf.ByteString
Throws:
IOException

toString

public String toString(String arg0)
                throws UnsupportedEncodingException
Specified by:
toString in class com.google.protobuf.ByteString
Throws:
UnsupportedEncodingException

isValidUtf8

public boolean isValidUtf8()
Specified by:
isValidUtf8 in class com.google.protobuf.ByteString

partialIsValidUtf8

protected int partialIsValidUtf8(int arg0,
                                 int arg1,
                                 int arg2)
Specified by:
partialIsValidUtf8 in class com.google.protobuf.ByteString

equals

public boolean equals(Object arg0)
Specified by:
equals in class com.google.protobuf.ByteString

hashCode

public int hashCode()
Specified by:
hashCode in class com.google.protobuf.ByteString

peekCachedHashCode

protected int peekCachedHashCode()
Specified by:
peekCachedHashCode in class com.google.protobuf.ByteString

partialHash

protected int partialHash(int arg0,
                          int arg1,
                          int arg2)
Specified by:
partialHash in class com.google.protobuf.ByteString

newInput

public InputStream newInput()
Specified by:
newInput in class com.google.protobuf.ByteString

newCodedInput

public com.google.protobuf.CodedInputStream newCodedInput()
Specified by:
newCodedInput in class com.google.protobuf.ByteString

iterator

public com.google.protobuf.ByteString.ByteIterator iterator()
Specified by:
iterator in interface Iterable<Byte>
Overrides:
iterator in class com.google.protobuf.ByteString

getTreeDepth

protected int getTreeDepth()
Specified by:
getTreeDepth in class com.google.protobuf.ByteString

isBalanced

protected boolean isBalanced()
Specified by:
isBalanced in class com.google.protobuf.ByteString

getOffsetIntoBytes

protected int getOffsetIntoBytes()


Copyright © 2015 The Apache Software Foundation. All Rights Reserved.