public final class LazyUtils extends Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
falseBytes |
static byte[] |
trueBytes |
Modifier and Type | Method and Description |
---|---|
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 void |
copyAndEscapeStringDataToText(byte[] inputBytes,
int start,
int length,
byte escapeChar,
org.apache.hadoop.io.Text data) |
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 byte |
getByte(String altValue,
byte defaultVal)
Return the byte value of the number string.
|
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.
|
public static int digit(int b, int radix)
b
- The ascii code of the characterradix
- The radixpublic static int compare(byte[] b1, int start1, int length1, byte[] b2, int start2, int length2)
public static String convertToString(byte[] bytes, int start, int length)
bytes
- The byte[] containing the UTF-8 String.start
- The start position inside the bytes.length
- The length of the data, starting from "start"public static void writeEscaped(OutputStream out, byte[] bytes, int start, int len, boolean escaped, byte escapeChar, boolean[] needsEscape) throws IOException
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 256.IOException
public static void writePrimitiveUTF8(OutputStream out, Object o, PrimitiveObjectInspector oi, boolean escaped, byte escapeChar, boolean[] needsEscape) throws IOException
out
- The UTF8 byte OutputStreamo
- The primitive ObjectneedsEscape
- Whether a character needs escaping.IOException
public static void writePrimitive(OutputStream out, Object o, PrimitiveObjectInspector oi) throws IOException
out
- ByteStream.Output, an unsynchronized version of ByteArrayOutputStream, used as a
backing buffer for the the DataOutputStreamo
- the PrimitiveObjectoi
- the PrimitiveObjectInspectorIOException
- on error during the write operationpublic static int hashBytes(byte[] data, int start, int len)
public static byte[] createByteArray(org.apache.hadoop.io.BytesWritable sourceBw)
sourceBw
- - source BytesWritablepublic static void copyAndEscapeStringDataToText(byte[] inputBytes, int start, int length, byte escapeChar, org.apache.hadoop.io.Text data)
public static byte getByte(String altValue, byte defaultVal)
altValue
- The string containing a number.defaultVal
- If the altValue does not represent a number, return the
defaultVal.Copyright © 2017 The Apache Software Foundation. All rights reserved.