@Override public TypeInformation<Tuple2<K, V>> getProducedType() { return new TupleTypeInfo<>(TypeExtractor.createTypeInfo(keyClass), TypeExtractor.createTypeInfo(valueClass)); } }
/** * The equals method does only check for field types. Field names do not matter during * runtime so we can consider rows with the same field types as equal. * Use {@link RowTypeInfo#schemaEquals(Object)} for checking schema-equivalence. */ @Override public boolean equals(Object obj) { if (obj instanceof RowTypeInfo) { final RowTypeInfo other = (RowTypeInfo) obj; return other.canEqual(this) && super.equals(other); } else { return false; } }
/** * Creates a new MessageAcknowledgingSourceBase for IDs of the given type. * * @param idClass The class of the message ID type, used to create a serializer for the message IDs. */ protected MessageAcknowledgingSourceBase(Class<UId> idClass) { this(TypeExtractor.getForClass(idClass)); }
@Override protected EitherTypeInfo<?, ?>[] getTestData() { return new EitherTypeInfo<?, ?>[] { new EitherTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO), new EitherTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, new TupleTypeInfo<Tuple2<Double, Long>>(TypeExtractor.getForClass(Double.class), TypeExtractor.getForClass(String.class))) }; } }
@Test public void testPojoWC() { TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(WC.class); checkWCPojoAsserts(typeForClass); WC t = new WC(); t.complex = new ComplexNestedClass(); TypeInformation<?> typeForObject = TypeExtractor.getForObject(t); checkWCPojoAsserts(typeForObject); }
@Test public void testPojoAllPublic() { TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(AllPublic.class); checkAllPublicAsserts(typeForClass); TypeInformation<?> typeForObject = TypeExtractor.getForObject(new AllPublic() ); checkAllPublicAsserts(typeForObject); }
@Test public void testPojoExtendingTuple() { TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(FromTuple.class); checkFromTuplePojo(typeForClass); FromTuple ft = new FromTuple(); ft.f0 = ""; ft.f1 = ""; ft.f2 = 0L; TypeInformation<?> typeForObject = TypeExtractor.getForObject(ft); checkFromTuplePojo(typeForObject); }
@Override protected TupleTypeInfo<?>[] getTestData() { return new TupleTypeInfo<?>[] { new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO), new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.BOOLEAN_TYPE_INFO) }; }
@Override protected ObjectArrayTypeInfo<?, ?>[] getTestData() { return new ObjectArrayTypeInfo<?, ?>[] { ObjectArrayTypeInfo.getInfoFor(TestClass[].class, new GenericTypeInfo<>(TestClass.class)), ObjectArrayTypeInfo.getInfoFor(TestClass[].class, new PojoTypeInfo<>(TestClass.class, new ArrayList<PojoField>())) }; }
@Override protected GenericTypeInfo<?>[] getTestData() { return new GenericTypeInfo<?>[] { new GenericTypeInfo<>(TestClass.class), new GenericTypeInfo<>(AlternativeClass.class) }; }
private TypeInformation<?>[] extractFieldTypes(int[] fields, TypeInformation<?> inType) { TupleTypeInfo<?> inTupleType = (TupleTypeInfo<?>) inType; TypeInformation<?>[] fieldTypes = new TypeInformation[fields.length]; for (int i = 0; i < fields.length; i++) { fieldTypes[i] = inTupleType.getTypeAt(fields[i]); } return fieldTypes; }
@Test(expected = InvalidTypesException.class) public void testMissingTypeInference() { MapFunction f = new MyFaultyMapper2(); TypeExtractor.getMapReturnTypes(f, new MyFaultyTypeInfo()); }
@Override protected ValueTypeInfo<?>[] getTestData() { return new ValueTypeInfo<?>[] { new ValueTypeInfo<>(TestClass.class), new ValueTypeInfo<>(AlternativeClass.class), new ValueTypeInfo<>(Record.class), }; }
@Override @SuppressWarnings("unchecked") public void setInputType(TypeInformation<?> type, ExecutionConfig executionConfig) { if (this.writerTemplate instanceof InputTypeConfigurable) { ((InputTypeConfigurable) writerTemplate).setInputType(type, executionConfig); } }
@Override protected MultisetTypeInfo<?>[] getTestData() { return new MultisetTypeInfo<?>[] { new MultisetTypeInfo<>(BasicTypeInfo.STRING_TYPE_INFO), new MultisetTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO), new MultisetTypeInfo<>(Long.class) }; } }
/** * Create a new {@code MapStateDescriptor} with the given name and the given type information. * * @param name The name of the {@code MapStateDescriptor}. * @param keyTypeInfo The type information for the keys in the state. * @param valueTypeInfo The type information for the values in the state. */ public MapStateDescriptor(String name, TypeInformation<UK> keyTypeInfo, TypeInformation<UV> valueTypeInfo) { super(name, new MapTypeInfo<>(keyTypeInfo, valueTypeInfo), null); }
/** * Creates a new {@code ListStateDescriptor} with the given name and list element type. * * <p>If this constructor fails (because it is not possible to describe the type via a class), * consider using the {@link #ListStateDescriptor(String, TypeInformation)} constructor. * * @param name The (unique) name for the state. * @param elementTypeClass The type of the elements in the state. */ public ListStateDescriptor(String name, Class<T> elementTypeClass) { super(name, new ListTypeInfo<>(elementTypeClass), null); }
@Override public boolean equals(Object obj) { if (obj instanceof WritableTypeInfo) { @SuppressWarnings("unchecked") WritableTypeInfo<T> writableTypeInfo = (WritableTypeInfo<T>) obj; return writableTypeInfo.canEqual(this) && typeClass == writableTypeInfo.typeClass; } else { return false; } }
@Override public boolean equals(Object obj) { if (obj instanceof ValueTypeInfo) { @SuppressWarnings("unchecked") ValueTypeInfo<T> valueTypeInfo = (ValueTypeInfo<T>) obj; return valueTypeInfo.canEqual(this) && type == valueTypeInfo.type; } else { return false; } }
@Override public TypeInformation<Tuple2<K, V>> getProducedType() { return new TupleTypeInfo<Tuple2<K, V>>(TypeExtractor.createTypeInfo(keyClass), TypeExtractor.createTypeInfo(valueClass)); } }