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

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive
      extended by org.apache.hadoop.hive.serde2.lazy.LazyMap
All Implemented Interfaces:
LazyObject

public class LazyMap
extends LazyNonPrimitive

LazyMap stores a map of Primitive LazyObjects to LazyObjects. Note that the keys of the map cannot contain null. LazyMap does not deal with the case of a NULL map. That is handled by LazyMapObjectInspector.


Field Summary
 
Fields inherited from class org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive
bytes, length, start
 
Constructor Summary
protected LazyMap(TypeInfo typeInfo)
          Construct a LazyMap object with the TypeInfo.
 
Method Summary
protected  void enlargeArrays()
          Enlarge the size of arrays storing information for the elements inside the array.
 Map<Object,Object> getMap(byte itemSeparator, byte keyValueSeparator, org.apache.hadoop.io.Text nullSequence)
          Return the map object representing this LazyMap.
 int getMapSize(byte itemSeparator, byte keyValueSeparator, org.apache.hadoop.io.Text nullSequence)
          Get the size of the map represented by this LazyMap.
 Object getMapValueElement(byte itemSeparator, byte keyValueSeparator, org.apache.hadoop.io.Text nullSequence, Object key)
          Get the value in the map for the key.
 void init(ByteArrayRef bytes, int start, int length)
          Set the row data for this LazyArray.
 
Methods inherited from class org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive
getObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyMap

protected LazyMap(TypeInfo typeInfo)
Construct a LazyMap object with the TypeInfo.

Parameters:
typeInfo - the TypeInfo representing the type of this LazyMap.
Method Detail

init

public void init(ByteArrayRef bytes,
                 int start,
                 int length)
Set the row data for this LazyArray.

Specified by:
init in interface LazyObject
Overrides:
init in class LazyNonPrimitive
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:
LazyObject.init(ByteArrayRef, int, int)

enlargeArrays

protected void enlargeArrays()
Enlarge the size of arrays storing information for the elements inside the array.


getMapValueElement

public Object getMapValueElement(byte itemSeparator,
                                 byte keyValueSeparator,
                                 org.apache.hadoop.io.Text nullSequence,
                                 Object key)
Get the value in the map for the key. If there are multiple matches (which is possible in the serialized format), only the first one is returned. The most efficient way to get the value for the key is to serialize the key and then try to find it in the array. We do linear search because in most cases, user only wants to get one or two values out of the map, and the cost of building up a HashMap is substantially higher.

Parameters:
itemSeparator - The separator between different entries.
keyValueSeparator - The separator between key and value.
nullSequence - The byte sequence representing NULL.
key - The key object that we are looking for.
Returns:
The corresponding value object, or NULL if not found

getMap

public Map<Object,Object> getMap(byte itemSeparator,
                                 byte keyValueSeparator,
                                 org.apache.hadoop.io.Text nullSequence)
Return the map object representing this LazyMap. Note that the keyObjects will be Java primitive objects.

Parameters:
itemSeparator - The separator between different entries.
keyValueSeparator - The separator between key and value.
nullSequence - The byte sequence representing NULL.
Returns:
the map object

getMapSize

public int getMapSize(byte itemSeparator,
                      byte keyValueSeparator,
                      org.apache.hadoop.io.Text nullSequence)
Get the size of the map represented by this LazyMap.

Parameters:
itemSeparator - The separator between different entries.
keyValueSeparator - The separator between key and value.
nullSequence - The byte sequence representing NULL.
Returns:
The size of the map, -1 for NULL map.


Copyright © 2009 The Apache Software Foundation