if (fastSkips) { ((org.apache.hadoop.hive.serde2.thrift.SkippableTProtocol) iprot) .skip(mt.getType()); } else { TProtocolUtil.skip(iprot, mt.getType()); struct.set(orderedId, mt.deserialize(struct.get(orderedId), iprot)); if (thrift_mode) { iprot.readFieldEnd();
public static ObjectInspector dynamicSerDeStructBaseToObjectInspector( DynamicSerDeTypeBase bt) throws SerDeException { if (bt.isList()) { return ObjectInspectorFactory .getStandardListObjectInspector(dynamicSerDeStructBaseToObjectInspector(((DynamicSerDeTypeList) bt) .getElementType())); } else if (bt.isMap()) { DynamicSerDeTypeMap btMap = (DynamicSerDeTypeMap) bt; return ObjectInspectorFactory.getStandardMapObjectInspector( dynamicSerDeStructBaseToObjectInspector(btMap.getKeyType()), dynamicSerDeStructBaseToObjectInspector(btMap.getValueType())); } else if (bt.isPrimitive()) { PrimitiveTypeEntry pte = PrimitiveObjectInspectorUtils .getTypeEntryFromPrimitiveJavaClass(bt.getRealType()); return PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(pte.primitiveCategory); } else {
public void initialize() { if (types_by_id == null) { // multiple means of lookup types_by_id = new HashMap<Integer, DynamicSerDeTypeBase>(); types_by_column_name = new HashMap<String, DynamicSerDeTypeBase>(); ordered_types = new DynamicSerDeTypeBase[jjtGetNumChildren()]; ordered_column_id_by_name = new HashMap<String, Integer>(); // put them in and also roll them up while we're at it // a Field contains a FieldType which in turn contains a type for (int i = 0; i < jjtGetNumChildren(); i++) { DynamicSerDeField mt = getField(i); DynamicSerDeTypeBase type = mt.getFieldType().getMyType(); // types get initialized in case they need to setup any // internal data structures - e.g., DynamicSerDeStructBase type.initialize(); type.fieldid = mt.fieldid; type.name = mt.name; types_by_id.put(Integer.valueOf(mt.fieldid), type); types_by_column_name.put(mt.name, type); ordered_types[i] = type; ordered_column_id_by_name.put(mt.name, i); } } }
@Override public void serialize(Object o, ObjectInspector oi, TProtocol oprot) throws TException, SerDeException, NoSuchFieldException, IllegalAccessException { ListObjectInspector loi = (ListObjectInspector) oi; Set<Object> set = (Set<Object>) o; DynamicSerDeTypeBase mt = getElementType(); tset = new TSet(mt.getType(), set.size()); oprot.writeSetBegin(tset); for (Object element : set) { mt.serialize(element, loi.getListElementObjectInspector(), oprot); } // in theory, the below call isn't needed in non thrift_mode, but let's not // get too crazy oprot.writeSetEnd(); } }
for (int i = 0; i < thelist.size; i++) { if (i + 1 > deserializeReuse.size()) { deserializeReuse.add(getElementType().deserialize(null, iprot)); } else { deserializeReuse.set(i, getElementType().deserialize( deserializeReuse.get(i), iprot));
@Override public Class getRealType() { try { Class c = getElementType().getRealType(); Object o = c.newInstance(); Set<?> l = Collections.singleton(o); return l.getClass(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
@Override public void serialize(Object o, ObjectInspector oi, TProtocol oprot) throws TException, SerDeException, NoSuchFieldException, IllegalAccessException { DynamicSerDeTypeBase keyType = getKeyType(); DynamicSerDeTypeBase valueType = getValueType(); WriteNullsProtocol nullProtocol = (oprot instanceof WriteNullsProtocol) ? (WriteNullsProtocol) oprot : null; assert (oi.getCategory() == ObjectInspector.Category.MAP); MapObjectInspector moi = (MapObjectInspector) oi; ObjectInspector koi = moi.getMapKeyObjectInspector(); ObjectInspector voi = moi.getMapValueObjectInspector(); Map<?, ?> map = moi.getMap(o); serializeMap = new TMap(keyType.getType(), valueType.getType(), map.size()); oprot.writeMapBegin(serializeMap); for (Object element : map.entrySet()) { Map.Entry it = (Map.Entry) element; Object key = it.getKey(); Object value = it.getValue(); keyType.serialize(key, koi, oprot); if (value == null) { assert (nullProtocol != null); nullProtocol.writeNull(); } else { valueType.serialize(value, voi, oprot); } } // in theory, the below call isn't needed in non thrift_mode, but let's not // get too crazy oprot.writeMapEnd(); }
@Override public String toString() { return "set<" + getElementType().toString() + ">"; }
@Override public Map<Object, Object> deserialize(Object reuse, TProtocol iprot) throws SerDeException, TException, IllegalAccessException { Map<Object, Object> deserializeReuse; if (reuse != null && reuse.getClass() == LinkedHashMap.class) { deserializeReuse = (Map<Object, Object>) reuse; deserializeReuse.clear(); } else { deserializeReuse = new LinkedHashMap<Object, Object>(); } TMap themap = iprot.readMapBegin(); if (themap == null) { return null; } // themap might be reused by the Protocol. int mapSize = themap.size; for (int i = 0; i < mapSize; i++) { Object key = getKeyType().deserialize(null, iprot); Object value = getValueType().deserialize(null, iprot); deserializeReuse.put(key, value); } // in theory, the below call isn't needed in non thrift_mode, but let's not // get too crazy iprot.readMapEnd(); return deserializeReuse; }
@Override public Class getRealType() { try { Class c = getKeyType().getRealType(); Class c2 = getValueType().getRealType(); Object o = c.newInstance(); Object o2 = c2.newInstance(); Map<?, ?> l = Collections.singletonMap(o, o2); return l.getClass(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
public static ObjectInspector dynamicSerDeStructBaseToObjectInspector( DynamicSerDeTypeBase bt) throws SerDeException { if (bt.isList()) { return ObjectInspectorFactory .getStandardListObjectInspector(dynamicSerDeStructBaseToObjectInspector(((DynamicSerDeTypeList) bt) .getElementType())); } else if (bt.isMap()) { DynamicSerDeTypeMap btMap = (DynamicSerDeTypeMap) bt; return ObjectInspectorFactory.getStandardMapObjectInspector( dynamicSerDeStructBaseToObjectInspector(btMap.getKeyType()), dynamicSerDeStructBaseToObjectInspector(btMap.getValueType())); } else if (bt.isPrimitive()) { PrimitiveTypeEntry pte = PrimitiveObjectInspectorUtils .getTypeEntryFromPrimitiveJavaClass(bt.getRealType()); return PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(pte.primitiveCategory); } else {
@Override public String toString() { return serdeConstants.LIST_TYPE_NAME + "<" + getElementType().toString() + ">"; }
if (fastSkips) { ((org.apache.hadoop.hive.serde2.thrift.SkippableTProtocol) iprot) .skip(mt.getType()); } else { TProtocolUtil.skip(iprot, mt.getType()); struct.set(orderedId, mt.deserialize(struct.get(orderedId), iprot)); if (thrift_mode) { iprot.readFieldEnd();
/** * NOTE: Set is not supported by Hive yet. */ @Override public Object deserialize(Object reuse, TProtocol iprot) throws SerDeException, TException, IllegalAccessException { TSet theset = iprot.readSetBegin(); if (theset == null) { return null; } Set<Object> result; if (reuse != null) { result = (Set<Object>) reuse; result.clear(); } else { result = new HashSet<Object>(); } for (int i = 0; i < theset.size; i++) { Object elem = getElementType().deserialize(null, iprot); result.add(elem); } // in theory, the below call isn't needed in non thrift_mode, but let's not // get too crazy iprot.readSetEnd(); return result; }
@Override public Class getRealType() { try { Class c = getElementType().getRealType(); Object o = c.newInstance(); Set<?> l = Collections.singleton(o); return l.getClass(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
public void initialize() { if (types_by_id == null) { // multiple means of lookup types_by_id = new HashMap<Integer, DynamicSerDeTypeBase>(); types_by_column_name = new HashMap<String, DynamicSerDeTypeBase>(); ordered_types = new DynamicSerDeTypeBase[jjtGetNumChildren()]; ordered_column_id_by_name = new HashMap<String, Integer>(); // put them in and also roll them up while we're at it // a Field contains a FieldType which in turn contains a type for (int i = 0; i < jjtGetNumChildren(); i++) { DynamicSerDeField mt = getField(i); DynamicSerDeTypeBase type = mt.getFieldType().getMyType(); // types get initialized in case they need to setup any // internal data structures - e.g., DynamicSerDeStructBase type.initialize(); type.fieldid = mt.fieldid; type.name = mt.name; types_by_id.put(Integer.valueOf(mt.fieldid), type); types_by_column_name.put(mt.name, type); ordered_types[i] = type; ordered_column_id_by_name.put(mt.name, i); } } }
oprot.writeListBegin(new TList(mt.getType(), list.size())); for (Object element : list) { if (element == null) { nullProtocol.writeNull(); } else { mt.serialize(element, elementObjectInspector, oprot); oprot.writeListBegin(new TList(mt.getType(), list.length)); for (Object element : list) { if (element == null && nullProtocol != null) { nullProtocol.writeNull(); } else { mt.serialize(element, elementObjectInspector, oprot);
public static ObjectInspector dynamicSerDeStructBaseToObjectInspector( DynamicSerDeTypeBase bt) throws SerDeException { if (bt.isList()) { return ObjectInspectorFactory .getStandardListObjectInspector(dynamicSerDeStructBaseToObjectInspector(((DynamicSerDeTypeList) bt) .getElementType())); } else if (bt.isMap()) { DynamicSerDeTypeMap btMap = (DynamicSerDeTypeMap) bt; return ObjectInspectorFactory.getStandardMapObjectInspector( dynamicSerDeStructBaseToObjectInspector(btMap.getKeyType()), dynamicSerDeStructBaseToObjectInspector(btMap.getValueType())); } else if (bt.isPrimitive()) { PrimitiveTypeEntry pte = PrimitiveObjectInspectorUtils .getTypeEntryFromPrimitiveJavaClass(bt.getRealType()); return PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(pte.primitiveCategory); } else {