@Test public void testGetFlatFields() { RowTypeInfo typeInfo1 = new RowTypeInfo(typeList, new String[]{"int", "row", "string"}); List<FlatFieldDescriptor> result = new ArrayList<>(); typeInfo1.getFlatFields("row.*", 0, result); assertEquals(2, result.size()); assertEquals( new FlatFieldDescriptor(1, BasicTypeInfo.SHORT_TYPE_INFO).toString(), result.get(0).toString()); assertEquals( new FlatFieldDescriptor(2, BasicTypeInfo.BIG_DEC_TYPE_INFO).toString(), result.get(1).toString()); result.clear(); typeInfo1.getFlatFields("string", 0, result); assertEquals(1, result.size()); assertEquals( new FlatFieldDescriptor(3, BasicTypeInfo.STRING_TYPE_INFO).toString(), result.get(0).toString()); }
@Override public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) { Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression); if (!matcher.matches()) { throw new InvalidFieldReferenceException( "Invalid tuple field reference \"" + fieldExpression + "\"."); } String field = matcher.group(0); if ((field.equals(ExpressionKeys.SELECT_ALL_CHAR)) || (field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA))) { int keyPosition = 0; for (TypeInformation<?> fType : types) { if (fType instanceof CompositeType) { CompositeType<?> cType = (CompositeType<?>) fType; cType.getFlatFields(ExpressionKeys.SELECT_ALL_CHAR, offset + keyPosition, result); keyPosition += cType.getTotalFields() - 1; } else { result.add(new FlatFieldDescriptor(offset + keyPosition, fType)); } keyPosition++; } } else { field = matcher.group(1); Matcher intFieldMatcher = PATTERN_INT_FIELD.matcher(field); int fieldIndex; if (intFieldMatcher.matches()) { fieldIndex = Integer.valueOf(field); } else { fieldIndex = this.getFieldIndex(field); } TypeInformation<?> fieldType = this.getTypeAt(fieldIndex); for (int i = 0; i < fieldIndex; i++) { offset += this.getTypeAt(i).getTotalFields(); } String tail = matcher.group(3); if (tail == null) { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields("*", offset, result); } else { result.add(new FlatFieldDescriptor(offset, fieldType)); } } else { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields(tail, offset, result); } else { throw new InvalidFieldReferenceException( "Nested field expression \"" + tail + "\" not possible on atomic type " + fieldType + "."); } } } }
RowTypeInfo extends TupleTypeInfoBase<Row> { @Override public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) { Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression); if (!matcher.matches()) { throw new InvalidFieldReferenceException( "Invalid tuple field reference \"" + fieldExpression + "\"."); } String field = matcher.group(0); if ((field.equals(ExpressionKeys.SELECT_ALL_CHAR)) || (field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA))) { int keyPosition = 0; for (TypeInformation<?> fType : types) { if (fType instanceof CompositeType) { CompositeType<?> cType = (CompositeType<?>) fType; cType.getFlatFields(ExpressionKeys.SELECT_ALL_CHAR, offset + keyPosition, result); keyPosition += cType.getTotalFields() - 1; } else { result.add(new FlatFieldDescriptor(offset + keyPosition, fType)); } keyPosition++; } } else { field = matcher.group(1); Matcher intFieldMatcher = PATTERN_INT_FIELD.matcher(field); int fieldIndex; if (intFieldMatcher.matches()) { fieldIndex = Integer.valueOf(field); } else { fieldIndex = this.getFieldIndex(field); } TypeInformation<?> fieldType = this.getTypeAt(fieldIndex); for (int i = 0; i < fieldIndex; i++) { offset += this.getTypeAt(i).getTotalFields(); } String tail = matcher.group(3); if (tail == null) { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields("*", offset, result); } else { result.add(new FlatFieldDescriptor(offset, fieldType)); } } else { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields(tail, offset, result); } else { throw new InvalidFieldReferenceException( "Nested field expression \"" + tail + "\" not possible on atomic type " + fieldType + "."); } } } } }
RowTypeInfo extends TupleTypeInfoBase<Row> { @Override public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) { Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression); if (!matcher.matches()) { throw new InvalidFieldReferenceException( "Invalid tuple field reference \"" + fieldExpression + "\"."); } String field = matcher.group(0); if ((field.equals(ExpressionKeys.SELECT_ALL_CHAR)) || (field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA))) { int keyPosition = 0; for (TypeInformation<?> fType : types) { if (fType instanceof CompositeType) { CompositeType<?> cType = (CompositeType<?>) fType; cType.getFlatFields(ExpressionKeys.SELECT_ALL_CHAR, offset + keyPosition, result); keyPosition += cType.getTotalFields() - 1; } else { result.add(new FlatFieldDescriptor(offset + keyPosition, fType)); } keyPosition++; } } else { field = matcher.group(1); Matcher intFieldMatcher = PATTERN_INT_FIELD.matcher(field); int fieldIndex; if (intFieldMatcher.matches()) { fieldIndex = Integer.valueOf(field); } else { fieldIndex = this.getFieldIndex(field); } TypeInformation<?> fieldType = this.getTypeAt(fieldIndex); for (int i = 0; i < fieldIndex; i++) { offset += this.getTypeAt(i).getTotalFields(); } String tail = matcher.group(3); if (tail == null) { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields("*", offset, result); } else { result.add(new FlatFieldDescriptor(offset, fieldType)); } } else { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields(tail, offset, result); } else { throw new InvalidFieldReferenceException( "Nested field expression \"" + tail + "\" not possible on atomic type " + fieldType + "."); } } } } RowTypeInfo(TypeInformation<?>... types);  RowTypeInfo(TypeInformation<?>[] types, String[] fieldNames); }
RowTypeInfo extends TupleTypeInfoBase<Row> { @Override public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) { Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression); if (!matcher.matches()) { throw new InvalidFieldReferenceException( "Invalid tuple field reference \"" + fieldExpression + "\"."); } String field = matcher.group(0); if ((field.equals(ExpressionKeys.SELECT_ALL_CHAR)) || (field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA))) { int keyPosition = 0; for (TypeInformation<?> fType : types) { if (fType instanceof CompositeType) { CompositeType<?> cType = (CompositeType<?>) fType; cType.getFlatFields(ExpressionKeys.SELECT_ALL_CHAR, offset + keyPosition, result); keyPosition += cType.getTotalFields() - 1; } else { result.add(new FlatFieldDescriptor(offset + keyPosition, fType)); } keyPosition++; } } else { field = matcher.group(1); Matcher intFieldMatcher = PATTERN_INT_FIELD.matcher(field); int fieldIndex; if (intFieldMatcher.matches()) { fieldIndex = Integer.valueOf(field); } else { fieldIndex = this.getFieldIndex(field); } TypeInformation<?> fieldType = this.getTypeAt(fieldIndex); for (int i = 0; i < fieldIndex; i++) { offset += this.getTypeAt(i).getTotalFields(); } String tail = matcher.group(3); if (tail == null) { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields("*", offset, result); } else { result.add(new FlatFieldDescriptor(offset, fieldType)); } } else { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields(tail, offset, result); } else { throw new InvalidFieldReferenceException( "Nested field expression \"" + tail + "\" not possible on atomic type " + fieldType + "."); } } } } RowTypeInfo(TypeInformation<?>... types);  RowTypeInfo(TypeInformation<?>[] types, String[] fieldNames); @Override void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result); @Override TypeInformation<X> getTypeAt(String fieldExpression); @Override TypeComparator<Row> createComparator(
		int[] logicalKeyFields,
		boolean[] orders,
		int logicalFieldOffset,
		ExecutionConfig config); @Override String[] getFieldNames(); @Override int getFieldIndex(String fieldName); @Override TypeSerializer<Row> createSerializer(ExecutionConfig config); @Override boolean canEqual(Object obj); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); TypeInformation<?>[] getFieldTypes(); boolean schemaEquals(Object obj); static RowTypeInfo projectFields(RowTypeInfo rowType, int[] fieldMapping); }
