org.elasticsearch.hadoop.hive
Class FastBytesWritable

java.lang.Object
  extended by org.apache.hadoop.io.BinaryComparable
      extended by org.elasticsearch.hadoop.hive.FastBytesWritable
All Implemented Interfaces:
Comparable<BinaryComparable>, Writable, WritableComparable<BinaryComparable>

public class FastBytesWritable
extends BinaryComparable
implements WritableComparable<BinaryComparable>

Replacement of BytesWritable that allows direct access to the underlying byte array without copying.


Nested Class Summary
static class FastBytesWritable.Comparator
           
 
Constructor Summary
FastBytesWritable()
           
FastBytesWritable(byte[] bytes, int size)
          Create a BytesWritable using the byte array as the initial value.
 
Method Summary
 boolean equals(Object right_obj)
          Are the two byte sequences equal?
 byte[] getBytes()
          Get the data from the BytesWritable.
 int getLength()
          Get the current size of the buffer.
 int hashCode()
           
 void readFields(DataInput in)
           
 void set(byte[] bytes, int size)
           
 String toString()
          Generate the stream of bytes as hex pairs separated by ' '.
 void write(DataOutput out)
           
 
Methods inherited from class org.apache.hadoop.io.BinaryComparable
compareTo, compareTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

FastBytesWritable

public FastBytesWritable()

FastBytesWritable

public FastBytesWritable(byte[] bytes,
                         int size)
Create a BytesWritable using the byte array as the initial value.

Parameters:
bytes - This array becomes the backing storage for the object.
Method Detail

getLength

public int getLength()
Get the current size of the buffer.

Specified by:
getLength in class BinaryComparable

set

public void set(byte[] bytes,
                int size)

getBytes

public byte[] getBytes()
Get the data from the BytesWritable.

Specified by:
getBytes in class BinaryComparable
Returns:
The data is only valid between 0 and getLength() - 1.

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface Writable
Throws:
IOException

hashCode

public int hashCode()
Overrides:
hashCode in class BinaryComparable

equals

public boolean equals(Object right_obj)
Are the two byte sequences equal?

Overrides:
equals in class BinaryComparable

toString

public String toString()
Generate the stream of bytes as hex pairs separated by ' '.

Overrides:
toString in class Object