org.apache.flink.api.java.typeutils.EnumTypeInfo Java Examples

The following examples show how to use org.apache.flink.api.java.typeutils.EnumTypeInfo. 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: DataStreamTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testEnumKeyRejection() {
	KeySelector<Tuple2<TestEnum, String>, TestEnum> keySelector = value -> value.f0;

	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	DataStream<Tuple2<TestEnum, String>> input = env.fromElements(
			Tuple2.of(TestEnum.FOO, "Foo"),
			Tuple2.of(TestEnum.BAR, "Bar"));

	expectedException.expect(InvalidProgramException.class);
	expectedException.expectMessage(new StringStartsWith("Type " + EnumTypeInfo.of(TestEnum.class) + " cannot be used as key."));

	input.keyBy(keySelector);
}
 
Example #2
Source File: KeyedStream.java    From flink with Apache License 2.0 4 votes vote down vote up
private static boolean isEnumType(TypeInformation<?> type) {
	return type instanceof EnumTypeInfo;
}
 
Example #3
Source File: Types.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Returns type information for Java enumerations. Null values are not supported.
 *
 * @param enumType enumeration class extending {@link java.lang.Enum}
 */
public static <E extends Enum<E>> TypeInformation<E> ENUM(Class<E> enumType) {
	return new EnumTypeInfo<>(enumType);
}
 
Example #4
Source File: Types.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Returns type information for Java enumerations. Null values are not supported.
 *
 * @param enumType enumeration class extending {@link java.lang.Enum}
 */
public static <E extends Enum<E>> TypeInformation<E> ENUM(Class<E> enumType) {
	return new EnumTypeInfo<>(enumType);
}
 
Example #5
Source File: Types.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Returns type information for Java enumerations. Null values are not supported.
 *
 * @param enumType enumeration class extending {@link java.lang.Enum}
 */
public static <E extends Enum<E>> TypeInformation<E> ENUM(Class<E> enumType) {
	return new EnumTypeInfo<>(enumType);
}