org.apache.hadoop.hive.serde2.lazy
Class LazyInteger
java.lang.Object
org.apache.hadoop.hive.serde2.lazy.LazyObjectBase
org.apache.hadoop.hive.serde2.lazy.LazyObject<OI>
org.apache.hadoop.hive.serde2.lazy.LazyPrimitive<LazyIntObjectInspector,org.apache.hadoop.io.IntWritable>
org.apache.hadoop.hive.serde2.lazy.LazyInteger
- Direct Known Subclasses:
- LazyDioInteger
public class LazyInteger
- extends LazyPrimitive<LazyIntObjectInspector,org.apache.hadoop.io.IntWritable>
LazyObject for storing a value of Integer.
Part of the code is adapted from Apache Harmony Project.
As with the specification, this implementation relied on code laid out in Henry S. Warren, Jr.'s Hacker's
Delight, (Addison Wesley, 2002) as well as The Aggregate's Magic Algorithms.
Fields inherited from class org.apache.hadoop.hive.serde2.lazy.LazyObject |
oi |
Method Summary |
void |
init(ByteArrayRef bytes,
int start,
int length)
Set the data for this LazyObjectBase. |
static int |
parseInt(byte[] bytes,
int start,
int length)
Parses the string argument as if it was an int value and returns the
result. |
static int |
parseInt(byte[] bytes,
int start,
int length,
int radix)
Parses the string argument as if it was an int value and returns the
result. |
static void |
writeUTF8(OutputStream out,
int i)
Writes out the text representation of an integer using base 10 to an
OutputStream in UTF-8 encoding. |
static void |
writeUTF8NoException(OutputStream out,
int i)
|
LazyInteger
public LazyInteger(LazyIntObjectInspector oi)
LazyInteger
public LazyInteger(LazyInteger copy)
init
public void init(ByteArrayRef bytes,
int start,
int length)
- Description copied from class:
LazyObjectBase
- Set the data for this LazyObjectBase. We take ByteArrayRef instead of byte[] so
that we will be able to drop the reference to byte[] by a single
assignment. The ByteArrayRef object can be reused across multiple rows.
- Specified by:
init
in class LazyObjectBase
- Parameters:
bytes
- The wrapper of the byte[].start
- The start position inside the bytes.length
- The length of the data, starting from "start"- See Also:
ByteArrayRef
parseInt
public static int parseInt(byte[] bytes,
int start,
int length)
- Parses the string argument as if it was an int value and returns the
result. Throws NumberFormatException if the string does not represent an
int quantity.
- Parameters:
bytes
- start
- length
- a UTF-8 encoded string representation of an int quantity.
- Returns:
- int the value represented by the argument
- Throws:
NumberFormatException
- if the argument could not be parsed as an int quantity.
parseInt
public static int parseInt(byte[] bytes,
int start,
int length,
int radix)
- Parses the string argument as if it was an int value and returns the
result. Throws NumberFormatException if the string does not represent an
int quantity. The second argument specifies the radix to use when parsing
the value.
- Parameters:
bytes
- start
- length
- a UTF-8 encoded string representation of an int quantity.radix
- the base to use for conversion.
- Returns:
- the value represented by the argument
- Throws:
NumberFormatException
- if the argument could not be parsed as an int quantity.
writeUTF8
public static void writeUTF8(OutputStream out,
int i)
throws IOException
- Writes out the text representation of an integer using base 10 to an
OutputStream in UTF-8 encoding.
Note: division by a constant (like 10) is much faster than division by a
variable. That's one of the reasons that we don't make radix a parameter
here.
- Parameters:
out
- the outputstream to write toi
- an int to write out
- Throws:
IOException
writeUTF8NoException
public static void writeUTF8NoException(OutputStream out,
int i)
Copyright © 2013 The Apache Software Foundation