void markSelected(String fieldName) { for (int i = 0; i < typeInfo.getAllStructFieldNames().size(); ++i) { if (typeInfo.getAllStructFieldNames().get(i).equalsIgnoreCase(fieldName)) { selected[i] = true; break; } } }
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; } }
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); }
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)); } } }
@Override public String toString() { return getClass().toString() + "[" + Arrays.asList(serdeParams.getSeparators()) + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()) .getAllStructFieldNames() + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()) .getAllStructFieldTypeInfos() + "]"; }
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}; }
@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}; }
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()); }
@Override public String toString() { return getClass().toString() + "[" + Arrays.asList(serdeParams.getSeparators()) + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()).getAllStructFieldNames() + ":" + ((StructTypeInfo) serdeParams.getRowTypeInfo()) .getAllStructFieldTypeInfos() + "]"; }
private boolean canCoerceForStruct(HiveType fromHiveType, HiveType toHiveType) { if (!fromHiveType.getCategory().equals(Category.STRUCT) || !toHiveType.getCategory().equals(Category.STRUCT)) { return false; } List<String> fromFieldNames = ((StructTypeInfo) fromHiveType.getTypeInfo()).getAllStructFieldNames(); List<String> toFieldNames = ((StructTypeInfo) toHiveType.getTypeInfo()).getAllStructFieldNames(); List<HiveType> fromFieldTypes = extractStructFieldTypes(fromHiveType); List<HiveType> toFieldTypes = extractStructFieldTypes(toHiveType); // Rule: // * Fields may be added or dropped from the end. // * For all other field indices, the corresponding fields must have // the same name, and the type must be coercible. for (int i = 0; i < min(fromFieldTypes.size(), toFieldTypes.size()); i++) { if (!fromFieldNames.get(i).equals(toFieldNames.get(i))) { return false; } if (!fromFieldTypes.get(i).equals(toFieldTypes.get(i)) && !canCoerce(fromFieldTypes.get(i), toFieldTypes.get(i))) { return false; } } return true; } }
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 StringArrayOI(StructTypeInfo type) { List<String> names = type.getAllStructFieldNames(); List<ObjectInspector> ois = new ArrayList<ObjectInspector>(); for (int i = 0; i < names.size(); i++) { ois.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector); } init(names, ois, null); }
private SlashSeparatedOI(StructTypeInfo type) { List<String> names = type.getAllStructFieldNames(); List<ObjectInspector> ois = new ArrayList<ObjectInspector>(); for (int i = 0; i < names.size(); i++) { ois.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector); } init(names, ois, null); }
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 HCatSchema constructHCatSchema(StructTypeInfo stypeInfo) throws HCatException { CollectionBuilder builder = getStructSchemaBuilder(); for (String fieldName : stypeInfo.getAllStructFieldNames()) { builder.addField(getHCatFieldSchema(fieldName, stypeInfo.getStructFieldTypeInfo(fieldName), null)); } return builder.build(); }
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)); }
private void doStructFieldTests(Random random) throws Exception { String structTypeName = VectorRandomRowSource.getDecoratedTypeName( random, "struct", SupportedTypes.ALL, /* allowedTypeNameSet */ null, /* depth */ 0, /* maxDepth */ 2); StructTypeInfo structTypeInfo = (StructTypeInfo) TypeInfoUtils.getTypeInfoFromTypeString(structTypeName); List<String> fieldNameList = structTypeInfo.getAllStructFieldNames(); final int fieldCount = fieldNameList.size(); for (int fieldIndex = 0; fieldIndex < fieldCount; fieldIndex++) { doOneStructFieldTest(random, structTypeInfo, structTypeName, fieldIndex); } }