private static <T> String getSerializerTree(TypeInformation<T> ti, int indent) { String ret = ""; if (ti instanceof CompositeType) { ret += StringUtils.repeat(' ', indent) + ti.getClass().getSimpleName() + "\n"; CompositeType<T> cti = (CompositeType<T>) ti; String[] fieldNames = cti.getFieldNames(); for (int i = 0; i < cti.getArity(); i++) { TypeInformation<?> fieldType = cti.getTypeAt(i); ret += StringUtils.repeat(' ', indent + 2) + fieldNames[i] + ":" + getSerializerTree(fieldType, indent); } } else { if (ti instanceof GenericTypeInfo) { ret += StringUtils.repeat(' ', indent) + "GenericTypeInfo (" + ti.getTypeClass().getSimpleName() + ")\n"; ret += getGenericTypeTree(ti.getTypeClass(), indent + 4); } else { ret += StringUtils.repeat(' ', indent) + ti.toString() + "\n"; } } return ret; }
/** * Creates a table schema from a {@link TypeInformation} instance. If the type information is * a {@link CompositeType}, the field names and types for the composite type are used to * construct the {@link TableSchema} instance. Otherwise, a table schema with a single field * is created. The field name is "f0" and the field type the provided type. * * @param typeInfo The {@link TypeInformation} from which the table schema is generated. * @return The table schema that was generated from the given {@link TypeInformation}. */ public static TableSchema fromTypeInfo(TypeInformation<?> typeInfo) { if (typeInfo instanceof CompositeType<?>) { final CompositeType<?> compositeType = (CompositeType<?>) typeInfo; // get field names and types from composite type final String[] fieldNames = compositeType.getFieldNames(); final TypeInformation<?>[] fieldTypes = new TypeInformation[fieldNames.length]; for (int i = 0; i < fieldTypes.length; i++) { fieldTypes[i] = compositeType.getTypeAt(i); } return new TableSchema(fieldNames, fieldTypes); } else { // create table schema with a single field named "f0" of the given type. return new TableSchema( new String[]{ATOMIC_TYPE_FIELD_NAME}, new TypeInformation<?>[]{typeInfo}); } }
String[] fieldNames = cType.getFieldNames(); this.originalKeyTypes = new TypeInformation<?>[keyPositions.length]; ArrayList<FlatFieldDescriptor> tmpList = new ArrayList<>();
private static <T> String getSerializerTree(TypeInformation<T> ti, int indent) { String ret = ""; if (ti instanceof CompositeType) { ret += StringUtils.repeat(' ', indent) + ti.getClass().getSimpleName() + "\n"; CompositeType<T> cti = (CompositeType<T>) ti; String[] fieldNames = cti.getFieldNames(); for (int i = 0; i < cti.getArity(); i++) { TypeInformation<?> fieldType = cti.getTypeAt(i); ret += StringUtils.repeat(' ', indent + 2) + fieldNames[i] + ":" + getSerializerTree(fieldType, indent); } } else { if (ti instanceof GenericTypeInfo) { ret += StringUtils.repeat(' ', indent) + "GenericTypeInfo (" + ti.getTypeClass().getSimpleName() + ")\n"; ret += getGenericTypeTree(ti.getTypeClass(), indent + 4); } else { ret += StringUtils.repeat(' ', indent) + ti.toString() + "\n"; } } return ret; }
private static <T> String getSerializerTree(TypeInformation<T> ti, int indent) { String ret = ""; if (ti instanceof CompositeType) { ret += StringUtils.repeat(' ', indent) + ti.getClass().getSimpleName() + "\n"; CompositeType<T> cti = (CompositeType<T>) ti; String[] fieldNames = cti.getFieldNames(); for (int i = 0; i < cti.getArity(); i++) { TypeInformation<?> fieldType = cti.getTypeAt(i); ret += StringUtils.repeat(' ', indent + 2) + fieldNames[i] + ":" + getSerializerTree(fieldType, indent); } } else { if (ti instanceof GenericTypeInfo) { ret += StringUtils.repeat(' ', indent) + "GenericTypeInfo (" + ti.getTypeClass().getSimpleName() + ")\n"; ret += getGenericTypeTree(ti.getTypeClass(), indent + 4); } else { ret += StringUtils.repeat(' ', indent) + ti.toString() + "\n"; } } return ret; }
private <E> TypeInformation[] getFieldTypes(TypeInformation<E> typeInfo, int[] fieldIndexes, String[] fieldNames) { TypeInformation[] fieldTypes; if (isCompositeType()) { CompositeType cType = (CompositeType) typeInfo; if (fieldNames.length != cType.getArity()) { // throw new IllegalArgumentException("Arity of type (" + cType.getFieldNames().length+ ") " + // "not equal to number of field names " + fieldNames.length + "."); LOGGER.warn("Arity of type (" + cType.getFieldNames().length + ") " + "not equal to number of field names " + fieldNames.length + "."); } fieldTypes = new TypeInformation[fieldIndexes.length]; for (int i = 0; i < fieldIndexes.length; i++) { fieldTypes[i] = cType.getTypeAt(fieldIndexes[i]); } } else if (isAtomicType()) { if (fieldIndexes.length != 1 || fieldIndexes[0] != 0) { throw new IllegalArgumentException( "Non-composite input type may have only a single field and its index must be 0."); } fieldTypes = new TypeInformation[]{typeInfo}; } else { throw new IllegalArgumentException( "Illegal input type info" ); } return fieldTypes; }
private <E> TypeInformation[] getFieldTypes(TypeInformation<E> typeInfo, int[] fieldIndexes, String[] fieldNames) { TypeInformation[] fieldTypes; if (isCompositeType()) { CompositeType cType = (CompositeType) typeInfo; if (fieldNames.length != cType.getArity()) { // throw new IllegalArgumentException("Arity of type (" + cType.getFieldNames().length+ ") " + // "not equal to number of field names " + fieldNames.length + "."); LOGGER.warn("Arity of type (" + cType.getFieldNames().length + ") " + "not equal to number of field names " + fieldNames.length + "."); } fieldTypes = new TypeInformation[fieldIndexes.length]; for (int i = 0; i < fieldIndexes.length; i++) { fieldTypes[i] = cType.getTypeAt(fieldIndexes[i]); } } else if (isAtomicType()) { if (fieldIndexes.length != 1 || fieldIndexes[0] != 0) { throw new IllegalArgumentException( "Non-composite input type may have only a single field and its index must be 0."); } fieldTypes = new TypeInformation[]{typeInfo}; } else { throw new IllegalArgumentException( "Illegal input type info" ); } return fieldTypes; }
/** * Creates a table schema from a {@link TypeInformation} instance. If the type information is * a {@link CompositeType}, the field names and types for the composite type are used to * construct the {@link TableSchema} instance. Otherwise, a table schema with a single field * is created. The field name is "f0" and the field type the provided type. * * @param typeInfo The {@link TypeInformation} from which the table schema is generated. * @return The table schema that was generated from the given {@link TypeInformation}. */ public static TableSchema fromTypeInfo(TypeInformation<?> typeInfo) { if (typeInfo instanceof CompositeType<?>) { final CompositeType<?> compositeType = (CompositeType<?>) typeInfo; // get field names and types from composite type final String[] fieldNames = compositeType.getFieldNames(); final TypeInformation<?>[] fieldTypes = new TypeInformation[fieldNames.length]; for (int i = 0; i < fieldTypes.length; i++) { fieldTypes[i] = compositeType.getTypeAt(i); } return new TableSchema(fieldNames, fieldTypes); } else { // create table schema with a single field named "f0" of the given type. return new TableSchema( new String[]{ATOMIC_TYPE_FIELD_NAME}, new TypeInformation<?>[]{typeInfo}); } }
String[] fieldNames = cType.getFieldNames(); this.originalKeyTypes = new TypeInformation<?>[keyPositions.length]; ArrayList<FlatFieldDescriptor> tmpList = new ArrayList<>();
String[] fieldNames = cType.getFieldNames(); this.originalKeyTypes = new TypeInformation<?>[keyPositions.length]; ArrayList<FlatFieldDescriptor> tmpList = new ArrayList<>();