org.apache.flink.api.java.typeutils.GenericTypeInfo Java Examples
The following examples show how to use
org.apache.flink.api.java.typeutils.GenericTypeInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FieldInfoUtils.java From flink with Apache License 2.0 | 6 votes |
private static <A> List<FieldInfo> extractFieldInformation( TypeInformation<A> inputType, Expression[] exprs) { final List<FieldInfo> fieldInfos; if (inputType instanceof GenericTypeInfo && inputType.getTypeClass() == Row.class) { throw new ValidationException( "An input of GenericTypeInfo<Row> cannot be converted to Table. " + "Please specify the type of the input with a RowTypeInfo."); } else if (inputType instanceof TupleTypeInfoBase) { fieldInfos = extractFieldInfosFromTupleType((TupleTypeInfoBase<?>) inputType, exprs); } else if (inputType instanceof PojoTypeInfo) { fieldInfos = extractFieldInfosByNameReference((CompositeType<?>) inputType, exprs); } else { fieldInfos = extractFieldInfoFromAtomicType(inputType, exprs); } return fieldInfos; }
Example #2
Source File: SerializersTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testTypeRegistrationFromTypeInfo() { ExecutionConfig conf = new ExecutionConfig(); Serializers.recursivelyRegisterType(new GenericTypeInfo<>(ClassWithNested.class), conf, new HashSet<Class<?>>()); KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type. assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0); // check if the generic type from one field is also registered (its very likely that // generic types are also used as fields somewhere. assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0); }
Example #3
Source File: Utils.java From flink with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: DataStreamTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testObjectArrayKeyRejection() { KeySelector<Tuple2<Integer[], String>, Object[]> keySelector = new KeySelector<Tuple2<Integer[], String>, Object[]>() { @Override public Object[] getKey(Tuple2<Integer[], String> value) throws Exception { Object[] ks = new Object[value.f0.length]; for (int i = 0; i < ks.length; i++) { ks[i] = new Object(); } return ks; } }; ObjectArrayTypeInfo<Object[], Object> keyTypeInfo = ObjectArrayTypeInfo.getInfoFor( Object[].class, new GenericTypeInfo<>(Object.class)); testKeyRejection(keySelector, keyTypeInfo); }
Example #5
Source File: DataTypeExtractorTest.java From flink with Apache License 2.0 | 6 votes |
private static DataType getPojoWithRawSelfReferenceDataType() { final StructuredType.Builder builder = StructuredType.newBuilder(PojoWithRawSelfReference.class); builder.attributes( Arrays.asList( new StructuredAttribute( "integer", new IntType()), new StructuredAttribute( "reference", new TypeInformationRawType<>(new GenericTypeInfo<>(PojoWithRawSelfReference.class))))); builder.setFinal(true); builder.setInstantiable(true); final StructuredType structuredType = builder.build(); final List<DataType> fieldDataTypes = Arrays.asList( DataTypes.INT(), DataTypes.RAW(new GenericTypeInfo<>(PojoWithRawSelfReference.class)) ); return new FieldsDataType(structuredType, PojoWithRawSelfReference.class, fieldDataTypes); }
Example #6
Source File: Keys.java From flink with Apache License 2.0 | 6 votes |
@Override public <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo) { if (keyFields.size() != 1) { throw new InvalidProgramException("Custom partitioners can only be used with keys that have one key field."); } if (typeInfo == null) { // try to extract key type from partitioner try { typeInfo = TypeExtractor.getPartitionerTypes(partitioner); } catch (Throwable t) { // best effort check, so we ignore exceptions } } // only check if type is known and not a generic type if (typeInfo != null && !(typeInfo instanceof GenericTypeInfo)) { // check equality of key and partitioner type if (!keyType.equals(typeInfo)) { throw new InvalidProgramException("The partitioner is incompatible with the key type. " + "Partitioner type: " + typeInfo + " , key type: " + keyType); } } }
Example #7
Source File: Serializers.java From flink with Apache License 2.0 | 6 votes |
public static void recursivelyRegisterType(TypeInformation<?> typeInfo, ExecutionConfig config, Set<Class<?>> alreadySeen) { if (typeInfo instanceof GenericTypeInfo) { GenericTypeInfo<?> genericTypeInfo = (GenericTypeInfo<?>) typeInfo; Serializers.recursivelyRegisterType(genericTypeInfo.getTypeClass(), config, alreadySeen); } else if (typeInfo instanceof CompositeType) { List<GenericTypeInfo<?>> genericTypesInComposite = new ArrayList<>(); getContainedGenericTypes((CompositeType<?>)typeInfo, genericTypesInComposite); for (GenericTypeInfo<?> gt : genericTypesInComposite) { Serializers.recursivelyRegisterType(gt.getTypeClass(), config, alreadySeen); } } else if (typeInfo instanceof ObjectArrayTypeInfo) { ObjectArrayTypeInfo<?, ?> objectArrayTypeInfo = (ObjectArrayTypeInfo<?, ?>) typeInfo; recursivelyRegisterType(objectArrayTypeInfo.getComponentInfo(), config, alreadySeen); } }
Example #8
Source File: ExecutionConfigTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testDisableGenericTypes() { ExecutionConfig conf = new ExecutionConfig(); TypeInformation<Object> typeInfo = new GenericTypeInfo<Object>(Object.class); // by default, generic types are supported TypeSerializer<Object> serializer = typeInfo.createSerializer(conf); assertTrue(serializer instanceof KryoSerializer); // expect an exception when generic types are disabled conf.disableGenericTypes(); try { typeInfo.createSerializer(conf); fail("should have failed with an exception"); } catch (UnsupportedOperationException e) { // expected } }
Example #9
Source File: OuterJoinITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testJoinWithAtomicType2() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Integer> ds1 = env.fromElements(1, 2); DataSet<Tuple3<Integer, Long, String>> ds2 = CollectionDataSets.getSmall3TupleDataSet(env); DataSet<Tuple2<Integer, Tuple3<Integer, Long, String>>> joinDs = ds1 .fullOuterJoin(ds2) .where("*") .equalTo(0) .with(new ProjectBothFunction<Integer, Tuple3<Integer, Long, String>>()) .returns(new GenericTypeInfo(Tuple2.class)); List<Tuple2<Integer, Tuple3<Integer, Long, String>>> result = joinDs.collect(); String expected = "1,(1,1,Hi)\n" + "2,(2,2,Hello)\n" + "null,(3,2,Hello world)\n"; compareResultAsTuples(result, expected); }
Example #10
Source File: ExecutionConfigTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testDisableGenericTypes() { ExecutionConfig conf = new ExecutionConfig(); TypeInformation<Object> typeInfo = new GenericTypeInfo<Object>(Object.class); // by default, generic types are supported TypeSerializer<Object> serializer = typeInfo.createSerializer(conf); assertTrue(serializer instanceof KryoSerializer); // expect an exception when generic types are disabled conf.disableGenericTypes(); try { typeInfo.createSerializer(conf); fail("should have failed with an exception"); } catch (UnsupportedOperationException e) { // expected } }
Example #11
Source File: SerializersTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testTypeRegistrationFromTypeInfo() { ExecutionConfig conf = new ExecutionConfig(); Serializers.recursivelyRegisterType(new GenericTypeInfo<>(ClassWithNested.class), conf, new HashSet<Class<?>>()); KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type. assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0); // check if the generic type from one field is also registered (its very likely that // generic types are also used as fields somewhere. assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0); }
Example #12
Source File: WeatherDataComplexEventProcessingExample2.java From FlinkExperiments with MIT License | 6 votes |
private static <TWarningType extends IWarning> DataStream<TWarningType> toWarningStream(DataStream<LocalWeatherData> localWeatherDataDataStream, IWarningPattern<LocalWeatherData, TWarningType> warningPattern) { PatternStream<LocalWeatherData> tempPatternStream = CEP.pattern( localWeatherDataDataStream.keyBy(new KeySelector<LocalWeatherData, String>() { @Override public String getKey(LocalWeatherData localWeatherData) throws Exception { return localWeatherData.getStation().getWban(); } }), warningPattern.getEventPattern()); DataStream<TWarningType> warnings = tempPatternStream.select(new PatternSelectFunction<LocalWeatherData, TWarningType>() { @Override public TWarningType select(Map<String, List<LocalWeatherData>> map) throws Exception { return warningPattern.create(map); } }, new GenericTypeInfo<TWarningType>(warningPattern.getWarningTargetType())); return warnings; }
Example #13
Source File: FlinkStateInternalsTest.java From beam with Apache License 2.0 | 6 votes |
public static KeyedStateBackend<ByteBuffer> createStateBackend() throws Exception { MemoryStateBackend backend = new MemoryStateBackend(); AbstractKeyedStateBackend<ByteBuffer> keyedStateBackend = backend.createKeyedStateBackend( new DummyEnvironment("test", 1, 0), new JobID(), "test_op", new GenericTypeInfo<>(ByteBuffer.class).createSerializer(new ExecutionConfig()), 2, new KeyGroupRange(0, 1), new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()), TtlTimeProvider.DEFAULT, null, Collections.emptyList(), new CloseableRegistry()); changeKey(keyedStateBackend); return keyedStateBackend; }
Example #14
Source File: Utils.java From flink with Apache License 2.0 | 6 votes |
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; }
Example #15
Source File: Serializers.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static void recursivelyRegisterType(TypeInformation<?> typeInfo, ExecutionConfig config, Set<Class<?>> alreadySeen) { if (typeInfo instanceof GenericTypeInfo) { GenericTypeInfo<?> genericTypeInfo = (GenericTypeInfo<?>) typeInfo; Serializers.recursivelyRegisterType(genericTypeInfo.getTypeClass(), config, alreadySeen); } else if (typeInfo instanceof CompositeType) { List<GenericTypeInfo<?>> genericTypesInComposite = new ArrayList<>(); getContainedGenericTypes((CompositeType<?>)typeInfo, genericTypesInComposite); for (GenericTypeInfo<?> gt : genericTypesInComposite) { Serializers.recursivelyRegisterType(gt.getTypeClass(), config, alreadySeen); } } else if (typeInfo instanceof ObjectArrayTypeInfo) { ObjectArrayTypeInfo<?, ?> objectArrayTypeInfo = (ObjectArrayTypeInfo<?, ?>) typeInfo; recursivelyRegisterType(objectArrayTypeInfo.getComponentInfo(), config, alreadySeen); } }
Example #16
Source File: MapViewTypeInfoFactory.java From flink with Apache License 2.0 | 6 votes |
@Override public TypeInformation<MapView<K, V>> createTypeInfo(Type t, Map<String, TypeInformation<?>> genericParameters) { TypeInformation<?> keyType = genericParameters.get("K"); TypeInformation<?> valueType = genericParameters.get("V"); if (keyType == null) { // we might can get the keyType later from the MapView constructor keyType = new GenericTypeInfo<>(Object.class); } if (valueType == null) { // we might can get the keyType later from the MapView constructor valueType = new GenericTypeInfo<>(Object.class); } //noinspection unchecked return new MapViewTypeInfo<>((TypeInformation<K>) keyType, (TypeInformation<V>) valueType); }
Example #17
Source File: SerializersTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testTypeRegistrationFromTypeInfo() { ExecutionConfig conf = new ExecutionConfig(); Serializers.recursivelyRegisterType(new GenericTypeInfo<>(ClassWithNested.class), conf, new HashSet<Class<?>>()); KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type. assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0); // check if the generic type from one field is also registered (its very likely that // generic types are also used as fields somewhere. assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0); assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0); }
Example #18
Source File: OuterJoinITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testJoinWithAtomicType2() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Integer> ds1 = env.fromElements(1, 2); DataSet<Tuple3<Integer, Long, String>> ds2 = CollectionDataSets.getSmall3TupleDataSet(env); DataSet<Tuple2<Integer, Tuple3<Integer, Long, String>>> joinDs = ds1 .fullOuterJoin(ds2) .where("*") .equalTo(0) .with(new ProjectBothFunction<Integer, Tuple3<Integer, Long, String>>()) .returns(new GenericTypeInfo(Tuple2.class)); List<Tuple2<Integer, Tuple3<Integer, Long, String>>> result = joinDs.collect(); String expected = "1,(1,1,Hi)\n" + "2,(2,2,Hello)\n" + "null,(3,2,Hello world)\n"; compareResultAsTuples(result, expected); }
Example #19
Source File: OuterJoinITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testJoinWithAtomicType1() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env); DataSet<Integer> ds2 = env.fromElements(1, 2); DataSet<Tuple2<Tuple3<Integer, Long, String>, Integer>> joinDs = ds1 .fullOuterJoin(ds2) .where(0) .equalTo("*") .with(new ProjectBothFunction<Tuple3<Integer, Long, String>, Integer>()) .returns(new GenericTypeInfo(Tuple2.class)); List<Tuple2<Tuple3<Integer, Long, String>, Integer>> result = joinDs.collect(); String expected = "(1,1,Hi),1\n" + "(2,2,Hello),2\n" + "(3,2,Hello world),null\n"; compareResultAsTuples(result, expected); }
Example #20
Source File: Keys.java From flink with Apache License 2.0 | 6 votes |
@Override public <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo) { if (keyFields.size() != 1) { throw new InvalidProgramException("Custom partitioners can only be used with keys that have one key field."); } if (typeInfo == null) { // try to extract key type from partitioner try { typeInfo = TypeExtractor.getPartitionerTypes(partitioner); } catch (Throwable t) { // best effort check, so we ignore exceptions } } // only check if type is known and not a generic type if (typeInfo != null && !(typeInfo instanceof GenericTypeInfo)) { // check equality of key and partitioner type if (!keyType.equals(typeInfo)) { throw new InvalidProgramException("The partitioner is incompatible with the key type. " + "Partitioner type: " + typeInfo + " , key type: " + keyType); } } }
Example #21
Source File: NestedRowDataTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testNestedRowDataWithMultipleSegments() { BinaryRowData row = getBinaryRowData(); GenericTypeInfo<MyObj> info = new GenericTypeInfo<>(MyObj.class); TypeSerializer<MyObj> genericSerializer = info.createSerializer(new ExecutionConfig()); MemorySegment[] segments = splitBytes(row.getSegments()[0].getHeapMemory(), 3); row.pointTo(segments, 3, row.getSizeInBytes()); { RowData nestedRow = row.getRow(0, 5); assertEquals(nestedRow.getInt(0), 1); assertEquals(nestedRow.getLong(1), 5L); assertEquals(nestedRow.getString(2), StringData.fromString("12345678")); assertTrue(nestedRow.isNullAt(3)); assertEquals(new MyObj(15, 5), nestedRow.<MyObj>getRawValue(4).toObject(genericSerializer)); } }
Example #22
Source File: NestedRowTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testNestedRowWithMultipleSegments() { BinaryRow row = getBinaryRow(); GenericTypeInfo<MyObj> info = new GenericTypeInfo<>(MyObj.class); TypeSerializer<MyObj> genericSerializer = info.createSerializer(new ExecutionConfig()); MemorySegment[] segments = splitBytes(row.getSegments()[0].getHeapMemory(), 3); row.pointTo(segments, 3, row.getSizeInBytes()); { BaseRow nestedRow = row.getRow(0, 5); assertEquals(nestedRow.getInt(0), 1); assertEquals(nestedRow.getLong(1), 5L); assertEquals(nestedRow.getString(2), BinaryString.fromString("12345678")); assertTrue(nestedRow.isNullAt(3)); assertEquals(new MyObj(15, 5), BinaryGeneric.getJavaObjectFromBinaryGeneric(nestedRow.getGeneric(4), genericSerializer)); } }
Example #23
Source File: FieldInfoUtils.java From flink with Apache License 2.0 | 6 votes |
private static <A> List<FieldInfo> extractFieldInformation( TypeInformation<A> inputType, Expression[] exprs) { final List<FieldInfo> fieldInfos; if (inputType instanceof GenericTypeInfo && inputType.getTypeClass() == Row.class) { throw new ValidationException( "An input of GenericTypeInfo<Row> cannot be converted to Table. " + "Please specify the type of the input with a RowTypeInfo."); } else if (inputType instanceof TupleTypeInfoBase) { fieldInfos = extractFieldInfosFromTupleType((TupleTypeInfoBase<?>) inputType, exprs); } else if (inputType instanceof PojoTypeInfo) { fieldInfos = extractFieldInfosByNameReference((CompositeType<?>) inputType, exprs); } else { fieldInfos = extractFieldInfoFromAtomicType(inputType, exprs); } return fieldInfos; }
Example #24
Source File: MapViewTypeInfoFactory.java From flink with Apache License 2.0 | 6 votes |
@Override public TypeInformation<MapView<K, V>> createTypeInfo(Type t, Map<String, TypeInformation<?>> genericParameters) { TypeInformation<?> keyType = genericParameters.get("K"); TypeInformation<?> valueType = genericParameters.get("V"); if (keyType == null) { // we might can get the keyType later from the MapView constructor keyType = new GenericTypeInfo<>(Object.class); } if (valueType == null) { // we might can get the keyType later from the MapView constructor valueType = new GenericTypeInfo<>(Object.class); } //noinspection unchecked return new MapViewTypeInfo<>((TypeInformation<K>) keyType, (TypeInformation<V>) valueType); }
Example #25
Source File: JavaTableEnvironmentITCase.java From flink with Apache License 2.0 | 5 votes |
@Test(expected = ValidationException.class) public void testGenericRow() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); BatchTableEnvironment tableEnv = BatchTableEnvironment.create(env, config()); // use null value the enforce GenericType DataSet<Row> dataSet = env.fromElements(Row.of(1, 2L, "Hello", null)); assertTrue(dataSet.getType() instanceof GenericTypeInfo); assertTrue(dataSet.getType().getTypeClass().equals(Row.class)); // Must fail. Cannot import DataSet<Row> with GenericTypeInfo. tableEnv.fromDataSet(dataSet); }
Example #26
Source File: HiveAggSqlFunction.java From flink with Apache License 2.0 | 5 votes |
public HiveAggSqlFunction( FunctionIdentifier identifier, AggregateFunction aggregateFunction, FlinkTypeFactory typeFactory) { super(identifier, identifier.toString(), aggregateFunction, fromLegacyInfoToDataType(new GenericTypeInfo<>(Object.class)), fromLegacyInfoToDataType(new GenericTypeInfo<>(Object.class)), typeFactory, false, new Some<>(createReturnTypeInference(aggregateFunction, typeFactory))); this.aggregateFunction = aggregateFunction; }
Example #27
Source File: ListViewTypeInfoFactory.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeInformation<ListView<T>> createTypeInfo(Type t, Map<String, TypeInformation<?>> genericParameters) { TypeInformation<?> elementType = genericParameters.get("T"); if (elementType == null) { // we might can get the elementType later from the ListView constructor elementType = new GenericTypeInfo<>(Object.class); } //noinspection unchecked return new ListViewTypeInfo<>((TypeInformation<T>) elementType); }
Example #28
Source File: Serializers.java From flink with Apache License 2.0 | 5 votes |
/** * Returns all GenericTypeInfos contained in a composite type. * * @param typeInfo {@link CompositeType} */ private static void getContainedGenericTypes(CompositeType<?> typeInfo, List<GenericTypeInfo<?>> target) { for (int i = 0; i < typeInfo.getArity(); i++) { TypeInformation<?> type = typeInfo.getTypeAt(i); if (type instanceof CompositeType) { getContainedGenericTypes((CompositeType<?>) type, target); } else if (type instanceof GenericTypeInfo) { if (!target.contains(type)) { target.add((GenericTypeInfo<?>) type); } } } }
Example #29
Source File: HiveAggSqlFunction.java From flink with Apache License 2.0 | 5 votes |
public HiveAggSqlFunction(String name, String displayName, AggregateFunction aggregateFunction, FlinkTypeFactory typeFactory) { super(name, displayName, aggregateFunction, fromLegacyInfoToDataType(new GenericTypeInfo<>(Object.class)), fromLegacyInfoToDataType(new GenericTypeInfo<>(Object.class)), typeFactory, false, new Some<>(createReturnTypeInference(aggregateFunction, typeFactory))); this.aggregateFunction = aggregateFunction; }
Example #30
Source File: FieldInfoUtils.java From flink with Apache License 2.0 | 5 votes |
/** * Returns a {@link TypeInfoSchema} for a given {@link TypeInformation}. * * @param inputType The TypeInformation to extract the mapping from. * @param <A> The type of the TypeInformation. * @return A description of the input that enables creation of a {@link TableSchema}. * @see TypeInfoSchema */ public static <A> TypeInfoSchema getFieldsInfo(TypeInformation<A> inputType) { if (inputType instanceof GenericTypeInfo && inputType.getTypeClass() == Row.class) { throw new ValidationException( "An input of GenericTypeInfo<Row> cannot be converted to Table. " + "Please specify the type of the input with a RowTypeInfo."); } else { return new TypeInfoSchema( getFieldNames(inputType), getFieldIndices(inputType), fromLegacyInfoToDataType(getFieldTypes(inputType)), false); } }