RowTypeInfo extends TupleTypeInfoBase<Row> { @Override public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) { Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression); if (!matcher.matches()) { throw new InvalidFieldReferenceException( "Invalid tuple field reference \"" + fieldExpression + "\"."); } String field = matcher.group(0); if ((field.equals(ExpressionKeys.SELECT_ALL_CHAR)) || (field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA))) { int keyPosition = 0; for (TypeInformation<?> fType : types) { if (fType instanceof CompositeType) { CompositeType<?> cType = (CompositeType<?>) fType; cType.getFlatFields(ExpressionKeys.SELECT_ALL_CHAR, offset + keyPosition, result); keyPosition += cType.getTotalFields() - 1; } else { result.add(new FlatFieldDescriptor(offset + keyPosition, fType)); } keyPosition++; } } else { field = matcher.group(1); Matcher intFieldMatcher = PATTERN_INT_FIELD.matcher(field); int fieldIndex; if (intFieldMatcher.matches()) { fieldIndex = Integer.valueOf(field); } else { fieldIndex = this.getFieldIndex(field); } TypeInformation<?> fieldType = this.getTypeAt(fieldIndex); for (int i = 0; i < fieldIndex; i++) { offset += this.getTypeAt(i).getTotalFields(); } String tail = matcher.group(3); if (tail == null) { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields("*", offset, result); } else { result.add(new FlatFieldDescriptor(offset, fieldType)); } } else { if (fieldType instanceof CompositeType) { ((CompositeType) fieldType).getFlatFields(tail, offset, result); } else { throw new InvalidFieldReferenceException( "Nested field expression \"" + tail + "\" not possible on atomic type " + fieldType + "."); } } } } RowTypeInfo(TypeInformation<?>... types);  RowTypeInfo(TypeInformation<?>[] types, String[] fieldNames); @Override void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result); @Override TypeInformation<X> getTypeAt(String fieldExpression); @Override TypeComparator<Row> createComparator(
		int[] logicalKeyFields,
		boolean[] orders,
		int logicalFieldOffset,
		ExecutionConfig config); @Override String[] getFieldNames(); @Override int getFieldIndex(String fieldName); @Override TypeSerializer<Row> createSerializer(ExecutionConfig config); @Override boolean canEqual(Object obj); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); TypeInformation<?>[] getFieldTypes(); boolean schemaEquals(Object obj); static RowTypeInfo projectFields(RowTypeInfo rowType, int[] fieldMapping);  }