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.


Method Summary
 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.
 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, hashCode
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

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)

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.


Copyright © 2014 The Apache Software Foundation. All rights reserved.