Java Code Examples for org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo#INT_PRIMITIVE_ARRAY_TYPE_INFO

The following examples show how to use org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo#INT_PRIMITIVE_ARRAY_TYPE_INFO . 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-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPOJOWithNestedArrayNoHashCodeKeyRejection() {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	DataStream<POJOWithHashCode> input = env.fromElements(
			new POJOWithHashCode(new int[] {1, 2}));

	TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple1<int[]>>(
			PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);

	// adjust the rule
	expectedException.expect(InvalidProgramException.class);
	expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));

	input.keyBy("id");
}
 
Example 2
Source File: Types.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Generates type information for an array consisting of Java primitive elements. The elements do
 * not support null values.
 *
 * @param elementType type of the array elements; e.g. Types.INT()
 */
public static TypeInformation<?> PRIMITIVE_ARRAY(TypeInformation<?> elementType) {
	if (elementType.equals(BOOLEAN())) {
		return PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(BYTE())) {
		return PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(SHORT())) {
		return PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(INT())) {
		return PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(LONG())) {
		return PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(FLOAT())) {
		return PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(DOUBLE())) {
		return PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO;
	}
	throw new TableException(
		String.format(
			"%s cannot be an element of a primitive array. Only Java primitive types are supported.",
			elementType));
}
 
Example 3
Source File: DataStreamTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPOJOWithNestedArrayNoHashCodeKeyRejection() {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	DataStream<POJOWithHashCode> input = env.fromElements(
			new POJOWithHashCode(new int[] {1, 2}));

	TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple1<int[]>>(
			PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);

	// adjust the rule
	expectedException.expect(InvalidProgramException.class);
	expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));

	input.keyBy("id");
}
 
Example 4
Source File: Types.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Generates type information for an array consisting of Java primitive elements. The elements do
 * not support null values.
 *
 * @param elementType type of the array elements; e.g. Types.INT()
 */
public static TypeInformation<?> PRIMITIVE_ARRAY(TypeInformation<?> elementType) {
	if (elementType.equals(BOOLEAN())) {
		return PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(BYTE())) {
		return PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(SHORT())) {
		return PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(INT())) {
		return PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(LONG())) {
		return PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(FLOAT())) {
		return PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO;
	} else if (elementType.equals(DOUBLE())) {
		return PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO;
	}
	throw new TableException(
		String.format(
			"%s cannot be an element of a primitive array. Only Java primitive types are supported.",
			elementType));
}
 
Example 5
Source File: DataStreamTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPOJOWithNestedArrayNoHashCodeKeyRejection() {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	DataStream<POJOWithHashCode> input = env.fromElements(
			new POJOWithHashCode(new int[] {1, 2}));

	TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple1<int[]>>(
			PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);

	// adjust the rule
	expectedException.expect(InvalidProgramException.class);
	expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));

	input.keyBy("id");
}
 
Example 6
Source File: IntPrimitiveArrayComparatorTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public IntPrimitiveArrayComparatorTest() {
	super(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);
}
 
Example 7
Source File: IntPrimitiveArrayComparatorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
public IntPrimitiveArrayComparatorTest() {
	super(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);
}
 
Example 8
Source File: IntPrimitiveArrayComparatorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
public IntPrimitiveArrayComparatorTest() {
	super(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO);
}