Search in sources :

Example 26 with MapTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo in project cdap by caskdata.

the class ObjectDeserializer method deserializeMap.

@SuppressWarnings("unchecked")
private Object deserializeMap(Object mapField, MapTypeInfo typeInfo, Map.Entry<Schema, Schema> mapSchema) throws NoSuchFieldException, IllegalAccessException {
    Map<Object, Object> ourMap = (Map) mapField;
    TypeInfo keyType = typeInfo.getMapKeyTypeInfo();
    TypeInfo valType = typeInfo.getMapValueTypeInfo();
    Schema keySchema = mapSchema.getKey();
    Schema valSchema = mapSchema.getValue();
    Map translatedMap = Maps.newHashMap();
    for (Map.Entry entry : ourMap.entrySet()) {
        translatedMap.put(deserializeField(entry.getKey(), keyType, keySchema), deserializeField(entry.getValue(), valType, valSchema));
    }
    return translatedMap;
}
Also used : Schema(co.cask.cdap.api.data.schema.Schema) Map(java.util.Map) MapTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo) ListTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo) StructTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo) PrimitiveTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo) TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)

Aggregations

MapTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo)24 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)22 StructTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo)21 ListTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo)20 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)20 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 Map (java.util.Map)7 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)7 UnionTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.UnionTypeInfo)7 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)5 DecimalTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo)4 List (java.util.List)3 CharTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo)3 PrestoException (com.facebook.presto.spi.PrestoException)2 ImmutableList (com.google.common.collect.ImmutableList)2 Schema (org.apache.avro.Schema)2 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)2 ByteWritable (org.apache.hadoop.hive.serde2.io.ByteWritable)2 DateWritable (org.apache.hadoop.hive.serde2.io.DateWritable)2