org.apache.hadoop.hive.serde2.objectinspector
Class StandardMapObjectInspector

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.objectinspector.StandardMapObjectInspector
All Implemented Interfaces:
Cloneable, MapObjectInspector, ObjectInspector, SettableMapObjectInspector
Direct Known Subclasses:
LazyBinaryMapObjectInspector

public class StandardMapObjectInspector
extends Object
implements SettableMapObjectInspector

StandardMapObjectInspector works on map data that is stored as a Java Map object. Note: the key object of the map must support equals and hashCode by itself. We also plan to have a GeneralMapObjectInspector which can work on map with key objects that does not support equals and hashCode. That will require us to store InspectableObject as the key, which will have overridden equals and hashCode methods. Always use the ObjectInspectorFactory to create new ObjectInspector objects, instead of directly creating an instance of this class.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector
ObjectInspector.Category
 
Constructor Summary
protected StandardMapObjectInspector(ObjectInspector mapKeyObjectInspector, ObjectInspector mapValueObjectInspector)
          Call ObjectInspectorFactory.getStandardMapObjectInspector instead.
 
Method Summary
 Object clear(Object map)
          Clear the map.
 Object create()
          Create an empty map.
 ObjectInspector.Category getCategory()
          An ObjectInspector must inherit from one of the following interfaces if getCategory() returns: PRIMITIVE: PrimitiveObjectInspector LIST: ListObjectInspector MAP: MapObjectInspector STRUCT: StructObjectInspector.
 Map<?,?> getMap(Object data)
          returns null for data = null.
 ObjectInspector getMapKeyObjectInspector()
           
 int getMapSize(Object data)
          returns -1 for NULL map.
 Object getMapValueElement(Object data, Object key)
           
 ObjectInspector getMapValueObjectInspector()
           
 String getTypeName()
          Returns the name of the data type that is inspected by this ObjectInspector.
 Object put(Object map, Object key, Object value)
          Add a key-value pair to the map.
 Object remove(Object map, Object key)
          Remove a key-value pair from the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardMapObjectInspector

protected StandardMapObjectInspector(ObjectInspector mapKeyObjectInspector,
                                     ObjectInspector mapValueObjectInspector)
Call ObjectInspectorFactory.getStandardMapObjectInspector instead.

Method Detail

getMapKeyObjectInspector

public ObjectInspector getMapKeyObjectInspector()
Specified by:
getMapKeyObjectInspector in interface MapObjectInspector

getMapValueObjectInspector

public ObjectInspector getMapValueObjectInspector()
Specified by:
getMapValueObjectInspector in interface MapObjectInspector

getMapValueElement

public Object getMapValueElement(Object data,
                                 Object key)
Specified by:
getMapValueElement in interface MapObjectInspector

getMapSize

public int getMapSize(Object data)
Description copied from interface: MapObjectInspector
returns -1 for NULL map.

Specified by:
getMapSize in interface MapObjectInspector

getMap

public Map<?,?> getMap(Object data)
Description copied from interface: MapObjectInspector
returns null for data = null. Note: This method should not return a Map object that is reused by the same MapObjectInspector, because it's possible that the same MapObjectInspector will be used in multiple places in the code. However it's OK if the Map object is part of the Object data.

Specified by:
getMap in interface MapObjectInspector

getCategory

public final ObjectInspector.Category getCategory()
Description copied from interface: ObjectInspector
An ObjectInspector must inherit from one of the following interfaces if getCategory() returns: PRIMITIVE: PrimitiveObjectInspector LIST: ListObjectInspector MAP: MapObjectInspector STRUCT: StructObjectInspector.

Specified by:
getCategory in interface ObjectInspector

getTypeName

public String getTypeName()
Description copied from interface: ObjectInspector
Returns the name of the data type that is inspected by this ObjectInspector. This is used to display the type information to the user. For primitive types, the type name is standardized. For other types, the type name can be something like "list", "map", java class names, or user-defined type names similar to typedef.

Specified by:
getTypeName in interface ObjectInspector

create

public Object create()
Description copied from interface: SettableMapObjectInspector
Create an empty map.

Specified by:
create in interface SettableMapObjectInspector

clear

public Object clear(Object map)
Description copied from interface: SettableMapObjectInspector
Clear the map. Return the map.

Specified by:
clear in interface SettableMapObjectInspector

put

public Object put(Object map,
                  Object key,
                  Object value)
Description copied from interface: SettableMapObjectInspector
Add a key-value pair to the map. Return the map.

Specified by:
put in interface SettableMapObjectInspector

remove

public Object remove(Object map,
                     Object key)
Description copied from interface: SettableMapObjectInspector
Remove a key-value pair from the map. Return the map.

Specified by:
remove in interface SettableMapObjectInspector


Copyright © 2011 The Apache Software Foundation