org.apache.hadoop.hive.serde2.columnar
Class BytesRefWritable

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.columnar.BytesRefWritable
All Implemented Interfaces:
Comparable<BytesRefWritable>, org.apache.hadoop.io.Writable

public class BytesRefWritable
extends Object
implements org.apache.hadoop.io.Writable, Comparable<BytesRefWritable>

BytesRefWritable referenced a section of byte array. It can be used to avoid unnecessary byte copy.


Field Summary
static BytesRefWritable ZeroBytesRefWritable
           
 
Constructor Summary
BytesRefWritable()
          Create a zero-size bytes.
BytesRefWritable(byte[] bytes)
          Create a BytesRefWritable referenced to the given bytes.
BytesRefWritable(byte[] data, int offset, int len)
          Create a BytesRefWritable referenced to one section of the given bytes.
BytesRefWritable(int length)
          Create a BytesRefWritable with length bytes.
BytesRefWritable(LazyDecompressionCallback lazyDecompressData, int offset, int len)
          Create a BytesRefWritable referenced to one section of the given bytes.
 
Method Summary
 int compareTo(BytesRefWritable other)
          
 boolean equals(Object right_obj)
          
 byte[] getBytesCopy()
          Returns a copy of the underlying bytes referenced by this instance.
 byte[] getData()
          Returns the underlying bytes.
 int getLength()
           
 int getStart()
           
 int hashCode()
          
 void readFields(DataInput in)
          Always reuse the bytes array if length of bytes array is equal or greater to the current record, otherwise create a new one.
 void set(byte[] newData, int offset, int len)
          readFields() will corrupt the array.
 void set(LazyDecompressionCallback newData, int offset, int len)
          readFields() will corrupt the array.
 String toString()
          
 void write(DataOutput out)
          
 void writeDataTo(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZeroBytesRefWritable

public static BytesRefWritable ZeroBytesRefWritable
Constructor Detail

BytesRefWritable

public BytesRefWritable()
Create a zero-size bytes.


BytesRefWritable

public BytesRefWritable(int length)
Create a BytesRefWritable with length bytes.


BytesRefWritable

public BytesRefWritable(byte[] bytes)
Create a BytesRefWritable referenced to the given bytes.


BytesRefWritable

public BytesRefWritable(byte[] data,
                        int offset,
                        int len)
Create a BytesRefWritable referenced to one section of the given bytes. The section is determined by argument offset and len.


BytesRefWritable

public BytesRefWritable(LazyDecompressionCallback lazyDecompressData,
                        int offset,
                        int len)
Create a BytesRefWritable referenced to one section of the given bytes. The argument lazyDecompressData refers to a LazyDecompressionCallback object. The arguments offset and len are referred to uncompressed bytes of lazyDecompressData. Use offset and len after uncompressing the data.

Method Detail

getBytesCopy

public byte[] getBytesCopy()
                    throws IOException
Returns a copy of the underlying bytes referenced by this instance.

Returns:
a new copied byte array
Throws:
IOException

getData

public byte[] getData()
               throws IOException
Returns the underlying bytes.

Throws:
IOException

set

public void set(byte[] newData,
                int offset,
                int len)
readFields() will corrupt the array. So use the set method whenever possible.

See Also:
readFields(DataInput)

set

public void set(LazyDecompressionCallback newData,
                int offset,
                int len)
readFields() will corrupt the array. So use the set method whenever possible.

See Also:
readFields(DataInput)

writeDataTo

public void writeDataTo(DataOutput out)
                 throws IOException
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Always reuse the bytes array if length of bytes array is equal or greater to the current record, otherwise create a new one. readFields will corrupt the array. Please use set() whenever possible.

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException
See Also:
set(byte[], int, int)

write

public void write(DataOutput out)
           throws IOException

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object

compareTo

public int compareTo(BytesRefWritable other)

Specified by:
compareTo in interface Comparable<BytesRefWritable>

equals

public boolean equals(Object right_obj)

Overrides:
equals in class Object

getLength

public int getLength()

getStart

public int getStart()


Copyright © 2013 The Apache Software Foundation