org.apache.hadoop.hive.serde2.lazy
Class LazyUtils

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.lazy.LazyUtils

public final class LazyUtils
extends Object

LazyUtils.


Field Summary
static byte[] falseBytes
           
static byte[] trueBytes
           
 
Method Summary
static int compare(byte[] b1, int start1, int length1, byte[] b2, int start2, int length2)
          Returns -1 if the first byte sequence is lexicographically less than the second; returns +1 if the second byte sequence is lexicographically less than the first; otherwise return 0.
static String convertToString(byte[] bytes, int start, int length)
          Convert a UTF-8 byte array to String.
static byte[] createByteArray(org.apache.hadoop.io.BytesWritable sourceBw)
          gets a byte[] with copy of data from source BytesWritable
static int digit(int b, int radix)
          Returns the digit represented by character b.
static void extractColumnInfo(Properties tbl, LazySimpleSerDe.SerDeParameters serdeParams, String serdeName)
           
static int hashBytes(byte[] data, int start, int len)
           
static void writeEscaped(OutputStream out, byte[] bytes, int start, int len, boolean escaped, byte escapeChar, boolean[] needsEscape)
          Write the bytes with special characters escaped.
static void writePrimitive(OutputStream out, Object o, PrimitiveObjectInspector oi)
          Write out a binary representation of a PrimitiveObject to a byte stream.
static void writePrimitiveUTF8(OutputStream out, Object o, PrimitiveObjectInspector oi, boolean escaped, byte escapeChar, boolean[] needsEscape)
          Write out the text representation of a Primitive Object to a UTF8 byte stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trueBytes

public static byte[] trueBytes

falseBytes

public static byte[] falseBytes
Method Detail

digit

public static int digit(int b,
                        int radix)
Returns the digit represented by character b.

Parameters:
b - The ascii code of the character
radix - The radix
Returns:
-1 if it's invalid

compare

public static int compare(byte[] b1,
                          int start1,
                          int length1,
                          byte[] b2,
                          int start2,
                          int length2)
Returns -1 if the first byte sequence is lexicographically less than the second; returns +1 if the second byte sequence is lexicographically less than the first; otherwise return 0.


convertToString

public static String convertToString(byte[] bytes,
                                     int start,
                                     int length)
Convert a UTF-8 byte array to String.

Parameters:
bytes - The byte[] containing the UTF-8 String.
start - The start position inside the bytes.
length - The length of the data, starting from "start"
Returns:
The unicode String

writeEscaped

public static void writeEscaped(OutputStream out,
                                byte[] bytes,
                                int start,
                                int len,
                                boolean escaped,
                                byte escapeChar,
                                boolean[] needsEscape)
                         throws IOException
Write the bytes with special characters escaped.

Parameters:
escaped - Whether the data should be written out in an escaped way.
escapeChar - if escaped, the char for prefixing special characters.
needsEscape - if escaped, whether a specific character needs escaping. This array should have size of 128.
Throws:
IOException

writePrimitiveUTF8

public static void writePrimitiveUTF8(OutputStream out,
                                      Object o,
                                      PrimitiveObjectInspector oi,
                                      boolean escaped,
                                      byte escapeChar,
                                      boolean[] needsEscape)
                               throws IOException
Write out the text representation of a Primitive Object to a UTF8 byte stream.

Parameters:
out - The UTF8 byte OutputStream
o - The primitive Object
needsEscape - Whether a character needs escaping. This array should have size of 128.
Throws:
IOException

writePrimitive

public static void writePrimitive(OutputStream out,
                                  Object o,
                                  PrimitiveObjectInspector oi)
                           throws IOException
Write out a binary representation of a PrimitiveObject to a byte stream.

Parameters:
out - ByteStream.Output, an unsynchronized version of ByteArrayOutputStream, used as a backing buffer for the the DataOutputStream
o - the PrimitiveObject
oi - the PrimitiveObjectInspector
Throws:
IOException - on error during the write operation

hashBytes

public static int hashBytes(byte[] data,
                            int start,
                            int len)

extractColumnInfo

public static void extractColumnInfo(Properties tbl,
                                     LazySimpleSerDe.SerDeParameters serdeParams,
                                     String serdeName)
                              throws SerDeException
Throws:
SerDeException

createByteArray

public static byte[] createByteArray(org.apache.hadoop.io.BytesWritable sourceBw)
gets a byte[] with copy of data from source BytesWritable

Parameters:
sourceBw - - source BytesWritable


Copyright © 2014 The Apache Software Foundation. All rights reserved.