Java Code Examples for org.apache.flink.api.common.typeutils.ComparatorTestBase.TestOutputView

The following examples show how to use org.apache.flink.api.common.typeutils.ComparatorTestBase.TestOutputView. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: EitherSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializeIndividually() throws IOException {
	EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>(
		ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO);
	EitherSerializer<LongValue, DoubleValue> eitherSerializer =
		(EitherSerializer<LongValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig());

	LongValue lv = new LongValue();
	DoubleValue dv = new DoubleValue();

	Either<LongValue, DoubleValue> left = Left(lv);
	Either<LongValue, DoubleValue> right = Right(dv);

	TestOutputView out = new TestOutputView();
	eitherSerializer.serialize(left, out);
	eitherSerializer.serialize(right, out);
	eitherSerializer.serialize(left, out);

	TestInputView in = out.getInputView();
	// the first deserialization creates a new instance of Left
	Either<LongValue, DoubleValue> copy0 = eitherSerializer.deserialize(right, in);

	// then the cross-references are used for future copies
	Either<LongValue, DoubleValue> copy1 = eitherSerializer.deserialize(copy0, in);
	Either<LongValue, DoubleValue> copy2 = eitherSerializer.deserialize(copy1, in);

	// validate reference equality
	assertSame(right, copy1);
	assertSame(copy0, copy2);

	// validate reference equality of contained objects
	assertSame(right.right(), copy1.right());
	assertSame(copy0.left(), copy2.left());
}
 
Example 2
Source Project: flink   Source File: EitherSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializeIndividually() throws IOException {
	EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>(
		ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO);
	EitherSerializer<LongValue, DoubleValue> eitherSerializer =
		(EitherSerializer<LongValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig());

	LongValue lv = new LongValue();
	DoubleValue dv = new DoubleValue();

	Either<LongValue, DoubleValue> left = Left(lv);
	Either<LongValue, DoubleValue> right = Right(dv);

	TestOutputView out = new TestOutputView();
	eitherSerializer.serialize(left, out);
	eitherSerializer.serialize(right, out);
	eitherSerializer.serialize(left, out);

	TestInputView in = out.getInputView();
	// the first deserialization creates a new instance of Left
	Either<LongValue, DoubleValue> copy0 = eitherSerializer.deserialize(right, in);

	// then the cross-references are used for future copies
	Either<LongValue, DoubleValue> copy1 = eitherSerializer.deserialize(copy0, in);
	Either<LongValue, DoubleValue> copy2 = eitherSerializer.deserialize(copy1, in);

	// validate reference equality
	assertSame(right, copy1);
	assertSame(copy0, copy2);

	// validate reference equality of contained objects
	assertSame(right.right(), copy1.right());
	assertSame(copy0.left(), copy2.left());
}
 
Example 3
Source Project: flink   Source File: EitherSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializeIndividually() throws IOException {
	EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>(
		ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO);
	EitherSerializer<LongValue, DoubleValue> eitherSerializer =
		(EitherSerializer<LongValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig());

	LongValue lv = new LongValue();
	DoubleValue dv = new DoubleValue();

	Either<LongValue, DoubleValue> left = Left(lv);
	Either<LongValue, DoubleValue> right = Right(dv);

	TestOutputView out = new TestOutputView();
	eitherSerializer.serialize(left, out);
	eitherSerializer.serialize(right, out);
	eitherSerializer.serialize(left, out);

	TestInputView in = out.getInputView();
	// the first deserialization creates a new instance of Left
	Either<LongValue, DoubleValue> copy0 = eitherSerializer.deserialize(right, in);

	// then the cross-references are used for future copies
	Either<LongValue, DoubleValue> copy1 = eitherSerializer.deserialize(copy0, in);
	Either<LongValue, DoubleValue> copy2 = eitherSerializer.deserialize(copy1, in);

	// validate reference equality
	assertSame(right, copy1);
	assertSame(copy0, copy2);

	// validate reference equality of contained objects
	assertSame(right.right(), copy1.right());
	assertSame(copy0.left(), copy2.left());
}