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

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.lazy.LazyObjectBase
      extended by org.apache.hadoop.hive.serde2.lazy.LazyObject<OI>
          extended by org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive<LazyMapObjectInspector>
              extended by org.apache.hadoop.hive.serde2.lazy.LazyMap

public class LazyMap
extends LazyNonPrimitive<LazyMapObjectInspector>

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 the parent LazyObject.


Field Summary
protected  LinkedHashMap<Object,Object> cachedMap
          cachedMap is reused for different calls to getMap().
 
Fields inherited from class org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive
bytes, length, start
 
Fields inherited from class org.apache.hadoop.hive.serde2.lazy.LazyObject
oi
 
Constructor Summary
protected LazyMap(LazyMapObjectInspector oi)
          Construct a LazyMap object with the ObjectInspector.
 
Method Summary
protected  void enlargeArrays()
          Enlarge the size of arrays storing information for the elements inside the array.
 Map<Object,Object> getMap()
          Return the map object representing this LazyMap.
 int getMapSize()
          Get the size of the map represented by this LazyMap.
 Object getMapValueElement(Object key)
          Get the value in the map for the key.
protected  boolean getParsed()
           
 void init(ByteArrayRef bytes, int start, int length)
          Set the row data for this LazyArray.
protected  void setParsed(boolean parsed)
           
 
Methods inherited from class org.apache.hadoop.hive.serde2.lazy.LazyNonPrimitive
getObject, hashCode
 
Methods inherited from class org.apache.hadoop.hive.serde2.lazy.LazyObject
getInspector, setInspector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cachedMap

protected LinkedHashMap<Object,Object> cachedMap
cachedMap is reused for different calls to getMap(). But each LazyMap has a separate cachedMap so we won't overwrite the data by accident.

Constructor Detail

LazyMap

protected LazyMap(LazyMapObjectInspector oi)
Construct a LazyMap object with the ObjectInspector.

Method Detail

init

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

Overrides:
init in class LazyNonPrimitive<LazyMapObjectInspector>
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:
LazyObjectBase.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(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:
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()
Return the map object representing this LazyMap. Note that the keyObjects will be Writable primitive objects.

Returns:
the map object

getMapSize

public int getMapSize()
Get the size of the map represented by this LazyMap.

Returns:
The size of the map, -1 for NULL map.

getParsed

protected boolean getParsed()

setParsed

protected void setParsed(boolean parsed)


Copyright © 2013 The Apache Software Foundation