public static boolean lazyCompareStruct(StructTypeInfo structTypeInfo, List<Object> fields, List<Object> expectedFields) { ArrayList<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos(); final int size = fieldTypeInfos.size(); for (int i = 0; i < size; i++) { Object lazyEleObj = fields.get(i); Object expectedEleObj = expectedFields.get(i); if (!lazyCompare(fieldTypeInfos.get(i), lazyEleObj, expectedEleObj)) { throw new RuntimeException("SerDe deserialized value does not match"); } } return true; }
PrunedStructTypeInfo(StructTypeInfo typeInfo) { this.typeInfo = typeInfo; this.children = new HashMap<>(); this.selected = new boolean[typeInfo.getAllStructFieldTypeInfos().size()]; for (int i = 0; i < typeInfo.getAllStructFieldTypeInfos().size(); ++i) { TypeInfo ti = typeInfo.getAllStructFieldTypeInfos().get(i); if (ti.getCategory() == Category.STRUCT) { this.children.put(typeInfo.getAllStructFieldNames().get(i).toLowerCase(), new PrunedStructTypeInfo((StructTypeInfo) ti)); } } }
public void setStructValue(Object structValue) throws HiveException { StructTypeInfo structTypeInfo = (StructTypeInfo) outputTypeInfo; ArrayList<TypeInfo> fieldTypeInfoList = structTypeInfo.getAllStructFieldTypeInfos(); final int size = fieldTypeInfoList.size(); this.structValue = new ConstantVectorExpression[size]; List<Object> fieldValueList = (List<Object>) structValue; for (int i = 0; i < size; i++) { this.structValue[i] = create(i, fieldValueList.get(i), fieldTypeInfoList.get(i)); } }
private void init() { inputScale = ((DecimalTypeInfo) inputTypeInfo).getScale(); StructTypeInfo structTypeInfo = (StructTypeInfo) outputTypeInfo; outputDecimalTypeInfo = (DecimalTypeInfo) structTypeInfo.getAllStructFieldTypeInfos().get(AVERAGE_SUM_FIELD_INDEX); }
private static Properties getTablePropertiesFromStructTypeInfo(StructTypeInfo structTypeInfo) { Properties table = new Properties(); table.setProperty("columns", String.join(",", structTypeInfo.getAllStructFieldNames())); table.setProperty("columns.types", String.join( ",", Lists.transform( structTypeInfo.getAllStructFieldTypeInfos(), new Function<TypeInfo, String>() { @Nullable @Override public String apply(@Nullable TypeInfo typeInfo) { return typeInfo.getTypeName(); } } ) )); return table; } }
public static RelDataType convert(StructTypeInfo structType, final RelDataTypeFactory dtFactory) throws CalciteSemanticException { List<RelDataType> fTypes = new ArrayList<RelDataType>(structType.getAllStructFieldTypeInfos().size()); for (TypeInfo ti : structType.getAllStructFieldTypeInfos()) { fTypes.add(convert(ti,dtFactory)); } return dtFactory.createStructType(fTypes, structType.getAllStructFieldNames()); }
OrcStructInspector(StructTypeInfo info) { ArrayList<String> fieldNames = info.getAllStructFieldNames(); ArrayList<TypeInfo> fieldTypes = info.getAllStructFieldTypeInfos(); fields = new ArrayList<StructField>(fieldNames.size()); for(int i=0; i < fieldNames.size(); ++i) { fields.add(new Field(fieldNames.get(i), createObjectInspector(fieldTypes.get(i)), i)); } }
private Object deserializeStruct(GenericData.Record datum, Schema fileSchema, StructTypeInfo columnType) throws AvroSerdeException { // No equivalent Java type for the backing structure, need to recurse and build a list ArrayList<TypeInfo> innerFieldTypes = columnType.getAllStructFieldTypeInfos(); ArrayList<String> innerFieldNames = columnType.getAllStructFieldNames(); List<Object> innerObjectRow = new ArrayList<Object>(innerFieldTypes.size()); return workerBase(innerObjectRow, fileSchema, innerFieldNames, innerFieldTypes, datum); }
public static List<HiveType> extractStructFieldTypes(HiveType hiveType) { return ((StructTypeInfo) hiveType.getTypeInfo()).getAllStructFieldTypeInfos().stream() .map(typeInfo -> HiveType.valueOf(typeInfo.getTypeName())) .collect(toImmutableList()); }
private void init() { StructTypeInfo structTypeInfo = (StructTypeInfo) outputTypeInfo; outputDecimalTypeInfo = (DecimalTypeInfo) structTypeInfo.getAllStructFieldTypeInfos().get(AVERAGE_SUM_FIELD_INDEX); sumScale = outputDecimalTypeInfo.scale(); sumPrecision = outputDecimalTypeInfo.precision(); }
@SuppressWarnings({"unchecked"}) private static ArrayList<? extends Object>[] getTypeMap( StructObjectInspector oi) { StructTypeInfo t = (StructTypeInfo) TypeInfoUtils .getTypeInfoFromObjectInspector(oi); ArrayList<String> fnames = t.getAllStructFieldNames(); ArrayList<TypeInfo> fields = t.getAllStructFieldTypeInfos(); return new ArrayList<?>[] {fnames, fields}; }
private static ArrayList<? extends Object>[] getTypeMap( StructObjectInspector oi) { StructTypeInfo t = (StructTypeInfo) TypeInfoUtils .getTypeInfoFromObjectInspector(oi); ArrayList<String> fnames = t.getAllStructFieldNames(); ArrayList<TypeInfo> fields = t.getAllStructFieldTypeInfos(); return new ArrayList<?>[] {fnames, fields}; }
@Override public String toString() { return getClass().toString() + "[" + Arrays.asList(serdeParams.getSeparators()) + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()) .getAllStructFieldNames() + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()) .getAllStructFieldTypeInfos() + "]"; }
@Override public String toString() { return getClass().toString() + "[" + Arrays.asList(serdeParams.getSeparators()) + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()).getAllStructFieldNames() + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()) .getAllStructFieldTypeInfos() + "]"; }
private static GroupType convertStructType(final String name, final StructTypeInfo typeInfo) { final List<String> columnNames = typeInfo.getAllStructFieldNames(); final List<TypeInfo> columnTypes = typeInfo.getAllStructFieldTypeInfos(); return new GroupType(Repetition.OPTIONAL, name, convertTypes(columnNames, columnTypes)); }
public static boolean isSupportedType(TypeInfo typeInfo) { switch (typeInfo.getCategory()) { case PRIMITIVE: return getPrimitiveType((PrimitiveTypeInfo) typeInfo) != null; case MAP: MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo; return isSupportedType(mapTypeInfo.getMapKeyTypeInfo()) && isSupportedType(mapTypeInfo.getMapValueTypeInfo()); case LIST: ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo; return isSupportedType(listTypeInfo.getListElementTypeInfo()); case STRUCT: StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo; return structTypeInfo.getAllStructFieldTypeInfos().stream() .allMatch(HiveType::isSupportedType); } return false; }
private static boolean isWritableType(TypeInfo typeInfo) { switch (typeInfo.getCategory()) { case PRIMITIVE: PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); return isWritablePrimitiveType(primitiveCategory); case MAP: MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo; return isWritableType(mapTypeInfo.getMapKeyTypeInfo()) && isWritableType(mapTypeInfo.getMapValueTypeInfo()); case LIST: ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo; return isWritableType(listTypeInfo.getListElementTypeInfo()); case STRUCT: StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo; return structTypeInfo.getAllStructFieldTypeInfos().stream().allMatch(HiveWriteUtils::isWritableType); } return false; }
private static GroupType convertStructType(final String name, final StructTypeInfo typeInfo) { final List<String> columnNames = typeInfo.getAllStructFieldNames(); final List<TypeInfo> columnTypes = typeInfo.getAllStructFieldTypeInfos(); return new GroupType(Repetition.OPTIONAL, name, convertTypes(columnNames, columnTypes)); }
private static GroupType convertStructType(final String name, final StructTypeInfo typeInfo, final Repetition repetition) { final List<String> columnNames = typeInfo.getAllStructFieldNames(); final List<TypeInfo> columnTypes = typeInfo.getAllStructFieldTypeInfos(); return new GroupType(repetition, name, convertTypes(columnNames, columnTypes)); }
private static GroupType convertStructType(final String name, final StructTypeInfo typeInfo, final Repetition repetition) { final List<String> columnNames = typeInfo.getAllStructFieldNames(); final List<TypeInfo> columnTypes = typeInfo.getAllStructFieldTypeInfos(); return new GroupType(repetition, name, convertTypes(columnNames, columnTypes)); }