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

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.lazy.LazyPrimitive<Long>
      extended by org.apache.hadoop.hive.serde2.lazy.LazyLong
All Implemented Interfaces:
LazyObject

public class LazyLong
extends LazyPrimitive<Long>

LazyObject for storing a value of Long.

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.


Constructor Summary
LazyLong()
           
 
Method Summary
 void init(ByteArrayRef bytes, int start, int length)
          Set the data for this LazyObject.
static long parseLong(byte[] bytes, int start, int length)
          Parses the string argument as if it was a long value and returns the result.
static long parseLong(byte[] bytes, int start, int length, int radix)
          Parses the string argument as if it was an long value and returns the result.
 
Methods inherited from class org.apache.hadoop.hive.serde2.lazy.LazyPrimitive
getObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyLong

public LazyLong()
Method Detail

init

public void init(ByteArrayRef bytes,
                 int start,
                 int length)
Description copied from interface: LazyObject
Set the data for this LazyObject. 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.

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

parseLong

public static long parseLong(byte[] bytes,
                             int start,
                             int length)
                      throws NumberFormatException
Parses the string argument as if it was a long value and returns the result. Throws NumberFormatException if the string does not represent a long quantity.

Parameters:
bytes -
start -
length - a UTF-8 encoded string representation of a long quantity.
Returns:
long the value represented by the argument
Throws:
NumberFormatException - if the argument could not be parsed as a long quantity.

parseLong

public static long parseLong(byte[] bytes,
                             int start,
                             int length,
                             int radix)
                      throws NumberFormatException
Parses the string argument as if it was an long value and returns the result. Throws NumberFormatException if the string does not represent an long quantity. The second argument specifies the radix to use when parsing the value.

Parameters:
bytes -
start -
length - a UTF-8 encoded string representation of a long 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 long quantity.


Copyright © 2009 The Apache Software Foundation